1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[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

llvm-svn: 363971
This commit is contained in:
Leonard Chan 2019-06-20 19:44:51 +00:00
parent c48203da39
commit 6986b2400c
2 changed files with 27 additions and 2 deletions

View File

@ -812,8 +812,10 @@ ModulePassManager PassBuilder::buildModuleOptimizationPipeline(
// available externally globals. Eventually they will be suppressed during
// codegen, but eliminating here enables more opportunity for GlobalDCE as it
// may make globals referenced by available external functions dead and saves
// running remaining passes on the eliminated functions.
MPM.addPass(EliminateAvailableExternallyPass());
// running remaining passes on the eliminated functions. These should be
// preserved during prelinking for link-time inlining decisions.
if (!LTOPreLink)
MPM.addPass(EliminateAvailableExternallyPass());
if (EnableOrderFileInstrumentation)
MPM.addPass(InstrOrderFilePass());

View File

@ -0,0 +1,23 @@
; Ensure that we don't emit available_externally functions at -O2, unless
; -flto is present in which case we should preserve them for link-time inlining
; decisions.
; RUN: opt < %s -S -passes='default<O2>' | FileCheck %s
; RUN: opt < %s -S -passes='lto-pre-link<O2>' | FileCheck %s --check-prefix=LTO
@x = common local_unnamed_addr global i32 0, align 4
define void @test() local_unnamed_addr #0 {
entry:
tail call void @f0(i32 17)
ret void
}
; CHECK: declare void @f0(i32)
; LTO: define available_externally void @f0(i32 %y)
define available_externally void @f0(i32 %y) local_unnamed_addr #0 {
entry:
store i32 %y, i32* @x, align 4
ret void
}
attributes #0 = { noinline }