14
14
#include " llvm/IR/AssemblyAnnotationWriter.h"
15
15
#include " llvm/IR/IntrinsicInst.h"
16
16
#include " llvm/IR/Verifier.h"
17
+ #include " llvm/MC/TargetRegistry.h"
17
18
#include " llvm/Object/ObjectFile.h"
18
19
#include " llvm/Object/IRObjectFile.h"
19
20
#include " llvm/Passes/PassBuilder.h"
25
26
#include " llvm/Support/VirtualFileSystem.h"
26
27
#endif
27
28
#include " llvm/Support/Host.h"
28
- #if LLVM_VERSION_LT(14, 0)
29
- #include " llvm/Support/TargetRegistry.h"
30
- #else
31
- #include " llvm/MC/TargetRegistry.h"
32
- #endif
33
29
#include " llvm/Target/TargetMachine.h"
34
30
#include " llvm/Transforms/IPO/PassManagerBuilder.h"
35
31
#include " llvm/Transforms/IPO/AlwaysInliner.h"
@@ -267,10 +263,6 @@ enum class LLVMRustPassBuilderOptLevel {
267
263
Oz,
268
264
};
269
265
270
- #if LLVM_VERSION_LT(14,0)
271
- using OptimizationLevel = PassBuilder::OptimizationLevel;
272
- #endif
273
-
274
266
static OptimizationLevel fromRust (LLVMRustPassBuilderOptLevel Level) {
275
267
switch (Level) {
276
268
case LLVMRustPassBuilderOptLevel::O0:
@@ -747,27 +739,18 @@ LLVMRustOptimize(
747
739
748
740
if (SanitizerOptions) {
749
741
if (SanitizerOptions->SanitizeMemory ) {
750
- #if LLVM_VERSION_GE(14, 0)
751
742
MemorySanitizerOptions Options (
752
743
SanitizerOptions->SanitizeMemoryTrackOrigins ,
753
744
SanitizerOptions->SanitizeMemoryRecover ,
754
745
/* CompileKernel=*/ false ,
755
746
/* EagerChecks=*/ true );
756
- #else
757
- MemorySanitizerOptions Options (
758
- SanitizerOptions->SanitizeMemoryTrackOrigins ,
759
- SanitizerOptions->SanitizeMemoryRecover ,
760
- /* CompileKernel=*/ false );
761
- #endif
762
747
OptimizerLastEPCallbacks.push_back (
763
748
[Options](ModulePassManager &MPM, OptimizationLevel Level) {
764
- #if LLVM_VERSION_GE(14, 0) && LLVM_VERSION_LT(16, 0)
749
+ #if LLVM_VERSION_LT(16, 0)
765
750
MPM.addPass (ModuleMemorySanitizerPass (Options));
751
+ MPM.addPass (createModuleToFunctionPassAdaptor (MemorySanitizerPass (Options)));
766
752
#else
767
753
MPM.addPass (MemorySanitizerPass (Options));
768
- #endif
769
- #if LLVM_VERSION_LT(16, 0)
770
- MPM.addPass (createModuleToFunctionPassAdaptor (MemorySanitizerPass (Options)));
771
754
#endif
772
755
}
773
756
);
@@ -776,11 +759,7 @@ LLVMRustOptimize(
776
759
if (SanitizerOptions->SanitizeThread ) {
777
760
OptimizerLastEPCallbacks.push_back (
778
761
[](ModulePassManager &MPM, OptimizationLevel Level) {
779
- #if LLVM_VERSION_GE(14, 0)
780
762
MPM.addPass (ModuleThreadSanitizerPass ());
781
- #else
782
- MPM.addPass (ThreadSanitizerPass ());
783
- #endif
784
763
MPM.addPass (createModuleToFunctionPassAdaptor (ThreadSanitizerPass ()));
785
764
}
786
765
);
@@ -792,7 +771,6 @@ LLVMRustOptimize(
792
771
#if LLVM_VERSION_LT(15, 0)
793
772
MPM.addPass (RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
794
773
#endif
795
- #if LLVM_VERSION_GE(14, 0)
796
774
AddressSanitizerOptions opts = AddressSanitizerOptions{
797
775
/* CompileKernel=*/ false ,
798
776
SanitizerOptions->SanitizeAddressRecover ,
@@ -803,29 +781,17 @@ LLVMRustOptimize(
803
781
MPM.addPass (ModuleAddressSanitizerPass (opts));
804
782
#else
805
783
MPM.addPass (AddressSanitizerPass (opts));
806
- #endif
807
- #else
808
- MPM.addPass (ModuleAddressSanitizerPass (
809
- /* CompileKernel=*/ false , SanitizerOptions->SanitizeAddressRecover ));
810
- MPM.addPass (createModuleToFunctionPassAdaptor (AddressSanitizerPass (
811
- /* CompileKernel=*/ false , SanitizerOptions->SanitizeAddressRecover ,
812
- /* UseAfterScope=*/ true )));
813
784
#endif
814
785
}
815
786
);
816
787
}
817
788
if (SanitizerOptions->SanitizeHWAddress ) {
818
789
OptimizerLastEPCallbacks.push_back (
819
790
[SanitizerOptions](ModulePassManager &MPM, OptimizationLevel Level) {
820
- #if LLVM_VERSION_GE(14, 0)
821
791
HWAddressSanitizerOptions opts (
822
792
/* CompileKernel=*/ false , SanitizerOptions->SanitizeHWAddressRecover ,
823
793
/* DisableOptimization=*/ false );
824
794
MPM.addPass (HWAddressSanitizerPass (opts));
825
- #else
826
- MPM.addPass (HWAddressSanitizerPass (
827
- /* CompileKernel=*/ false , SanitizerOptions->SanitizeHWAddressRecover ));
828
- #endif
829
795
}
830
796
);
831
797
}
@@ -1328,11 +1294,7 @@ extern "C" bool
1328
1294
LLVMRustPrepareThinLTOResolveWeak (const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1329
1295
Module &Mod = *unwrap (M);
1330
1296
const auto &DefinedGlobals = Data->ModuleToDefinedGVSummaries .lookup (Mod.getModuleIdentifier ());
1331
- #if LLVM_VERSION_GE(14, 0)
1332
1297
thinLTOFinalizeInModule (Mod, DefinedGlobals, /* PropagateAttrs=*/ true );
1333
- #else
1334
- thinLTOResolvePrevailingInModule (Mod, DefinedGlobals);
1335
- #endif
1336
1298
return true ;
1337
1299
}
1338
1300
0 commit comments