llvm.org GIT mirror llvm / 17045f0
[MergeFuncs] Call removeUsers() prior to unnamed_addr RAUW Summary: For unnamed_addr functions we RAUW instead of only replacing direct callers. However, functions in which replacements were performed currently are not added back to the worklist, resulting in missed merging opportunities. Fix this by calling removeUsers() prior to RAUW. Reviewers: jfb, whitequark Reviewed By: whitequark Subscribers: rkruppe, llvm-commits Differential Revision: https://reviews.llvm.org/D53262 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346385 91177308-0d34-0410-b5e6-96231b3b80d8 whitequark 10 months ago
2 changed file(s) with 36 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
769769 GlobalNumbers.erase(G);
770770 // If G's address is not significant, replace it entirely.
771771 Constant *BitcastF = ConstantExpr::getBitCast(F, G->getType());
772 removeUsers(G);
772773 G->replaceAllUsesWith(BitcastF);
773774 } else {
774775 // Redirect direct callers of G to F. (See note on MergeFunctionsPDI
0 ; RUN: opt -S -mergefunc < %s | FileCheck %s
1
2 ; After test3 and test4 have been merged, we should detect that
3 ; test1 and test2 can also be merged.
4
5 ; CHECK: define void @test4() unnamed_addr
6 ; CHECK-NEXT: tail call void @test3()
7 ; CHECK: define void @test2() unnamed_addr
8 ; CHECK-NEXT: tail call void @test1()
9
10 declare void @dummy()
11
12 define void @test1() unnamed_addr {
13 call void @test3()
14 call void @test3()
15 ret void
16 }
17
18 define void @test2() unnamed_addr {
19 call void @test4()
20 call void @test4()
21 ret void
22 }
23
24 define void @test3() unnamed_addr {
25 call void @dummy()
26 call void @dummy()
27 ret void
28 }
29
30 define void @test4() unnamed_addr {
31 call void @dummy()
32 call void @dummy()
33 ret void
34 }