[asan] do not treat inline asm calls as indirect calls
authorKostya Serebryany <kcc@google.com>
Fri, 31 Oct 2014 18:38:23 +0000 (18:38 +0000)
committerKostya Serebryany <kcc@google.com>
Fri, 31 Oct 2014 18:38:23 +0000 (18:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220985 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/AddressSanitizer.cpp
test/Instrumentation/AddressSanitizer/coverage.ll

index de7b83d02940c91c6dd84797ee4d878ac6011949..e93c011913f88fceff61d12bcedec2f57ab5d8b6 100644 (file)
@@ -1408,12 +1408,14 @@ void AddressSanitizer::InjectCoverageForIndirectCalls(
   for (auto I : IndirCalls) {
     IRBuilder<> IRB(I);
     CallSite CS(I);
   for (auto I : IndirCalls) {
     IRBuilder<> IRB(I);
     CallSite CS(I);
+    Value *Callee = CS.getCalledValue();
+    if (dyn_cast<InlineAsm>(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,
     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));
   }
 }
                     IRB.CreatePointerCast(CalleeCache, IntptrTy));
   }
 }
index 707371ad33f3ebbffd5ae7dedd2626820c771549..d3de7d22d59bf758f2d7b1aa22a963412bab5a82 100644 (file)
@@ -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)
   %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
 }
 
   ret void
 }