llvm.org GIT mirror llvm / 3ed1bc5
Merging r295230: ------------------------------------------------------------------------ r295230 | arnolds | 2017-02-15 12:43:43 -0800 (Wed, 15 Feb 2017) | 11 lines 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!" ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@295377 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 3 years ago
2 changed file(s) with 38 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
10121012 (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) &&
10131013 // inalloca allocas are not treated as static, and we don't want
10141014 // dynamic alloca instrumentation for them as well.
1015 !AI.isUsedWithInAlloca());
1015 !AI.isUsedWithInAlloca() &&
1016 // swifterror allocas are register promoted by ISel
1017 !AI.isSwiftError());
10161018
10171019 ProcessedAllocas[&AI] = IsInteresting;
10181020 return IsInteresting;
10871089 }
10881090 }
10891091
1090 // Do not instrument acesses from different address spaces; we cannot deal
1091 // with them.
10921092 if (PtrOperand) {
1093 // Do not instrument acesses from different address spaces; we cannot deal
1094 // with them.
10931095 Type *PtrTy = cast(PtrOperand->getType()->getScalarType());
10941096 if (PtrTy->getPointerAddressSpace() != 0)
1097 return nullptr;
1098
1099 // Ignore swifterror addresses.
1100 // swifterror memory addresses are mem2reg promoted by instruction
1101 // selection. As such they cannot have regular uses like an instrumentation
1102 // function and it makes no sense to track them as memory.
1103 if (PtrOperand->isSwiftError())
10951104 return nullptr;
10961105 }
10971106
169169 ; CHECK: __asan_memcpy
170170 ; CHECK: ret void
171171
172 ; CHECK-LABEL: @test_swifterror
173 ; CHECK-NOT: __asan_report_load
174 ; CHECK: ret void
175 define void @test_swifterror(i8** swifterror) sanitize_address {
176 %swifterror_ptr_value = load i8*, i8** %0
177 ret void
178 }
179
180 ; CHECK-LABEL: @test_swifterror_2
181 ; CHECK-NOT: __asan_report_store
182 ; CHECK: ret void
183 define void @test_swifterror_2(i8** swifterror) sanitize_address {
184 store i8* null, i8** %0
185 ret void
186 }
187
188 ; CHECK-LABEL: @test_swifterror_3
189 ; CHECK-NOT: __asan_report_store
190 ; CHECK: ret void
191 define void @test_swifterror_3() sanitize_address {
192 %swifterror_addr = alloca swifterror i8*
193 store i8* null, i8** %swifterror_addr
194 call void @test_swifterror_2(i8** swifterror %swifterror_addr)
195 ret void
196 }
197
172198 ; CHECK: define internal void @asan.module_ctor()
173199 ; CHECK: call void @__asan_init()
174200