[PATCH] D20612: Analysis: Do not create call graph nodes for intrinsic functions.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 22:17:14 PDT 2016
pcc created this revision.
pcc added reviewers: dberlin, chandlerc, hfinkel, reames, sanjoy.
pcc added subscribers: llvm-commits, krasin.
Intrinsic functions do not participate in the call graph, so there is no
need to create call graph nodes for them.
This has the effect of inhibiting SCC-based function attribute inference for
intrinsic functions, which was previously incorrectly setting the readnone
attribute on the llvm.assume intrinsic as a result of propagating the AA
result introduced in D19730 to its attributes.
http://reviews.llvm.org/D20612
Files:
lib/Analysis/CallGraph.cpp
lib/Transforms/IPO/PruneEH.cpp
test/Transforms/FunctionAttrs/assume.ll
Index: test/Transforms/FunctionAttrs/assume.ll
===================================================================
--- /dev/null
+++ test/Transforms/FunctionAttrs/assume.ll
@@ -0,0 +1,4 @@
+; RUN: opt -S -o - -functionattrs %s | FileCheck %s
+
+; CHECK-NOT: readnone
+declare void @llvm.assume(i1)
Index: lib/Transforms/IPO/PruneEH.cpp
===================================================================
--- lib/Transforms/IPO/PruneEH.cpp
+++ lib/Transforms/IPO/PruneEH.cpp
@@ -134,11 +134,14 @@
bool InstMightUnwind = true;
if (const auto *CI = dyn_cast<CallInst>(&I)) {
if (Function *Callee = CI->getCalledFunction()) {
- CallGraphNode *CalleeNode = CG[Callee];
- // If the callee is outside our current SCC then we may throw
- // because it might. If it is inside, do nothing.
- if (SCCNodes.count(CalleeNode) > 0)
- InstMightUnwind = false;
+ // The call graph does not contain intrinsics.
+ if (!Callee->isIntrinsic()) {
+ CallGraphNode *CalleeNode = CG[Callee];
+ // If the callee is outside our current SCC then we may throw
+ // because it might. If it is inside, do nothing.
+ if (SCCNodes.count(CalleeNode) > 0)
+ InstMightUnwind = false;
+ }
}
}
SCCMightUnwind |= InstMightUnwind;
Index: lib/Analysis/CallGraph.cpp
===================================================================
--- lib/Analysis/CallGraph.cpp
+++ lib/Analysis/CallGraph.cpp
@@ -55,6 +55,9 @@
}
void CallGraph::addToCallGraph(Function *F) {
+ if (F->isIntrinsic())
+ return;
+
CallGraphNode *Node = getOrInsertFunction(F);
// If this function has external linkage, anything could call it.
@@ -76,7 +79,7 @@
// If this function is not defined in this translation unit, it could call
// anything.
- if (F->isDeclaration() && !F->isIntrinsic())
+ if (F->isDeclaration())
Node->addCalledFunction(CallSite(), CallsExternalNode.get());
// Look for calls by this function.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20612.58384.patch
Type: text/x-patch
Size: 2176 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160525/633bbad2/attachment.bin>
More information about the llvm-commits
mailing list