[asan] fix caller-calee instrumentation to emit new cache for every call site

llvm-svn: 220973
This commit is contained in:
Kostya Serebryany 2014-10-31 17:11:27 +00:00
parent e9f6a717dd
commit 001ea5fe15
2 changed files with 9 additions and 5 deletions

View File

@ -1405,13 +1405,13 @@ void AddressSanitizer::InjectCoverageForIndirectCalls(
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));

View File

@ -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