[PATCH] D79382: [CallGraphUpdater] Removed references to calles when deleting function
Sergey Dmitriev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 4 19:23:11 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf637334df93f: [CallGraphUpdater] Removed references to calles when deleting function (authored by sdmitriev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79382/new/
https://reviews.llvm.org/D79382
Files:
llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
llvm/test/Transforms/Util/cg-updater-dead-function-callees.ll
llvm/unittests/IR/LegacyPassManagerTest.cpp
Index: llvm/unittests/IR/LegacyPassManagerTest.cpp
===================================================================
--- llvm/unittests/IR/LegacyPassManagerTest.cpp
+++ llvm/unittests/IR/LegacyPassManagerTest.cpp
@@ -687,9 +687,9 @@
Passes.add(P);
Passes.run(*M);
ASSERT_EQ(P->SetupWorked, 1U);
- ASSERT_EQ(P->NumSCCs, 5U);
- ASSERT_EQ(P->NumFns, 8U);
- ASSERT_EQ(P->NumFnDecls, 3U);
+ ASSERT_EQ(P->NumSCCs, 4U);
+ ASSERT_EQ(P->NumFns, 6U);
+ ASSERT_EQ(P->NumFnDecls, 1U);
ASSERT_EQ(M->getFunctionList().size(), 3U);
ASSERT_EQ(P->NumExtCalledBefore, /* test1, 2a, 2b, 3, 4 */ 5U);
ASSERT_EQ(P->NumExtCalledAfter, /* test1, 3repl, 4 */ 3U);
Index: llvm/test/Transforms/Util/cg-updater-dead-function-callees.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Util/cg-updater-dead-function-callees.ll
@@ -0,0 +1,31 @@
+; RUN: opt -inline -attributor-cgscc -tailcallelim -S %s | FileCheck %s
+;
+; CHECK: define void @foo()
+; CHECK: declare i32 @baz()
+; CHECK-NOT: void @goo()
+; CHECK-NOT: void @bar()
+
+define void @foo() {
+ call fastcc void @bar()
+ ret void
+}
+
+define internal fastcc void @goo() {
+ call fastcc void @bar()
+ ret void
+}
+
+define internal fastcc void @bar() {
+ %call = call i32 @baz()
+ %cond = icmp eq i32 %call, 0
+ br i1 %cond, label %if.then, label %if.end
+
+if.then:
+ call fastcc void @goo()
+ br label %if.end
+
+if.end:
+ ret void
+}
+
+declare i32 @baz()
Index: llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
+++ llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
@@ -112,8 +112,11 @@
DeadFunctions.push_back(&DeadFn);
// For the old call graph we remove the function from the SCC right away.
- if (CG && !ReplacedFunctions.count(&DeadFn))
- CGSCC->DeleteNode((*CG)[&DeadFn]);
+ if (CG && !ReplacedFunctions.count(&DeadFn)) {
+ CallGraphNode *DeadCGN = (*CG)[&DeadFn];
+ DeadCGN->removeAllCalledFunctions();
+ CGSCC->DeleteNode(DeadCGN);
+ }
}
void CallGraphUpdater::replaceFunctionWith(Function &OldFn, Function &NewFn) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79382.261990.patch
Type: text/x-patch
Size: 2246 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200505/7fd025b3/attachment.bin>
More information about the llvm-commits
mailing list