Skip to content

Commit 8473c58

Browse files
committed
fix crash
1 parent 3c60ce4 commit 8473c58

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ struct AddressSanitizer {
839839
ArrayRef<Instruction *> RetVec);
840840
bool instrumentSyclDynamicLocalMemory(Function &F,
841841
ArrayRef<Instruction *> RetVec);
842-
void instrumentInitAsanLaunchInfo(Function &F);
842+
void instrumentInitAsanLaunchInfo(Function &F, const TargetLibraryInfo *TLI);
843843

844844
void AppendDebugInfoToArgs(Instruction *InsertBefore, Value *Addr,
845845
SmallVectorImpl<Value *> &Args);
@@ -1536,9 +1536,8 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M,
15361536
Options.UseAfterScope, Options.UseAfterReturn);
15371537
const TargetLibraryInfo &TLI = FAM.getResult<TargetLibraryAnalysis>(F);
15381538
Modified |= FunctionSanitizer.instrumentFunction(F, &TLI);
1539-
if (Triple(M.getTargetTriple()).isSPIROrSPIRV() &&
1540-
F.getCallingConv() == CallingConv::SPIR_KERNEL) {
1541-
FunctionSanitizer.instrumentInitAsanLaunchInfo(F);
1539+
if (F.getCallingConv() == CallingConv::SPIR_KERNEL) {
1540+
FunctionSanitizer.instrumentInitAsanLaunchInfo(F, &TLI);
15421541
Modified = true;
15431542
}
15441543
}
@@ -1809,7 +1808,8 @@ bool AddressSanitizer::instrumentSyclDynamicLocalMemory(
18091808

18101809
// Initialize the value of local memory "__AsanLaunchInfo", store
18111810
// "__asan_launch" if it's an extended kernel, and store 0 if not
1812-
void AddressSanitizer::instrumentInitAsanLaunchInfo(Function &F) {
1811+
void AddressSanitizer::instrumentInitAsanLaunchInfo(
1812+
Function &F, const TargetLibraryInfo *TLI) {
18131813
InstrumentationIRBuilder IRB(F.getEntryBlock().getFirstNonPHI());
18141814
if (F.arg_size()) {
18151815
auto *LastArg = F.getArg(F.arg_size() - 1);
@@ -1818,6 +1818,7 @@ void AddressSanitizer::instrumentInitAsanLaunchInfo(Function &F) {
18181818
return;
18191819
}
18201820
}
1821+
initializeCallbacks(TLI);
18211822
IRB.CreateStore(
18221823
ConstantPointerNull::get(IntptrTy->getPointerTo(kSpirOffloadGlobalAS)),
18231824
AsanLaunchInfo);

0 commit comments

Comments
 (0)