[llvm] r220973 - [asan] fix caller-calee instrumentation to emit new cache for every call site
Kostya Serebryany
kcc at google.com
Fri Oct 31 10:11:27 PDT 2014
Author: kcc
Date: Fri Oct 31 12:11:27 2014
New Revision: 220973
URL: http://llvm.org/viewvc/llvm-project?rev=220973&view=rev
Log:
[asan] fix caller-calee instrumentation to emit new cache for every call site
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=220973&r1=220972&r2=220973&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Fri Oct 31 12:11:27 2014
@@ -1405,13 +1405,13 @@ void AddressSanitizer::InjectCoverageFor
const int kCacheSize = 16;
const int kCacheAlignment = 64; // Align for better performance.
Type *Ty = ArrayType::get(IntptrTy, kCacheSize);
- GlobalVariable *CalleeCache =
- new GlobalVariable(*F.getParent(), Ty, false, GlobalValue::PrivateLinkage,
- Constant::getNullValue(Ty), "__asan_gen_callee_cache");
- CalleeCache->setAlignment(kCacheAlignment);
for (auto I : IndirCalls) {
IRBuilder<> IRB(I);
CallSite CS(I);
+ GlobalVariable *CalleeCache = new GlobalVariable(
+ *F.getParent(), Ty, false, GlobalValue::PrivateLinkage,
+ Constant::getNullValue(Ty), "__asan_gen_callee_cache");
+ CalleeCache->setAlignment(kCacheAlignment);
IRB.CreateCall2(AsanCovIndirCallFunction,
IRB.CreatePointerCast(CS.getCalledValue(), IntptrTy),
IRB.CreatePointerCast(CalleeCache, IntptrTy));
Modified: llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll?rev=220973&r1=220972&r2=220973&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll (original)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/coverage.ll Fri Oct 31 12:11:27 2014
@@ -78,9 +78,13 @@ entry:
%vtable = load void (%struct.StructWithVptr*)*** %0, align 8
%1 = load void (%struct.StructWithVptr*)** %vtable, align 8
tail call void %1(%struct.StructWithVptr* %foo)
+ tail call void %1(%struct.StructWithVptr* %foo)
ret void
}
+; We expect to see two calls to __sanitizer_cov_indir_call16
+; with different values of second argument.
; CHECK4-LABEL: define void @CallViaVptr
-; CHECK4: call void @__sanitizer_cov_indir_call16
+; CHECK4: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE:.*]])
+; CHECK4-NOT: call void @__sanitizer_cov_indir_call16({{.*}},[[CACHE]])
; CHECK4: ret void
More information about the llvm-commits
mailing list