From 854432d7e55a169a46d319cf0edffab790709582 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Fri, 31 Oct 2014 18:38:23 +0000 Subject: [PATCH] [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 --- lib/Transforms/Instrumentation/AddressSanitizer.cpp | 4 +++- test/Instrumentation/AddressSanitizer/coverage.ll | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index de7b83d0294..e93c011913f 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1408,12 +1408,14 @@ void AddressSanitizer::InjectCoverageForIndirectCalls( for (auto I : IndirCalls) { IRBuilder<> IRB(I); CallSite CS(I); + Value *Callee = CS.getCalledValue(); + if (dyn_cast(Callee)) continue; 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(Callee, IntptrTy), IRB.CreatePointerCast(CalleeCache, IntptrTy)); } } diff --git a/test/Instrumentation/AddressSanitizer/coverage.ll b/test/Instrumentation/AddressSanitizer/coverage.ll index 707371ad33f..d3de7d22d59 100644 --- a/test/Instrumentation/AddressSanitizer/coverage.ll +++ b/test/Instrumentation/AddressSanitizer/coverage.ll @@ -79,6 +79,7 @@ entry: %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 asm sideeffect "", ""() ret void } -- 2.34.1