mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[ThinLTO] Pass down opt level to LTO backend and handle -O0 LTO in new PM
Summary: The opt level was not being passed down to the ThinLTO backend when invoked via clang (for distributed ThinLTO). This exposed an issue where the new PM was asserting if the Thin or regular LTO backend pipelines were invoked with -O0 (not a new issue, could be provoked by invoking in-process *LTO backends via linker using new PM and -O0). Fix this similar to the old PM where -O0 only does the necessary lowering of type metadata (WPD and LowerTypeTest passes) and then quits, rather than asserting. Reviewers: xur Subscribers: mehdi_amini, inglorion, eraman, hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits, pcc Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61022 llvm-svn: 359025
This commit is contained in:
parent
e063765ded
commit
9937f43a8d
@ -1046,10 +1046,16 @@ ModulePassManager PassBuilder::buildThinLTODefaultPipeline(
|
|||||||
//
|
//
|
||||||
// Also, WPD has access to more precise information than ICP and can
|
// Also, WPD has access to more precise information than ICP and can
|
||||||
// devirtualize more effectively, so it should operate on the IR first.
|
// devirtualize more effectively, so it should operate on the IR first.
|
||||||
|
//
|
||||||
|
// The WPD and LowerTypeTest passes need to run at -O0 to lower type
|
||||||
|
// metadata and intrinsics.
|
||||||
MPM.addPass(WholeProgramDevirtPass(nullptr, ImportSummary));
|
MPM.addPass(WholeProgramDevirtPass(nullptr, ImportSummary));
|
||||||
MPM.addPass(LowerTypeTestsPass(nullptr, ImportSummary));
|
MPM.addPass(LowerTypeTestsPass(nullptr, ImportSummary));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Level == O0)
|
||||||
|
return MPM;
|
||||||
|
|
||||||
// Force any function attributes we want the rest of the pipeline to observe.
|
// Force any function attributes we want the rest of the pipeline to observe.
|
||||||
MPM.addPass(ForceFunctionAttrsPass());
|
MPM.addPass(ForceFunctionAttrsPass());
|
||||||
|
|
||||||
@ -1075,9 +1081,16 @@ PassBuilder::buildLTOPreLinkDefaultPipeline(OptimizationLevel Level,
|
|||||||
ModulePassManager
|
ModulePassManager
|
||||||
PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging,
|
PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, bool DebugLogging,
|
||||||
ModuleSummaryIndex *ExportSummary) {
|
ModuleSummaryIndex *ExportSummary) {
|
||||||
assert(Level != O0 && "Must request optimizations for the default pipeline!");
|
|
||||||
ModulePassManager MPM(DebugLogging);
|
ModulePassManager MPM(DebugLogging);
|
||||||
|
|
||||||
|
if (Level == O0) {
|
||||||
|
// The WPD and LowerTypeTest passes need to run at -O0 to lower type
|
||||||
|
// metadata and intrinsics.
|
||||||
|
MPM.addPass(WholeProgramDevirtPass(ExportSummary, nullptr));
|
||||||
|
MPM.addPass(LowerTypeTestsPass(ExportSummary, nullptr));
|
||||||
|
return MPM;
|
||||||
|
}
|
||||||
|
|
||||||
if (PGOOpt && PGOOpt->Action == PGOOptions::SampleUse) {
|
if (PGOOpt && PGOOpt->Action == PGOOptions::SampleUse) {
|
||||||
// Load sample profile before running the LTO optimization pipeline.
|
// Load sample profile before running the LTO optimization pipeline.
|
||||||
MPM.addPass(SampleProfileLoaderPass(PGOOpt->ProfileFile,
|
MPM.addPass(SampleProfileLoaderPass(PGOOpt->ProfileFile,
|
||||||
|
@ -6,12 +6,25 @@
|
|||||||
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
||||||
; RUN: -m elf_x86_64 \
|
; RUN: -m elf_x86_64 \
|
||||||
; RUN: -plugin-opt=O1 -r -o %t.o %t.bc
|
; RUN: -plugin-opt=O1 -r -o %t.o %t.bc
|
||||||
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O1 %s
|
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O1 --check-prefix=CHECK-O1-OLDPM %s
|
||||||
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
||||||
; RUN: -m elf_x86_64 \
|
; RUN: -m elf_x86_64 \
|
||||||
; RUN: -plugin-opt=O2 -r -o %t.o %t.bc
|
; RUN: -plugin-opt=O2 -r -o %t.o %t.bc
|
||||||
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O2 %s
|
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O2 %s
|
||||||
|
|
||||||
|
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
||||||
|
; RUN: -m elf_x86_64 --plugin-opt=new-pass-manager \
|
||||||
|
; RUN: -plugin-opt=O0 -r -o %t.o %t.bc
|
||||||
|
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O0 %s
|
||||||
|
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
||||||
|
; RUN: -m elf_x86_64 --plugin-opt=new-pass-manager \
|
||||||
|
; RUN: -plugin-opt=O1 -r -o %t.o %t.bc
|
||||||
|
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O1 --check-prefix=CHECK-O1-NEWPM %s
|
||||||
|
; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext -plugin-opt=save-temps \
|
||||||
|
; RUN: -m elf_x86_64 --plugin-opt=new-pass-manager \
|
||||||
|
; RUN: -plugin-opt=O2 -r -o %t.o %t.bc
|
||||||
|
; RUN: llvm-dis < %t.o.0.4.opt.bc -o - | FileCheck --check-prefix=CHECK-O2 %s
|
||||||
|
|
||||||
; CHECK-O0: define internal void @foo(
|
; CHECK-O0: define internal void @foo(
|
||||||
; CHECK-O1: define internal void @foo(
|
; CHECK-O1: define internal void @foo(
|
||||||
; CHECK-O2-NOT: define internal void @foo(
|
; CHECK-O2-NOT: define internal void @foo(
|
||||||
@ -36,7 +49,9 @@ f:
|
|||||||
|
|
||||||
end:
|
end:
|
||||||
; CHECK-O0: phi
|
; CHECK-O0: phi
|
||||||
; CHECK-O1: select
|
; CHECK-O1-OLDPM: select
|
||||||
|
; The new PM does not do as many optimizations at O1
|
||||||
|
; CHECK-O1-NEWPM: phi
|
||||||
%r = phi i32 [ 1, %t ], [ 2, %f ]
|
%r = phi i32 [ 1, %t ], [ 2, %f ]
|
||||||
ret i32 %r
|
ret i32 %r
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user