@@ -54,10 +54,6 @@ typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;
54
54
55
55
DEFINE_STDCXX_CONVERSION_FUNCTIONS (Pass, LLVMPassRef)
56
56
DEFINE_STDCXX_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
57
- #if LLVM_VERSION_LT(11, 0)
58
- DEFINE_STDCXX_CONVERSION_FUNCTIONS (PassManagerBuilder,
59
- LLVMPassManagerBuilderRef)
60
- #endif
61
57
62
58
extern "C" void LLVMInitializePasses() {
63
59
PassRegistry &Registry = *PassRegistry::getPassRegistry ();
@@ -857,13 +853,8 @@ LLVMRustOptimizeWithNewPassManager(
857
853
// PassBuilder does not create a pipeline.
858
854
std::vector<std::function<void (ModulePassManager &, OptimizationLevel)>>
859
855
PipelineStartEPCallbacks;
860
- #if LLVM_VERSION_GE(11, 0)
861
856
std::vector<std::function<void (ModulePassManager &, OptimizationLevel)>>
862
857
OptimizerLastEPCallbacks;
863
- #else
864
- std::vector<std::function<void (FunctionPassManager &, OptimizationLevel)>>
865
- OptimizerLastEPCallbacks;
866
- #endif
867
858
868
859
if (VerifyIR) {
869
860
PipelineStartEPCallbacks.push_back (
@@ -896,7 +887,6 @@ LLVMRustOptimizeWithNewPassManager(
896
887
SanitizerOptions->SanitizeMemoryTrackOrigins ,
897
888
SanitizerOptions->SanitizeMemoryRecover ,
898
889
/* CompileKernel=*/ false );
899
- #if LLVM_VERSION_GE(11, 0)
900
890
OptimizerLastEPCallbacks.push_back (
901
891
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
902
892
#if LLVM_VERSION_GE(14, 0)
@@ -907,22 +897,9 @@ LLVMRustOptimizeWithNewPassManager(
907
897
MPM.addPass (createModuleToFunctionPassAdaptor (MemorySanitizerPass (Options)));
908
898
}
909
899
);
910
- #else
911
- PipelineStartEPCallbacks.push_back (
912
- [Options](ModulePassManager &MPM, OptimizationLevel Level) {
913
- MPM.addPass (MemorySanitizerPass (Options));
914
- }
915
- );
916
- OptimizerLastEPCallbacks.push_back (
917
- [Options](FunctionPassManager &FPM, OptimizationLevel Level) {
918
- FPM.addPass (MemorySanitizerPass (Options));
919
- }
920
- );
921
- #endif
922
900
}
923
901
924
902
if (SanitizerOptions->SanitizeThread ) {
925
- #if LLVM_VERSION_GE(11, 0)
926
903
OptimizerLastEPCallbacks.push_back (
927
904
[](ModulePassManager &MPM, OptimizationLevel Level) {
928
905
#if LLVM_VERSION_GE(14, 0)
@@ -933,22 +910,9 @@ LLVMRustOptimizeWithNewPassManager(
933
910
MPM.addPass (createModuleToFunctionPassAdaptor (ThreadSanitizerPass ()));
934
911
}
935
912
);
936
- #else
937
- PipelineStartEPCallbacks.push_back (
938
- [](ModulePassManager &MPM, OptimizationLevel Level) {
939
- MPM.addPass (ThreadSanitizerPass ());
940
- }
941
- );
942
- OptimizerLastEPCallbacks.push_back (
943
- [](FunctionPassManager &FPM, OptimizationLevel Level) {
944
- FPM.addPass (ThreadSanitizerPass ());
945
- }
946
- );
947
- #endif
948
913
}
949
914
950
915
if (SanitizerOptions->SanitizeAddress ) {
951
- #if LLVM_VERSION_GE(11, 0)
952
916
OptimizerLastEPCallbacks.push_back (
953
917
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
954
918
MPM.addPass (RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
@@ -967,29 +931,8 @@ LLVMRustOptimizeWithNewPassManager(
967
931
#endif
968
932
}
969
933
);
970
- #else
971
- PipelineStartEPCallbacks.push_back (
972
- [&](ModulePassManager &MPM, OptimizationLevel Level) {
973
- MPM.addPass (RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
974
- }
975
- );
976
- OptimizerLastEPCallbacks.push_back (
977
- [SanitizerOptions](FunctionPassManager &FPM, OptimizationLevel Level) {
978
- FPM.addPass (AddressSanitizerPass (
979
- /* CompileKernel=*/ false , SanitizerOptions->SanitizeAddressRecover ,
980
- /* UseAfterScope=*/ true ));
981
- }
982
- );
983
- PipelineStartEPCallbacks.push_back (
984
- [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
985
- MPM.addPass (ModuleAddressSanitizerPass (
986
- /* CompileKernel=*/ false , SanitizerOptions->SanitizeAddressRecover ));
987
- }
988
- );
989
- #endif
990
934
}
991
935
if (SanitizerOptions->SanitizeHWAddress ) {
992
- #if LLVM_VERSION_GE(11, 0)
993
936
OptimizerLastEPCallbacks.push_back (
994
937
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
995
938
#if LLVM_VERSION_GE(14, 0)
@@ -1003,14 +946,6 @@ LLVMRustOptimizeWithNewPassManager(
1003
946
#endif
1004
947
}
1005
948
);
1006
- #else
1007
- PipelineStartEPCallbacks.push_back (
1008
- [SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
1009
- MPM.addPass (HWAddressSanitizerPass (
1010
- /* CompileKernel=*/ false , SanitizerOptions->SanitizeHWAddressRecover ));
1011
- }
1012
- );
1013
- #endif
1014
949
}
1015
950
}
1016
951
@@ -1037,17 +972,8 @@ LLVMRustOptimizeWithNewPassManager(
1037
972
for (const auto &C : PipelineStartEPCallbacks)
1038
973
C (MPM, OptLevel);
1039
974
1040
- # if LLVM_VERSION_GE(11, 0)
1041
975
for (const auto &C : OptimizerLastEPCallbacks)
1042
976
C (MPM, OptLevel);
1043
- # else
1044
- if (!OptimizerLastEPCallbacks.empty ()) {
1045
- FunctionPassManager FPM (DebugPassManager);
1046
- for (const auto &C : OptimizerLastEPCallbacks)
1047
- C (FPM, OptLevel);
1048
- MPM.addPass (createModuleToFunctionPassAdaptor (std::move (FPM)));
1049
- }
1050
- # endif
1051
977
1052
978
MPM.addPass (AlwaysInlinerPass (EmitLifetimeMarkers));
1053
979
@@ -1088,17 +1014,8 @@ LLVMRustOptimizeWithNewPassManager(
1088
1014
#else
1089
1015
MPM = PB.buildThinLTOPreLinkDefaultPipeline (OptLevel, DebugPassManager);
1090
1016
#endif
1091
- #if LLVM_VERSION_GE(11, 0)
1092
1017
for (const auto &C : OptimizerLastEPCallbacks)
1093
1018
C (MPM, OptLevel);
1094
- #else
1095
- if (!OptimizerLastEPCallbacks.empty ()) {
1096
- FunctionPassManager FPM (DebugPassManager);
1097
- for (const auto &C : OptimizerLastEPCallbacks)
1098
- C (FPM, OptLevel);
1099
- MPM.addPass (createModuleToFunctionPassAdaptor (std::move (FPM)));
1100
- }
1101
- #endif
1102
1019
break ;
1103
1020
case LLVMRustOptStage::PreLinkFatLTO:
1104
1021
#if LLVM_VERSION_GE(12, 0)
@@ -1552,7 +1469,6 @@ LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
1552
1469
// `ProcessThinLTOModule` function. Here they're split up into separate steps
1553
1470
// so rustc can save off the intermediate bytecode between each step.
1554
1471
1555
- #if LLVM_VERSION_GE(11, 0)
1556
1472
static bool
1557
1473
clearDSOLocalOnDeclarations (Module &Mod, TargetMachine &TM) {
1558
1474
// When linking an ELF shared object, dso_local should be dropped. We
@@ -1563,20 +1479,15 @@ clearDSOLocalOnDeclarations(Module &Mod, TargetMachine &TM) {
1563
1479
Mod.getPIELevel () == PIELevel::Default;
1564
1480
return ClearDSOLocalOnDeclarations;
1565
1481
}
1566
- #endif
1567
1482
1568
1483
extern " C" bool
1569
1484
LLVMRustPrepareThinLTORename (const LLVMRustThinLTOData *Data, LLVMModuleRef M,
1570
1485
LLVMTargetMachineRef TM) {
1571
1486
Module &Mod = *unwrap (M);
1572
1487
TargetMachine &Target = *unwrap (TM);
1573
1488
1574
- #if LLVM_VERSION_GE(11, 0)
1575
1489
bool ClearDSOLocal = clearDSOLocalOnDeclarations (Mod, Target);
1576
1490
bool error = renameModuleForThinLTO (Mod, Data->Index , ClearDSOLocal);
1577
- #else
1578
- bool error = renameModuleForThinLTO (Mod, Data->Index );
1579
- #endif
1580
1491
1581
1492
if (error) {
1582
1493
LLVMRustSetLastError (" renameModuleForThinLTO failed" );
@@ -1645,12 +1556,8 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M,
1645
1556
1646
1557
return MOrErr;
1647
1558
};
1648
- #if LLVM_VERSION_GE(11, 0)
1649
1559
bool ClearDSOLocal = clearDSOLocalOnDeclarations (Mod, Target);
1650
1560
FunctionImporter Importer (Data->Index , Loader, ClearDSOLocal);
1651
- #else
1652
- FunctionImporter Importer (Data->Index , Loader);
1653
- #endif
1654
1561
Expected<bool > Result = Importer.importFunctions (Mod, ImportList);
1655
1562
if (!Result) {
1656
1563
LLVMRustSetLastError (toString (Result.takeError ()).c_str ());
0 commit comments