Skip to content

Commit e400106

Browse files
authored
Merge pull request #92 from PRUNERS/bugfix/llvm9fixes
build fixes for LLVM 9
2 parents dabb16f + b6933c7 commit e400106

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

lib/Transforms/Instrumentation/InstrumentParallel.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ INITIALIZE_PASS_END(
116116
false, false)
117117

118118
#if LLVM_VERSION > MIN_VERSION
119-
StringRef InstrumentParallel::getPassName() const {
120-
return PassName;
121-
}
119+
StringRef InstrumentParallel::getPassName() const {
120+
return PassName;
121+
}
122122
#else
123-
const char *InstrumentParallel::getPassName() const {
124-
return PassName.c_str();
125-
}
123+
const char *InstrumentParallel::getPassName() const {
124+
return PassName.c_str();
125+
}
126126
#endif
127127

128128
void InstrumentParallel::getAnalysisUsage(AnalysisUsage &AU) const {
@@ -174,7 +174,7 @@ bool InstrumentParallel::runOnFunction(Function &F) {
174174
// }
175175
Constant *suppression_str_const =
176176
ConstantDataArray::getString(M->getContext(),
177-
"called_from_lib:libomp.*\nthread:^__kmp_create_worker$\n", true);
177+
"called_from_lib:libomp.*\nthread:^__kmp_create_worker$\n", true);
178178
GlobalVariable* suppression_str =
179179
new GlobalVariable(*M,
180180
suppression_str_const->getType(),
@@ -185,8 +185,15 @@ bool InstrumentParallel::runOnFunction(Function &F) {
185185
suppression_str->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
186186
suppression_str->setAlignment(1);
187187
IRBuilder<> IRB(M->getContext());
188+
#if LLVM_VERSION >= 90
189+
Function* __tsan_default_suppressions = Function::Create(FunctionType::get(IRB.getInt8PtrTy(), false),
190+
Function::ExternalLinkage,
191+
"__tsan_default_suppressions",
192+
M);
193+
#else
188194
Function* __tsan_default_suppressions = cast<Function>(M->getOrInsertFunction("__tsan_default_suppressions",
189-
IRB.getInt8PtrTy()));
195+
IRB.getInt8PtrTy()));
196+
#endif
190197
__tsan_default_suppressions->setCallingConv(CallingConv::C);
191198
__tsan_default_suppressions->addFnAttr(Attribute::NoInline);
192199
__tsan_default_suppressions->addFnAttr(Attribute::NoUnwind);
@@ -201,9 +208,15 @@ bool InstrumentParallel::runOnFunction(Function &F) {
201208

202209
#if LLVM_VERSION >= 40
203210
IRBuilder<> IRB2(M->getContext());
211+
#if LLVM_VERSION >= 90
212+
FunctionCallee constant = M->getOrInsertFunction("__archer_get_omp_status",
213+
IRB2.getInt32Ty());
214+
Function* __archer_get_omp_status = dyn_cast<Function>(constant.getCallee());
215+
#else
204216
Constant* constant = M->getOrInsertFunction("__archer_get_omp_status",
205-
IRB2.getInt32Ty());
217+
IRB2.getInt32Ty());
206218
Function* __archer_get_omp_status = cast<Function>(constant);
219+
#endif
207220
__archer_get_omp_status->setCallingConv(CallingConv::C);
208221
BasicBlock* block2 = BasicBlock::Create(M->getContext(), "entry", __archer_get_omp_status);
209222
IRBuilder<> builder2(block2);

0 commit comments

Comments
 (0)