[PATCH] Improve RefreshCallGraph to remove invalid call graph edge.
Lawrence Hu
lawrence at codeaurora.org
Tue Feb 17 15:12:52 PST 2015
Hi apazos, chandlerc,
This patch is to improve CGPassManager::RefreshCallGraph to remove an invalid call graph edge corrupted by Instruction Combiner, triggered an assert in CallGraphNode::addCalledFunction later.
With commit d8214db0868f228026fa6ab1d5ca6c76ab3b5ce0, llvm's Instruction Combiner now can turn an sqrtl into a llvm.fabs.f64, the call graph edge (to be more precise, one Entry in B's CalledFunctions list) originally representing call to sqrtl now becomes invalid: the instruction is the call instruction for llvm.fabs.f64 (done by Value:: replaceAllUsesWith(..)), and the call graph node is still sqrtl, note that intrinsic shouldn't be in call graph, and call graph node for sqrtl should be gone too.
The problem can only be reproduced if we meet the all following conditions:
1. Compile the program with NDK sysroot, and program need to be complicate enough to invoke CGPassManager::RunAllPassesOnSCC.
2. For program with function A and B, A calls B, B calls some other functions, B need to be compiled before A to reproduce the problem.
3. While compiling function B, inlining is invoked and instruction combiner is able to turn a call to sqrtl into llvm.fabs.f64
4. Inlining is invoked while compiling function A (a bigger inlining threshold is needed)
This problem can't be reproduced with llvm trunk, because it doesn't turn a sqrtl into llvm.fabs.f64, but I think it is a real problem.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7705
Files:
lib/Analysis/IPA/CallGraphSCCPass.cpp
Index: lib/Analysis/IPA/CallGraphSCCPass.cpp
===================================================================
--- lib/Analysis/IPA/CallGraphSCCPass.cpp
+++ lib/Analysis/IPA/CallGraphSCCPass.cpp
@@ -214,10 +214,13 @@
// list of the same call.
CallSites.count(I->first) ||
- // If the call edge is not from a call or invoke, then the function
- // pass RAUW'd a call with another value. This can happen when
- // constant folding happens of well known functions etc.
- !CallSite(I->first)) {
+ // If the call edge is not from a call or invoke, or it is a
+ // instrinsic call, then the function pass RAUW'd a call with
+ // another value. This can happen when constant folding happens
+ // of well known functions etc.
+ !CallSite(I->first) ||
+ (CallSite(I->first).getCalledFunction() &&
+ CallSite(I->first).getCalledFunction()->isIntrinsic())) {
assert(!CheckingMode &&
"CallGraphSCCPass did not update the CallGraph correctly!");
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7705.20112.patch
Type: text/x-patch
Size: 1098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150217/7e82ed65/attachment.bin>
More information about the llvm-commits
mailing list