1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

[CallGraphUpdater] Removed references to calles when deleting function

Summary: Otherwise we can get unaccounted references to call graph nodes.

Reviewers: jdoerfert, sstefan1

Reviewed By: jdoerfert

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79382
This commit is contained in:
Sergey Dmitriev 2020-05-04 18:58:59 -07:00
parent 6bb0aa513e
commit 84d3c8040f
3 changed files with 39 additions and 5 deletions

View File

@ -112,8 +112,11 @@ void CallGraphUpdater::removeFunction(Function &DeadFn) {
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) {

View File

@ -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()

View File

@ -687,9 +687,9 @@ namespace llvm {
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);