@@ -107,6 +107,7 @@ static LLVMRustPassKind toRust(PassKind Kind) {
107
107
}
108
108
109
109
extern " C" LLVMPassRef LLVMRustFindAndCreatePass (const char *PassName) {
110
+ #if LLVM_VERSION_LT(15, 0)
110
111
StringRef SR (PassName);
111
112
PassRegistry *PR = PassRegistry::getPassRegistry ();
112
113
@@ -115,36 +116,59 @@ extern "C" LLVMPassRef LLVMRustFindAndCreatePass(const char *PassName) {
115
116
return wrap (PI->createPass ());
116
117
}
117
118
return nullptr ;
119
+ #else
120
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
121
+ #endif
118
122
}
119
123
120
124
extern " C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass (bool Recover) {
125
+ #if LLVM_VERSION_LT(15, 0)
121
126
const bool CompileKernel = false ;
122
127
const bool UseAfterScope = true ;
123
128
124
129
return wrap (createAddressSanitizerFunctionPass (CompileKernel, Recover, UseAfterScope));
130
+ #else
131
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
132
+ #endif
125
133
}
126
134
127
135
extern " C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass (bool Recover) {
136
+ #if LLVM_VERSION_LT(15, 0)
128
137
const bool CompileKernel = false ;
129
138
130
139
return wrap (createModuleAddressSanitizerLegacyPassPass (CompileKernel, Recover));
140
+ #else
141
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
142
+ #endif
131
143
}
132
144
133
145
extern " C" LLVMPassRef LLVMRustCreateMemorySanitizerPass (int TrackOrigins, bool Recover) {
146
+ #if LLVM_VERSION_LT(15, 0)
134
147
const bool CompileKernel = false ;
135
148
136
149
return wrap (createMemorySanitizerLegacyPassPass (
137
150
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
151
+ #else
152
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
153
+ #endif
138
154
}
139
155
140
156
extern " C" LLVMPassRef LLVMRustCreateThreadSanitizerPass () {
157
+ #if LLVM_VERSION_LT(15, 0)
141
158
return wrap (createThreadSanitizerLegacyPassPass ());
159
+ #else
160
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
161
+ #endif
142
162
}
143
163
144
164
extern " C" LLVMPassRef LLVMRustCreateHWAddressSanitizerPass (bool Recover) {
165
+ #if LLVM_VERSION_LT(15, 0)
145
166
const bool CompileKernel = false ;
146
167
147
168
return wrap (createHWAddressSanitizerLegacyPassPass (CompileKernel, Recover));
169
+ #else
170
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
171
+ #endif
148
172
}
149
173
150
174
extern " C" LLVMRustPassKind LLVMRustPassKind (LLVMPassRef RustPass) {
@@ -154,23 +178,40 @@ extern "C" LLVMRustPassKind LLVMRustPassKind(LLVMPassRef RustPass) {
154
178
}
155
179
156
180
extern " C" void LLVMRustAddPass (LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
181
+ #if LLVM_VERSION_LT(15, 0)
157
182
assert (RustPass);
158
183
Pass *Pass = unwrap (RustPass);
159
184
PassManagerBase *PMB = unwrap (PMR);
160
185
PMB->add (Pass);
186
+ #else
187
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
188
+ #endif
189
+ }
190
+ extern " C" void LLVMRustPassManagerBuilderPopulateLTOPassManager (
191
+ LLVMPassManagerBuilderRef PMB, LLVMPassManagerRef PM, bool Internalize, bool RunInliner) {
192
+ #if LLVM_VERSION_LT(15, 0)
193
+ LLVMPassManagerBuilderPopulateLTOPassManager (PMB, PM, Internalize, RunInliner);
194
+ #else
195
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
196
+ #endif
161
197
}
162
198
163
199
extern " C"
164
200
void LLVMRustPassManagerBuilderPopulateThinLTOPassManager (
165
201
LLVMPassManagerBuilderRef PMBR,
166
202
LLVMPassManagerRef PMR
167
203
) {
204
+ #if LLVM_VERSION_LT(15, 0)
168
205
unwrap (PMBR)->populateThinLTOPassManager (*unwrap (PMR));
206
+ #else
207
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
208
+ #endif
169
209
}
170
210
171
211
extern " C"
172
212
void LLVMRustAddLastExtensionPasses (
173
213
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
214
+ #if LLVM_VERSION_LT(15, 0)
174
215
auto AddExtensionPasses = [Passes, NumPasses](
175
216
const PassManagerBuilder &Builder, PassManagerBase &PM) {
176
217
for (size_t I = 0 ; I < NumPasses; I++) {
@@ -183,6 +224,9 @@ void LLVMRustAddLastExtensionPasses(
183
224
AddExtensionPasses);
184
225
unwrap (PMBR)->addExtension (PassManagerBuilder::EP_EnabledOnOptLevel0,
185
226
AddExtensionPasses);
227
+ #else
228
+ report_fatal_error (" Legacy PM not supported with LLVM 15" );
229
+ #endif
186
230
}
187
231
188
232
#ifdef LLVM_COMPONENT_X86
0 commit comments