Skip to content

Commit 67f0a69

Browse files
[ASan][AMDGPU] Fix Assertion Failure. (#79795)
Assertion failure `(i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Calling a function with a bad signature!"'. The 'llvm.memcpy' intercepted by ASan instrumentation pass is implemented by it's own __asan_memcpy implementation. The second argument of llvm.memcpy accepts ptr to addrspace(4), __asan_memcpy also has to follow ptr to addrspace(4) convention. --------- Co-authored-by: Amit Pandey <[email protected]>
1 parent d09082f commit 67f0a69

File tree

2 files changed

+800
-2
lines changed

2 files changed

+800
-2
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,12 +1255,13 @@ void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI) {
12551255
InstrumentationIRBuilder IRB(MI);
12561256
if (isa<MemTransferInst>(MI)) {
12571257
IRB.CreateCall(isa<MemMoveInst>(MI) ? AsanMemmove : AsanMemcpy,
1258-
{MI->getOperand(0), MI->getOperand(1),
1258+
{IRB.CreateAddrSpaceCast(MI->getOperand(0), PtrTy),
1259+
IRB.CreateAddrSpaceCast(MI->getOperand(1), PtrTy),
12591260
IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
12601261
} else if (isa<MemSetInst>(MI)) {
12611262
IRB.CreateCall(
12621263
AsanMemset,
1263-
{MI->getOperand(0),
1264+
{IRB.CreateAddrSpaceCast(MI->getOperand(0), PtrTy),
12641265
IRB.CreateIntCast(MI->getOperand(1), IRB.getInt32Ty(), false),
12651266
IRB.CreateIntCast(MI->getOperand(2), IntptrTy, false)});
12661267
}

0 commit comments

Comments
 (0)