<div dir="ltr">You should probably note somewhere that assume is, in fact, readnone, we just don't model it that way right now because it hasn't been changed to use a real control dependency instead of a fake memory one.<div><br><div><div><div>:)</div><div><br></div><div><br></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 24, 2016 at 10:17 PM, Peter Collingbourne <span dir="ltr"><<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">pcc created this revision.<br>
pcc added reviewers: dberlin, chandlerc, hfinkel, reames, sanjoy.<br>
pcc added subscribers: llvm-commits, krasin.<br>
<br>
Intrinsic functions do not participate in the call graph, so there is no<br>
need to create call graph nodes for them.<br>
<br>
This has the effect of inhibiting SCC-based function attribute inference for<br>
intrinsic functions, which was previously incorrectly setting the readnone<br>
attribute on the llvm.assume intrinsic as a result of propagating the AA<br>
result introduced in D19730 to its attributes.<br>
<br>
<a href="http://reviews.llvm.org/D20612" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20612</a><br>
<br>
Files:<br>
lib/Analysis/CallGraph.cpp<br>
lib/Transforms/IPO/PruneEH.cpp<br>
test/Transforms/FunctionAttrs/assume.ll<br>
<br>
Index: test/Transforms/FunctionAttrs/assume.ll<br>
===================================================================<br>
--- /dev/null<br>
+++ test/Transforms/FunctionAttrs/assume.ll<br>
@@ -0,0 +1,4 @@<br>
+; RUN: opt -S -o - -functionattrs %s | FileCheck %s<br>
+<br>
+; CHECK-NOT: readnone<br>
+declare void @llvm.assume(i1)<br>
Index: lib/Transforms/IPO/PruneEH.cpp<br>
===================================================================<br>
--- lib/Transforms/IPO/PruneEH.cpp<br>
+++ lib/Transforms/IPO/PruneEH.cpp<br>
@@ -134,11 +134,14 @@<br>
bool InstMightUnwind = true;<br>
if (const auto *CI = dyn_cast<CallInst>(&I)) {<br>
if (Function *Callee = CI->getCalledFunction()) {<br>
- CallGraphNode *CalleeNode = CG[Callee];<br>
- // If the callee is outside our current SCC then we may throw<br>
- // because it might. If it is inside, do nothing.<br>
- if (SCCNodes.count(CalleeNode) > 0)<br>
- InstMightUnwind = false;<br>
+ // The call graph does not contain intrinsics.<br>
+ if (!Callee->isIntrinsic()) {<br>
+ CallGraphNode *CalleeNode = CG[Callee];<br>
+ // If the callee is outside our current SCC then we may throw<br>
+ // because it might. If it is inside, do nothing.<br>
+ if (SCCNodes.count(CalleeNode) > 0)<br>
+ InstMightUnwind = false;<br>
+ }<br>
}<br>
}<br>
SCCMightUnwind |= InstMightUnwind;<br>
Index: lib/Analysis/CallGraph.cpp<br>
===================================================================<br>
--- lib/Analysis/CallGraph.cpp<br>
+++ lib/Analysis/CallGraph.cpp<br>
@@ -55,6 +55,9 @@<br>
}<br>
<br>
void CallGraph::addToCallGraph(Function *F) {<br>
+ if (F->isIntrinsic())<br>
+ return;<br>
+<br>
CallGraphNode *Node = getOrInsertFunction(F);<br>
<br>
// If this function has external linkage, anything could call it.<br>
@@ -76,7 +79,7 @@<br>
<br>
// If this function is not defined in this translation unit, it could call<br>
// anything.<br>
- if (F->isDeclaration() && !F->isIntrinsic())<br>
+ if (F->isDeclaration())<br>
Node->addCalledFunction(CallSite(), CallsExternalNode.get());<br>
<br>
// Look for calls by this function.<br>
<br>
<br>
</blockquote></div><br></div>