diff options
| author | Jake Goulding <jake.goulding@gmail.com> | 2016-06-09 09:41:17 -0400 |
|---|---|---|
| committer | Jake Goulding <jake.goulding@gmail.com> | 2016-06-09 15:59:26 -0400 |
| commit | 4f01329e0eb48c9481e91ff1749367a4c0048d70 (patch) | |
| tree | 283488aefcf85b163c213db295244c133a84fff5 /src/rustllvm/PassWrapper.cpp | |
| parent | 0740a93cc290a5419807d2e8c6c442354baf46b0 (diff) | |
| download | rust-4f01329e0eb48c9481e91ff1749367a4c0048d70.tar.gz rust-4f01329e0eb48c9481e91ff1749367a4c0048d70.zip | |
Reflect supporting only LLVM 3.7+ in the LLVM wrappers
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 } |
