llvm.org GIT mirror llvm / 0d6fe2e
[clang][NewPM] Do not eliminate available_externally durng `-O2 -flto` runs This fixes CodeGen/available-externally-suppress.c when the new pass manager is turned on by default. available_externally was not emitted during -O2 -flto runs when it should still be retained for link time inlining purposes. This can be fixed by checking that we aren't LTOPrelinking when adding the EliminateAvailableExternallyPass. Differential Revision: https://reviews.llvm.org/D63580 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363971 91177308-0d34-0410-b5e6-96231b3b80d8 Leonard Chan a month ago
2 changed file(s) with 27 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
811811 // available externally globals. Eventually they will be suppressed during
812812 // codegen, but eliminating here enables more opportunity for GlobalDCE as it
813813 // may make globals referenced by available external functions dead and saves
814 // running remaining passes on the eliminated functions.
815 MPM.addPass(EliminateAvailableExternallyPass());
814 // running remaining passes on the eliminated functions. These should be
815 // preserved during prelinking for link-time inlining decisions.
816 if (!LTOPreLink)
817 MPM.addPass(EliminateAvailableExternallyPass());
816818
817819 if (EnableOrderFileInstrumentation)
818820 MPM.addPass(InstrOrderFilePass());
0 ; Ensure that we don't emit available_externally functions at -O2, unless
1 ; -flto is present in which case we should preserve them for link-time inlining
2 ; decisions.
3 ; RUN: opt < %s -S -passes='default' | FileCheck %s
4 ; RUN: opt < %s -S -passes='lto-pre-link' | FileCheck %s --check-prefix=LTO
5
6 @x = common local_unnamed_addr global i32 0, align 4
7
8 define void @test() local_unnamed_addr #0 {
9 entry:
10 tail call void @f0(i32 17)
11 ret void
12 }
13
14 ; CHECK: declare void @f0(i32)
15 ; LTO: define available_externally void @f0(i32 %y)
16 define available_externally void @f0(i32 %y) local_unnamed_addr #0 {
17 entry:
18 store i32 %y, i32* @x, align 4
19 ret void
20 }
21
22 attributes #0 = { noinline }