forked from OSchip/llvm-project
[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:
parent
d75a6e93ae
commit
f637334df9
|
@ -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) {
|
||||
|
|
|
@ -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()
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue