[llvm-commits] [llvm] r164707 - in /llvm/trunk: lib/Analysis/IPA/CallGraph.cpp test/Analysis/CallGraph/do-nothing-intrinsic.ll

Duncan Sands baldrick at free.fr
Wed Sep 26 10:16:01 PDT 2012


Author: baldrick
Date: Wed Sep 26 12:16:01 2012
New Revision: 164707

URL: http://llvm.org/viewvc/llvm-project?rev=164707&view=rev
Log:
Now that invoke of an intrinsic is possible (for the llvm.do.nothing intrinsic)
teach the callgraph logic to not create callgraph edges to intrinsics for invoke
instructions; it already skips this for call instructions.  Fixes PR13903.

Added:
    llvm/trunk/test/Analysis/CallGraph/do-nothing-intrinsic.ll
Modified:
    llvm/trunk/lib/Analysis/IPA/CallGraph.cpp

Modified: llvm/trunk/lib/Analysis/IPA/CallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraph.cpp?rev=164707&r1=164706&r2=164707&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/IPA/CallGraph.cpp (original)
+++ llvm/trunk/lib/Analysis/IPA/CallGraph.cpp Wed Sep 26 12:16:01 2012
@@ -141,12 +141,13 @@
       for (BasicBlock::iterator II = BB->begin(), IE = BB->end();
            II != IE; ++II) {
         CallSite CS(cast<Value>(II));
-        if (CS && !isa<IntrinsicInst>(II)) {
+        if (CS) {
           const Function *Callee = CS.getCalledFunction();
-          if (Callee)
-            Node->addCalledFunction(CS, getOrInsertFunction(Callee));
-          else
+          if (!Callee)
+            // Indirect calls of intrinsics are not allowed so no need to check.
             Node->addCalledFunction(CS, CallsExternalNode);
+          else if (!Callee->isIntrinsic())
+            Node->addCalledFunction(CS, getOrInsertFunction(Callee));
         }
       }
   }

Added: llvm/trunk/test/Analysis/CallGraph/do-nothing-intrinsic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CallGraph/do-nothing-intrinsic.ll?rev=164707&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CallGraph/do-nothing-intrinsic.ll (added)
+++ llvm/trunk/test/Analysis/CallGraph/do-nothing-intrinsic.ll Wed Sep 26 12:16:01 2012
@@ -0,0 +1,13 @@
+; RUN: opt < %s -basiccg
+; PR13903
+
+define void @main() {
+  invoke void @llvm.donothing()
+          to label %ret unwind label %unw
+unw:
+  %tmp = landingpad i8 personality i8 0 cleanup
+  br label %ret
+ret:
+  ret void
+}
+declare void @llvm.donothing() nounwind readnone





More information about the llvm-commits mailing list