|
35 | 35 | #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" |
36 | 36 | #include "llvm/Transforms/Utils/AddDiscriminators.h" |
37 | 37 | #include "llvm/Transforms/Utils/FunctionImportUtils.h" |
38 | | -#if LLVM_VERSION_GE(18, 0) |
39 | 38 | #include "llvm/TargetParser/Host.h" |
40 | | -#endif |
41 | 39 | #include "llvm/Support/TimeProfiler.h" |
42 | 40 | #include "llvm/Transforms/Instrumentation.h" |
43 | 41 | #include "llvm/Transforms/Instrumentation/AddressSanitizer.h" |
@@ -241,11 +239,7 @@ enum class LLVMRustCodeGenOptLevel { |
241 | 239 | Aggressive, |
242 | 240 | }; |
243 | 241 |
|
244 | | -#if LLVM_VERSION_GE(18, 0) |
245 | 242 | using CodeGenOptLevelEnum = llvm::CodeGenOptLevel; |
246 | | -#else |
247 | | -using CodeGenOptLevelEnum = llvm::CodeGenOpt::Level; |
248 | | -#endif |
249 | 243 |
|
250 | 244 | static CodeGenOptLevelEnum fromRust(LLVMRustCodeGenOptLevel Level) { |
251 | 245 | switch (Level) { |
@@ -371,29 +365,23 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, |
371 | 365 | } |
372 | 366 |
|
373 | 367 | extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) { |
374 | | -#if LLVM_VERSION_GE(18, 0) |
375 | 368 | const TargetMachine *Target = unwrap(TM); |
376 | 369 | const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo(); |
377 | 370 | const ArrayRef<SubtargetFeatureKV> FeatTable = |
378 | 371 | MCInfo->getAllProcessorFeatures(); |
379 | 372 | return FeatTable.size(); |
380 | | -#else |
381 | | - return 0; |
382 | | -#endif |
383 | 373 | } |
384 | 374 |
|
385 | 375 | extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index, |
386 | 376 | const char **Feature, |
387 | 377 | const char **Desc) { |
388 | | -#if LLVM_VERSION_GE(18, 0) |
389 | 378 | const TargetMachine *Target = unwrap(TM); |
390 | 379 | const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo(); |
391 | 380 | const ArrayRef<SubtargetFeatureKV> FeatTable = |
392 | 381 | MCInfo->getAllProcessorFeatures(); |
393 | 382 | const SubtargetFeatureKV Feat = FeatTable[Index]; |
394 | 383 | *Feature = Feat.Key; |
395 | 384 | *Desc = Feat.Desc; |
396 | | -#endif |
397 | 385 | } |
398 | 386 |
|
399 | 387 | extern "C" const char *LLVMRustGetHostCPUName(size_t *len) { |
@@ -570,17 +558,9 @@ enum class LLVMRustFileType { |
570 | 558 | static CodeGenFileType fromRust(LLVMRustFileType Type) { |
571 | 559 | switch (Type) { |
572 | 560 | case LLVMRustFileType::AssemblyFile: |
573 | | -#if LLVM_VERSION_GE(18, 0) |
574 | 561 | return CodeGenFileType::AssemblyFile; |
575 | | -#else |
576 | | - return CGFT_AssemblyFile; |
577 | | -#endif |
578 | 562 | case LLVMRustFileType::ObjectFile: |
579 | | -#if LLVM_VERSION_GE(18, 0) |
580 | 563 | return CodeGenFileType::ObjectFile; |
581 | | -#else |
582 | | - return CGFT_ObjectFile; |
583 | | -#endif |
584 | 564 | default: |
585 | 565 | report_fatal_error("Bad FileType."); |
586 | 566 | } |
@@ -866,11 +846,7 @@ extern "C" LLVMRustResult LLVMRustOptimize( |
866 | 846 | // cargo run tests in multhreading mode by default |
867 | 847 | // so use atomics for coverage counters |
868 | 848 | Options.Atomic = true; |
869 | | -#if LLVM_VERSION_GE(18, 0) |
870 | 849 | MPM.addPass(InstrProfilingLoweringPass(Options, false)); |
871 | | -#else |
872 | | - MPM.addPass(InstrProfiling(Options, false)); |
873 | | -#endif |
874 | 850 | }); |
875 | 851 | } |
876 | 852 |
|
@@ -1211,19 +1187,13 @@ struct LLVMRustThinLTOData { |
1211 | 1187 |
|
1212 | 1188 | // Not 100% sure what these are, but they impact what's internalized and |
1213 | 1189 | // what's inlined across modules, I believe. |
1214 | | -#if LLVM_VERSION_GE(18, 0) |
1215 | 1190 | #if LLVM_VERSION_GE(20, 0) |
1216 | 1191 | FunctionImporter::ImportListsTy ImportLists; |
1217 | 1192 | #else |
1218 | 1193 | DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists; |
1219 | 1194 | #endif |
1220 | 1195 | DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists; |
1221 | 1196 | DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries; |
1222 | | -#else |
1223 | | - StringMap<FunctionImporter::ImportMapTy> ImportLists; |
1224 | | - StringMap<FunctionImporter::ExportSetTy> ExportLists; |
1225 | | - StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries; |
1226 | | -#endif |
1227 | 1197 | StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR; |
1228 | 1198 |
|
1229 | 1199 | LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {} |
@@ -1275,11 +1245,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules, |
1275 | 1245 |
|
1276 | 1246 | Ret->ModuleMap[module->identifier] = mem_buffer; |
1277 | 1247 |
|
1278 | | -#if LLVM_VERSION_GE(18, 0) |
1279 | 1248 | if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index)) { |
1280 | | -#else |
1281 | | - if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) { |
1282 | | -#endif |
1283 | 1249 | LLVMRustSetLastError(toString(std::move(Err)).c_str()); |
1284 | 1250 | return nullptr; |
1285 | 1251 | } |
|
0 commit comments