diff options
| author | bors <bors@rust-lang.org> | 2016-06-10 04:50:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-06-10 04:50:46 -0700 |
| commit | 68241f00ad8fb90474748b37ebd68b6bd46c796b (patch) | |
| tree | e12d369a793cb9997f8063558098aeb5ec80c4cb /src/rustllvm/PassWrapper.cpp | |
| parent | a9234c11e00d976e69bcab95342b8af469c82d5b (diff) | |
| parent | f3d9de4528e7be9428b5afddec25d9ed4622f305 (diff) | |
| download | rust-68241f00ad8fb90474748b37ebd68b6bd46c796b.tar.gz rust-68241f00ad8fb90474748b37ebd68b6bd46c796b.zip | |
Auto merge of #34178 - shepmaster:llvm-3.7-and-up, r=alexcrichton
Reflect supporting only LLVM 3.7+ in the LLVM wrappers Based on 12abddb06b681f5c1cb389074b5a35d3e260698f, it appears we can drop support for these older LLVM versions. Hopefully, this will make it slightly easier to support the changes needed for LLVM 3.9. r? @nagisa /cc @brson
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index b3d4e35d7b0..3564f338a02 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -15,12 +15,8 @@ #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" -#if LLVM_VERSION_MINOR >= 7 #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/TargetTransformInfo.h" -#else -#include "llvm/Target/TargetLibraryInfo.h" -#endif #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" @@ -49,7 +45,7 @@ LLVMInitializePasses() { initializeVectorization(Registry); initializeIPO(Registry); initializeAnalysis(Registry); -#if LLVM_VERSION_MINOR <= 7 +#if LLVM_VERSION_MINOR == 7 initializeIPA(Registry); #endif initializeTransformUtils(Registry); @@ -223,17 +219,8 @@ LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM, LLVMPassManagerRef PMR, LLVMModuleRef M) { PassManagerBase *PM = unwrap(PMR); -#if LLVM_VERSION_MINOR >= 7 PM->add(createTargetTransformInfoWrapperPass( unwrap(TM)->getTargetIRAnalysis())); -#else -#if LLVM_VERSION_MINOR == 6 - PM->add(new DataLayoutPass()); -#else - PM->add(new DataLayoutPass(unwrap(M))); -#endif - unwrap(TM)->addAnalysisPasses(*PM); -#endif } extern "C" void @@ -242,10 +229,8 @@ LLVMRustConfigurePassManagerBuilder(LLVMPassManagerBuilderRef PMB, bool MergeFunctions, bool SLPVectorize, bool LoopVectorize) { -#if LLVM_VERSION_MINOR >= 6 // Ignore mergefunc for now as enabling it causes crashes. //unwrap(PMB)->MergeFunctions = MergeFunctions; -#endif unwrap(PMB)->SLPVectorize = SLPVectorize; unwrap(PMB)->OptLevel = OptLevel; unwrap(PMB)->LoopVectorize = LoopVectorize; @@ -258,11 +243,7 @@ LLVMRustAddBuilderLibraryInfo(LLVMPassManagerBuilderRef PMB, LLVMModuleRef M, bool DisableSimplifyLibCalls) { Triple TargetTriple(unwrap(M)->getTargetTriple()); -#if LLVM_VERSION_MINOR >= 7 TargetLibraryInfoImpl *TLI = new TargetLibraryInfoImpl(TargetTriple); -#else - TargetLibraryInfo *TLI = new TargetLibraryInfo(TargetTriple); -#endif if (DisableSimplifyLibCalls) TLI->disableAllFunctions(); unwrap(PMB)->LibraryInfo = TLI; @@ -275,17 +256,10 @@ LLVMRustAddLibraryInfo(LLVMPassManagerRef PMB, LLVMModuleRef M, bool DisableSimplifyLibCalls) { Triple TargetTriple(unwrap(M)->getTargetTriple()); -#if LLVM_VERSION_MINOR >= 7 TargetLibraryInfoImpl TLII(TargetTriple); if (DisableSimplifyLibCalls) TLII.disableAllFunctions(); unwrap(PMB)->add(new TargetLibraryInfoWrapperPass(TLII)); -#else - TargetLibraryInfo *TLI = new TargetLibraryInfo(TargetTriple); - if (DisableSimplifyLibCalls) - TLI->disableAllFunctions(); - unwrap(PMB)->add(TLI); -#endif } // Unfortunately, the LLVM C API doesn't provide an easy way of iterating over @@ -323,25 +297,16 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, PassManager *PM = unwrap<PassManager>(PMR); std::string ErrorInfo; -#if LLVM_VERSION_MINOR >= 6 std::error_code EC; raw_fd_ostream OS(path, EC, sys::fs::F_None); if (EC) ErrorInfo = EC.message(); -#else - raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None); -#endif if (ErrorInfo != "") { LLVMRustSetLastError(ErrorInfo.c_str()); return false; } -#if LLVM_VERSION_MINOR >= 7 unwrap(Target)->addPassesToEmitFile(*PM, OS, FileType, false); -#else - formatted_raw_ostream FOS(OS); - unwrap(Target)->addPassesToEmitFile(*PM, FOS, FileType, false); -#endif PM->run(*unwrap(M)); // Apparently `addPassesToEmitFile` adds a pointer to our on-the-stack output @@ -358,14 +323,10 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR, PassManager *PM = unwrap<PassManager>(PMR); std::string ErrorInfo; -#if LLVM_VERSION_MINOR >= 6 std::error_code EC; raw_fd_ostream OS(path, EC, sys::fs::F_None); if (EC) ErrorInfo = EC.message(); -#else - raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None); -#endif formatted_raw_ostream FOS(OS); @@ -428,22 +389,10 @@ extern "C" void LLVMRustSetDataLayoutFromTargetMachine(LLVMModuleRef Module, LLVMTargetMachineRef TMR) { TargetMachine *Target = unwrap(TMR); -#if LLVM_VERSION_MINOR >= 7 unwrap(Module)->setDataLayout(Target->createDataLayout()); -#elif LLVM_VERSION_MINOR >= 6 - if (const DataLayout *DL = Target->getSubtargetImpl()->getDataLayout()) - unwrap(Module)->setDataLayout(DL); -#else - if (const DataLayout *DL = Target->getDataLayout()) - unwrap(Module)->setDataLayout(DL); -#endif } extern "C" LLVMTargetDataRef LLVMRustGetModuleDataLayout(LLVMModuleRef M) { -#if LLVM_VERSION_MINOR >= 7 return wrap(&unwrap(M)->getDataLayout()); -#else - return wrap(unwrap(M)->getDataLayout()); -#endif } |
