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