[asan] do not treat inline asm calls as indirect calls

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220985 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kostya Serebryany 2014-10-31 18:38:23 +00:00
parent 9b6ca9304c
commit 854432d7e5
2 changed files with 4 additions and 1 deletions

View File

@ -1408,12 +1408,14 @@ void AddressSanitizer::InjectCoverageForIndirectCalls(
for (auto I : IndirCalls) { for (auto I : IndirCalls) {
IRBuilder<> IRB(I); IRBuilder<> IRB(I);
CallSite CS(I); CallSite CS(I);
Value *Callee = CS.getCalledValue();
if (dyn_cast<InlineAsm>(Callee)) continue;
GlobalVariable *CalleeCache = new GlobalVariable( GlobalVariable *CalleeCache = new GlobalVariable(
*F.getParent(), Ty, false, GlobalValue::PrivateLinkage, *F.getParent(), Ty, false, GlobalValue::PrivateLinkage,
Constant::getNullValue(Ty), "__asan_gen_callee_cache"); Constant::getNullValue(Ty), "__asan_gen_callee_cache");
CalleeCache->setAlignment(kCacheAlignment); CalleeCache->setAlignment(kCacheAlignment);
IRB.CreateCall2(AsanCovIndirCallFunction, IRB.CreateCall2(AsanCovIndirCallFunction,
IRB.CreatePointerCast(CS.getCalledValue(), IntptrTy), IRB.CreatePointerCast(Callee, IntptrTy),
IRB.CreatePointerCast(CalleeCache, IntptrTy)); IRB.CreatePointerCast(CalleeCache, IntptrTy));
} }
} }

View File

@ -79,6 +79,7 @@ entry:
%1 = load void (%struct.StructWithVptr*)** %vtable, align 8 %1 = load void (%struct.StructWithVptr*)** %vtable, align 8
tail call void %1(%struct.StructWithVptr* %foo) tail call void %1(%struct.StructWithVptr* %foo)
tail call void %1(%struct.StructWithVptr* %foo) tail call void %1(%struct.StructWithVptr* %foo)
tail call void asm sideeffect "", ""()
ret void ret void
} }