[PATCH] D20612: Analysis: Do not create call graph nodes for intrinsic functions.
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Tue May 24 22:23:54 PDT 2016
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.
:)
On Tue, May 24, 2016 at 10:17 PM, Peter Collingbourne <peter at pcc.me.uk>
wrote:
> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160524/9190397d/attachment.html>
More information about the llvm-commits
mailing list