mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 10:57:35 +03:00
Drop support for LLVM < 3.7
This commit is contained in:
parent
4e174ff19c
commit
1fb269f940
72 changed files with 98 additions and 3862 deletions
|
@ -17,26 +17,16 @@
|
|||
#include "driver/cl_options_sanitizers.h"
|
||||
#include "driver/targetmachine.h"
|
||||
#include "llvm/LinkAllPasses.h"
|
||||
#if LDC_LLVM_VER >= 307
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#else
|
||||
#include "llvm/PassManager.h"
|
||||
#endif
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#if LDC_LLVM_VER >= 400
|
||||
#include "llvm/Analysis/InlineCost.h"
|
||||
#endif
|
||||
#if LDC_LLVM_VER >= 307
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#endif
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#if LDC_LLVM_VER >= 307
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#else
|
||||
#include "llvm/Target/TargetLibraryInfo.h"
|
||||
#endif
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/IR/LegacyPassNameParser.h"
|
||||
|
@ -93,8 +83,7 @@ static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>>
|
|||
static cl::opt<cl::boolOrDefault, false, opts::FlagParser<cl::boolOrDefault>>
|
||||
enableCrossModuleInlining(
|
||||
"cross-module-inlining", cl::ZeroOrMore, cl::Hidden,
|
||||
cl::desc("(*) Enable cross-module function inlining (default disabled) "
|
||||
"(LLVM >= 3.7)"));
|
||||
cl::desc("(*) Enable cross-module function inlining (default disabled)"));
|
||||
|
||||
static cl::opt<bool> unitAtATime("unit-at-a-time", cl::desc("Enable basic IPO"),
|
||||
cl::ZeroOrMore, cl::init(true));
|
||||
|
@ -128,15 +117,7 @@ bool willInline() {
|
|||
}
|
||||
|
||||
bool willCrossModuleInline() {
|
||||
#if LDC_LLVM_VER >= 307
|
||||
return enableCrossModuleInlining == llvm::cl::BOU_TRUE;
|
||||
#else
|
||||
// Cross-module inlining is disabled for <3.7 because we don't emit symbols in
|
||||
// COMDAT any groups pre-LLVM3.7. With cross-module inlining enabled, without
|
||||
// COMDAT any there are multiple-def linker errors when linking druntime.
|
||||
// See supportsCOMDAT().
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool isOptimizationEnabled() { return optimizeLevel != 0; }
|
||||
|
@ -251,13 +232,8 @@ static void addPGOPasses(legacy::PassManagerBase &mpm, unsigned optLevel) {
|
|||
* The selection mirrors Clang behavior and is based on LLVM's
|
||||
* PassManagerBuilder.
|
||||
*/
|
||||
#if LDC_LLVM_VER >= 307
|
||||
static void addOptimizationPasses(legacy::PassManagerBase &mpm,
|
||||
legacy::FunctionPassManager &fpm,
|
||||
#else
|
||||
static void addOptimizationPasses(PassManagerBase &mpm,
|
||||
FunctionPassManager &fpm,
|
||||
#endif
|
||||
unsigned optLevel, unsigned sizeLevel) {
|
||||
if (!noVerify) {
|
||||
fpm.add(createVerifierPass());
|
||||
|
@ -358,12 +334,9 @@ static void addOptimizationPasses(PassManagerBase &mpm,
|
|||
// This function runs optimization passes based on command line arguments.
|
||||
// Returns true if any optimization passes were invoked.
|
||||
bool ldc_optimize_module(llvm::Module *M) {
|
||||
// Create a PassManager to hold and optimize the collection of
|
||||
// per-module passes we are about to build.
|
||||
#if LDC_LLVM_VER >= 307
|
||||
legacy::
|
||||
#endif
|
||||
PassManager mpm;
|
||||
// Create a PassManager to hold and optimize the collection of
|
||||
// per-module passes we are about to build.
|
||||
legacy::PassManager mpm;
|
||||
|
||||
// Dont optimise spirv modules because turning GEPs into extracts triggers
|
||||
// asserts in the IR -> SPIR-V translation pass. SPIRV doesn't have a target
|
||||
|
@ -375,7 +348,6 @@ bool ldc_optimize_module(llvm::Module *M) {
|
|||
if (getComputeTargetType(M) == ComputeBackend::SPIRV)
|
||||
return false;
|
||||
|
||||
#if LDC_LLVM_VER >= 307
|
||||
// Add an appropriate TargetLibraryInfo pass for the module's triple.
|
||||
TargetLibraryInfoImpl *tlii =
|
||||
new TargetLibraryInfoImpl(Triple(M->getTargetTriple()));
|
||||
|
@ -385,59 +357,22 @@ bool ldc_optimize_module(llvm::Module *M) {
|
|||
tlii->disableAllFunctions();
|
||||
|
||||
mpm.add(new TargetLibraryInfoWrapperPass(*tlii));
|
||||
#else
|
||||
// Add an appropriate TargetLibraryInfo pass for the module's triple.
|
||||
TargetLibraryInfo *tli = new TargetLibraryInfo(Triple(M->getTargetTriple()));
|
||||
|
||||
// The -disable-simplify-libcalls flag actually disables all builtin optzns.
|
||||
if (disableSimplifyLibCalls) {
|
||||
tli->disableAllFunctions();
|
||||
}
|
||||
// The DataLayout is already set at the module (in module.cpp,
|
||||
// method Module::genLLVMModule())
|
||||
// FIXME: Introduce new command line switch default-data-layout to
|
||||
// override the module data layout
|
||||
|
||||
mpm.add(tli);
|
||||
#endif
|
||||
|
||||
// Add an appropriate DataLayout instance for this module.
|
||||
#if LDC_LLVM_VER >= 307
|
||||
// The DataLayout is already set at the module (in module.cpp,
|
||||
// method Module::genLLVMModule())
|
||||
// FIXME: Introduce new command line switch default-data-layout to
|
||||
// override the module data layout
|
||||
#elif LDC_LLVM_VER == 306
|
||||
mpm.add(new DataLayoutPass());
|
||||
#else
|
||||
const DataLayout *DL = M->getDataLayout();
|
||||
assert(DL &&
|
||||
"DataLayout not set at module");
|
||||
mpm.add(new DataLayoutPass(*DL));
|
||||
#endif
|
||||
|
||||
#if LDC_LLVM_VER >= 307
|
||||
// Add internal analysis passes from the target machine.
|
||||
mpm.add(createTargetTransformInfoWrapperPass(
|
||||
gTargetMachine->getTargetIRAnalysis()));
|
||||
#else
|
||||
// Add internal analysis passes from the target machine.
|
||||
gTargetMachine->addAnalysisPasses(mpm);
|
||||
#endif
|
||||
|
||||
// Also set up a manager for the per-function passes.
|
||||
#if LDC_LLVM_VER >= 307
|
||||
legacy::
|
||||
#endif
|
||||
FunctionPassManager fpm(M);
|
||||
// Also set up a manager for the per-function passes.
|
||||
legacy::FunctionPassManager fpm(M);
|
||||
|
||||
#if LDC_LLVM_VER >= 307
|
||||
// Add internal analysis passes from the target machine.
|
||||
fpm.add(createTargetTransformInfoWrapperPass(
|
||||
gTargetMachine->getTargetIRAnalysis()));
|
||||
#elif LDC_LLVM_VER >= 306
|
||||
fpm.add(new DataLayoutPass());
|
||||
gTargetMachine->addAnalysisPasses(fpm);
|
||||
#else
|
||||
fpm.add(new DataLayoutPass(M));
|
||||
gTargetMachine->addAnalysisPasses(fpm);
|
||||
#endif
|
||||
|
||||
// If the -strip-debug command line option was specified, add it before
|
||||
// anything else.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue