|
16 | 16 | #include "llvm/Object/ObjectFile.h"
|
17 | 17 | #include "llvm/Object/IRObjectFile.h"
|
18 | 18 | #include "llvm/Passes/PassBuilder.h"
|
19 |
| -#if LLVM_VERSION_GE(9, 0) |
20 | 19 | #include "llvm/Passes/StandardInstrumentations.h"
|
21 |
| -#endif |
22 | 20 | #include "llvm/Support/CBindingWrapping.h"
|
23 | 21 | #include "llvm/Support/FileSystem.h"
|
24 | 22 | #include "llvm/Support/Host.h"
|
|
31 | 29 | #include "llvm-c/Transforms/PassManagerBuilder.h"
|
32 | 30 |
|
33 | 31 | #include "llvm/Transforms/Instrumentation.h"
|
34 |
| -#if LLVM_VERSION_GE(9, 0) |
35 | 32 | #include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
|
36 | 33 | #include "llvm/Support/TimeProfiler.h"
|
37 |
| -#endif |
38 | 34 | #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
|
39 | 35 | #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
|
40 |
| -#if LLVM_VERSION_GE(9, 0) |
41 | 36 | #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
|
42 |
| -#endif |
43 | 37 | #include "llvm/Transforms/Utils/NameAnonGlobals.h"
|
44 | 38 |
|
45 | 39 | using namespace llvm;
|
@@ -73,20 +67,18 @@ extern "C" void LLVMTimeTraceProfilerInitialize() {
|
73 | 67 | timeTraceProfilerInitialize(
|
74 | 68 | /* TimeTraceGranularity */ 0,
|
75 | 69 | /* ProcName */ "rustc");
|
76 |
| -#elif LLVM_VERSION_GE(9, 0) |
| 70 | +#else |
77 | 71 | timeTraceProfilerInitialize();
|
78 | 72 | #endif
|
79 | 73 | }
|
80 | 74 |
|
81 | 75 | extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
|
82 |
| -#if LLVM_VERSION_GE(9, 0) |
83 | 76 | StringRef FN(FileName);
|
84 | 77 | std::error_code EC;
|
85 | 78 | raw_fd_ostream OS(FN, EC, sys::fs::CD_CreateAlways);
|
86 | 79 |
|
87 | 80 | timeTraceProfilerWrite(OS);
|
88 | 81 | timeTraceProfilerCleanup();
|
89 |
| -#endif |
90 | 82 | }
|
91 | 83 |
|
92 | 84 | enum class LLVMRustPassKind {
|
@@ -127,22 +119,14 @@ extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover)
|
127 | 119 | extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
|
128 | 120 | const bool CompileKernel = false;
|
129 | 121 |
|
130 |
| -#if LLVM_VERSION_GE(9, 0) |
131 | 122 | return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
132 |
| -#else |
133 |
| - return wrap(createAddressSanitizerModulePass(CompileKernel, Recover)); |
134 |
| -#endif |
135 | 123 | }
|
136 | 124 |
|
137 | 125 | extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
|
138 |
| -#if LLVM_VERSION_GE(9, 0) |
139 | 126 | const bool CompileKernel = false;
|
140 | 127 |
|
141 | 128 | return wrap(createMemorySanitizerLegacyPassPass(
|
142 | 129 | MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
|
143 |
| -#else |
144 |
| - return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover)); |
145 |
| -#endif |
146 | 130 | }
|
147 | 131 |
|
148 | 132 | extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
|
@@ -657,8 +641,6 @@ extern "C" typedef void (*LLVMRustSelfProfileBeforePassCallback)(void*, // LlvmS
|
657 | 641 | const char*); // IR name
|
658 | 642 | extern "C" typedef void (*LLVMRustSelfProfileAfterPassCallback)(void*); // LlvmSelfProfiler
|
659 | 643 |
|
660 |
| -#if LLVM_VERSION_GE(9, 0) |
661 |
| - |
662 | 644 | std::string LLVMRustwrappedIrGetName(const llvm::Any &WrappedIr) {
|
663 | 645 | if (any_isa<const Module *>(WrappedIr))
|
664 | 646 | return any_cast<const Module *>(WrappedIr)->getName().str();
|
@@ -706,7 +688,6 @@ void LLVMSelfProfileInitializeCallbacks(
|
706 | 688 | AfterPassCallback(LlvmSelfProfiler);
|
707 | 689 | });
|
708 | 690 | }
|
709 |
| -#endif |
710 | 691 |
|
711 | 692 | enum class LLVMRustOptStage {
|
712 | 693 | PreLinkNoLTO,
|
@@ -739,7 +720,6 @@ LLVMRustOptimizeWithNewPassManager(
|
739 | 720 | void* LlvmSelfProfiler,
|
740 | 721 | LLVMRustSelfProfileBeforePassCallback BeforePassCallback,
|
741 | 722 | LLVMRustSelfProfileAfterPassCallback AfterPassCallback) {
|
742 |
| -#if LLVM_VERSION_GE(9, 0) |
743 | 723 | Module *TheModule = unwrap(ModuleRef);
|
744 | 724 | TargetMachine *TM = unwrap(TMRef);
|
745 | 725 | PassBuilder::OptimizationLevel OptLevel = fromRust(OptLevelRust);
|
@@ -970,11 +950,6 @@ LLVMRustOptimizeWithNewPassManager(
|
970 | 950 | UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove
|
971 | 951 |
|
972 | 952 | MPM.run(*TheModule, MAM);
|
973 |
| -#else |
974 |
| - // The new pass manager has been available for a long time, |
975 |
| - // but we don't bother supporting it on old LLVM versions. |
976 |
| - report_fatal_error("New pass manager only supported since LLVM 9"); |
977 |
| -#endif |
978 | 953 | }
|
979 | 954 |
|
980 | 955 | // Callback to demangle function name
|
@@ -1325,12 +1300,9 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
|
1325 | 1300 | GlobalValue::LinkageTypes NewLinkage) {
|
1326 | 1301 | Ret->ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
|
1327 | 1302 | };
|
1328 |
| -#if LLVM_VERSION_GE(9, 0) |
| 1303 | + |
1329 | 1304 | thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage,
|
1330 | 1305 | Ret->GUIDPreservedSymbols);
|
1331 |
| -#else |
1332 |
| - thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage); |
1333 |
| -#endif |
1334 | 1306 |
|
1335 | 1307 | // Here we calculate an `ExportedGUIDs` set for use in the `isExported`
|
1336 | 1308 | // callback below. This callback below will dictate the linkage for all
|
|
0 commit comments