|
18 | 18 | #include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
19 | 19 | #include "llvm/Transforms/IPO/AlwaysInliner.h"
|
20 | 20 | #include "llvm/Transforms/IPO/FunctionImport.h"
|
21 |
| -#include "llvm/Transforms/Instrumentation/AddressSanitizer.h" |
22 |
| -#include "llvm/Transforms/Instrumentation/MemorySanitizer.h" |
23 |
| -#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" |
24 | 21 | #include "llvm/Transforms/Utils/FunctionImportUtils.h"
|
25 | 22 | #include "llvm/LTO/LTO.h"
|
26 |
| - |
27 | 23 | #include "llvm-c/Transforms/PassManagerBuilder.h"
|
28 | 24 |
|
| 25 | +#include "llvm/Transforms/Instrumentation.h" |
| 26 | +#if LLVM_VERSION_GE(9, 0) |
| 27 | +#include "llvm/Transforms/Instrumentation/AddressSanitizer.h" |
| 28 | +#endif |
| 29 | +#if LLVM_VERSION_GE(8, 0) |
| 30 | +#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h" |
| 31 | +#include "llvm/Transforms/Instrumentation/MemorySanitizer.h" |
| 32 | +#endif |
| 33 | + |
29 | 34 | using namespace llvm;
|
30 | 35 | using namespace llvm::legacy;
|
31 | 36 |
|
@@ -88,18 +93,30 @@ extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover)
|
88 | 93 | extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
|
89 | 94 | const bool CompileKernel = false;
|
90 | 95 |
|
| 96 | +#if LLVM_VERSION_GE(9, 0) |
91 | 97 | return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
|
| 98 | +#else |
| 99 | + return wrap(createAddressSanitizerModulePass(CompileKernel, Recover)); |
| 100 | +#endif |
92 | 101 | }
|
93 | 102 |
|
94 | 103 | extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
|
| 104 | +#if LLVM_VERSION_GE(8, 0) |
95 | 105 | const bool CompileKernel = false;
|
96 | 106 |
|
97 | 107 | return wrap(createMemorySanitizerLegacyPassPass(
|
98 | 108 | MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
|
| 109 | +#else |
| 110 | + return wrap(createMemorySanitizerPass(TrackOrigins, Recover)); |
| 111 | +#endif |
99 | 112 | }
|
100 | 113 |
|
101 | 114 | extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
|
| 115 | +#if LLVM_VERSION_GE(8, 0) |
102 | 116 | return wrap(createThreadSanitizerLegacyPassPass());
|
| 117 | +#else |
| 118 | + return wrap(createThreadSanitizerPass()); |
| 119 | +#endif |
103 | 120 | }
|
104 | 121 |
|
105 | 122 | extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
|
|
0 commit comments