forked from OSchip/llvm-project
AddressSanitizer: don't track swifterror memory addresses
They are register promoted by ISel and so it makes no sense to treat them as memory. Inserting calls to the thread sanitizer would also generate invalid IR. You would hit: "swifterror value can only be loaded and stored from, or as a swifterror argument!" llvm-svn: 295230
This commit is contained in:
parent
f8acf568f1
commit
8d61e0030a
|
@ -1013,7 +1013,9 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
|
|||
(!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&
|
||||
// inalloca allocas are not treated as static, and we don't want
|
||||
// dynamic alloca instrumentation for them as well.
|
||||
!AI.isUsedWithInAlloca());
|
||||
!AI.isUsedWithInAlloca() &&
|
||||
// swifterror allocas are register promoted by ISel
|
||||
!AI.isSwiftError());
|
||||
|
||||
ProcessedAllocas[&AI] = IsInteresting;
|
||||
return IsInteresting;
|
||||
|
@ -1088,12 +1090,19 @@ Value *AddressSanitizer::isInterestingMemoryAccess(Instruction *I,
|
|||
}
|
||||
}
|
||||
|
||||
// Do not instrument acesses from different address spaces; we cannot deal
|
||||
// with them.
|
||||
if (PtrOperand) {
|
||||
// Do not instrument acesses from different address spaces; we cannot deal
|
||||
// with them.
|
||||
Type *PtrTy = cast<PointerType>(PtrOperand->getType()->getScalarType());
|
||||
if (PtrTy->getPointerAddressSpace() != 0)
|
||||
return nullptr;
|
||||
|
||||
// Ignore swifterror addresses.
|
||||
// swifterror memory addresses are mem2reg promoted by instruction
|
||||
// selection. As such they cannot have regular uses like an instrumentation
|
||||
// function and it makes no sense to track them as memory.
|
||||
if (PtrOperand->isSwiftError())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Treat memory accesses to promotable allocas as non-interesting since they
|
||||
|
|
|
@ -170,6 +170,32 @@ define void @memintr_test(i8* %a, i8* %b) nounwind uwtable sanitize_address {
|
|||
; CHECK: __asan_memcpy
|
||||
; CHECK: ret void
|
||||
|
||||
; CHECK-LABEL: @test_swifterror
|
||||
; CHECK-NOT: __asan_report_load
|
||||
; CHECK: ret void
|
||||
define void @test_swifterror(i8** swifterror) sanitize_address {
|
||||
%swifterror_ptr_value = load i8*, i8** %0
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test_swifterror_2
|
||||
; CHECK-NOT: __asan_report_store
|
||||
; CHECK: ret void
|
||||
define void @test_swifterror_2(i8** swifterror) sanitize_address {
|
||||
store i8* null, i8** %0
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @test_swifterror_3
|
||||
; CHECK-NOT: __asan_report_store
|
||||
; CHECK: ret void
|
||||
define void @test_swifterror_3() sanitize_address {
|
||||
%swifterror_addr = alloca swifterror i8*
|
||||
store i8* null, i8** %swifterror_addr
|
||||
call void @test_swifterror_2(i8** swifterror %swifterror_addr)
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: define internal void @asan.module_ctor()
|
||||
; CHECK: call void @__asan_init()
|
||||
|
||||
|
|
Loading…
Reference in New Issue