diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1047,22 +1047,6 @@ } } -static void addCoroutinePassesAtO0(ModulePassManager &MPM, - const LangOptions &LangOpts, - const CodeGenOptions &CodeGenOpts) { - if (!LangOpts.Coroutines) - return; - - MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass())); - - CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager); - CGPM.addPass(CoroSplitPass()); - CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass())); - MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM))); - - MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass())); -} - /// A clean version of `EmitAssembly` that uses the new pass manager. /// /// Not all features are currently supported in this system, but where @@ -1319,38 +1303,7 @@ }); if (CodeGenOpts.OptimizationLevel == 0) { - // Build a minimal pipeline based on the semantics required by Clang, - // which is just that always inlining occurs. Further, disable generating - // lifetime intrinsics to avoid enabling further optimizations during - // code generation. - // However, we need to insert lifetime intrinsics to avoid invalid access - // caused by multithreaded coroutines. - PB.registerPipelineStartEPCallback( - [this](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) { - MPM.addPass(AlwaysInlinerPass( - /*InsertLifetimeIntrinsics=*/LangOpts.Coroutines)); - }); - - // At -O0, we can still do PGO. Add all the requested passes for - // instrumentation PGO, if requested. - if (PGOOpt && (PGOOpt->Action == PGOOptions::IRInstr || - PGOOpt->Action == PGOOptions::IRUse)) - PB.addPGOInstrPassesForO0( - MPM, - /* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr), - /* IsCS */ false, PGOOpt->ProfileFile, - PGOOpt->ProfileRemappingFile); - - PB.runRegisteredEPCallbacks(MPM, Level, CodeGenOpts.DebugPassManager); - - // FIXME: the backends do not handle matrix intrinsics currently. Make - // sure they are also lowered in O0. A lightweight version of the pass - // should run in the backend pipeline on demand. - if (LangOpts.MatrixTypes) - MPM.addPass( - createModuleToFunctionPassAdaptor(LowerMatrixIntrinsicsPass())); - - addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts); + MPM = PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO); } else if (IsThinLTO) { MPM = PB.buildThinLTOPreLinkDefaultPipeline(Level); } else if (IsLTO) { @@ -1359,12 +1312,6 @@ MPM = PB.buildPerModuleDefaultPipeline(Level); } - // Lastly, add semantically necessary passes for LTO. - if (IsLTO || IsThinLTO) { - MPM.addPass(CanonicalizeAliasesPass()); - MPM.addPass(NameAnonGlobalPass()); - } - // Add UniqueInternalLinkageNames Pass which renames internal linkage // symbols with unique names. if (CodeGenOpts.UniqueInternalLinkageNames) diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -433,6 +433,12 @@ ModulePassManager buildLTODefaultPipeline(OptimizationLevel Level, ModuleSummaryIndex *ExportSummary); + /// Build an O0 pipeline with the minimal semantically required passes. + /// + /// This should only be used for non-LTO and LTO pre-link pipelines. + ModulePassManager buildO0DefaultPipeline(OptimizationLevel Level, + bool LTOPreLink = false); + /// Build the default `AAManager` with the default alias analysis pipeline /// registered. AAManager buildDefaultAAPipeline(); @@ -600,14 +606,6 @@ OptimizerLastEPCallbacks.push_back(C); } - /// Run all registered extension point callbacks - /// - /// This runs the registered callbacks in the order they would be run in a - /// typical build*Pipeline(). This allows for reusing register*EPCallback() - /// between O0 and O[123] pipelines. - void runRegisteredEPCallbacks(ModulePassManager &MPM, OptimizationLevel Level, - bool DebugLogging); - /// Register a callback for parsing an AliasAnalysis Name to populate /// the given AAManager \p AA void registerParseAACallback( @@ -688,6 +686,8 @@ buildO1FunctionSimplificationPipeline(OptimizationLevel Level, ThinLTOPhase Phase); + void addRequiredLTOPreLinkPasses(ModulePassManager &MPM); + static Optional> parsePipelineText(StringRef Text); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -806,6 +806,11 @@ return FPM; } +void PassBuilder::addRequiredLTOPreLinkPasses(ModulePassManager &MPM) { + MPM.addPass(CanonicalizeAliasesPass()); + MPM.addPass(NameAnonGlobalPass()); +} + void PassBuilder::addPGOInstrPasses(ModulePassManager &MPM, PassBuilder::OptimizationLevel Level, bool RunProfileGen, bool IsCS, @@ -1349,6 +1354,9 @@ // Emit annotation remarks. addAnnotationRemarksPass(MPM); + if (LTOPreLink) + addRequiredLTOPreLinkPasses(MPM); + return MPM; } @@ -1399,6 +1407,8 @@ // Emit annotation remarks. addAnnotationRemarksPass(MPM); + addRequiredLTOPreLinkPasses(MPM); + return MPM; } @@ -1703,13 +1713,35 @@ return MPM; } -void PassBuilder::runRegisteredEPCallbacks(ModulePassManager &MPM, - OptimizationLevel Level, - bool DebugLogging) { +ModulePassManager PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level, + bool LTOPreLink) { assert(Level == OptimizationLevel::O0 && - "runRegisteredEPCallbacks should only be used with O0"); + "buildO0DefaultPipeline should only be used with O0"); + + ModulePassManager MPM(DebugLogging); + + if (PGOOpt && (PGOOpt->Action == PGOOptions::IRInstr || + PGOOpt->Action == PGOOptions::IRUse)) + addPGOInstrPassesForO0( + MPM, + /* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr), + /* IsCS */ false, PGOOpt->ProfileFile, PGOOpt->ProfileRemappingFile); + for (auto &C : PipelineStartEPCallbacks) C(MPM, Level); + + // Build a minimal pipeline based on the semantics required by LLVM, + // which is just that always inlining occurs. Further, disable generating + // lifetime intrinsics to avoid enabling further optimizations during + // code generation. + // However, we need to insert lifetime intrinsics to avoid invalid access + // caused by multithreaded coroutines. + MPM.addPass(AlwaysInlinerPass( + /*InsertLifetimeIntrinsics=*/PTO.Coroutines)); + + if (EnableMatrix) + MPM.addPass(createModuleToFunctionPassAdaptor(LowerMatrixIntrinsicsPass())); + if (!LateLoopOptimizationsEPCallbacks.empty()) { LoopPassManager LPM(DebugLogging); for (auto &C : LateLoopOptimizationsEPCallbacks) @@ -1749,8 +1781,25 @@ if (!FPM.isEmpty()) MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM))); } + + if (PTO.Coroutines) { + MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass())); + + CGSCCPassManager CGPM(DebugLogging); + CGPM.addPass(CoroSplitPass()); + CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass())); + MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM))); + + MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass())); + } + for (auto &C : OptimizerLastEPCallbacks) C(MPM, Level); + + if (LTOPreLink) + addRequiredLTOPreLinkPasses(MPM); + + return MPM; } AAManager PassBuilder::buildDefaultAAPipeline() { @@ -2311,33 +2360,10 @@ .Case("O3", OptimizationLevel::O3) .Case("Os", OptimizationLevel::Os) .Case("Oz", OptimizationLevel::Oz); - if (L == OptimizationLevel::O0) { - // Add instrumentation PGO passes -- at O0 we can still do PGO. - if (PGOOpt && Matches[1] != "thinlto" && - (PGOOpt->Action == PGOOptions::IRInstr || - PGOOpt->Action == PGOOptions::IRUse)) - addPGOInstrPassesForO0( - MPM, - /* RunProfileGen */ (PGOOpt->Action == PGOOptions::IRInstr), - /* IsCS */ false, PGOOpt->ProfileFile, - PGOOpt->ProfileRemappingFile); - - // For IR that makes use of coroutines intrinsics, coroutine passes must - // be run, even at -O0. - if (PTO.Coroutines) { - MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass())); - - CGSCCPassManager CGPM(DebugLogging); - CGPM.addPass(CoroSplitPass()); - CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass())); - MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM))); - - MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass())); - } - - runRegisteredEPCallbacks(MPM, L, DebugLogging); - - // Do nothing else at all! + if (L == OptimizationLevel::O0 && + (Matches[1] == "default" || Matches[1] == "thinlto-pre-link" || + Matches[1] == "lto-pre-link")) { + MPM.addPass(buildO0DefaultPipeline(L, Matches[1] != "default")); return Error::success(); } diff --git a/llvm/test/Other/new-pass-manager.ll b/llvm/test/Other/new-pass-manager.ll --- a/llvm/test/Other/new-pass-manager.ll +++ b/llvm/test/Other/new-pass-manager.ll @@ -360,7 +360,9 @@ ; RUN: -passes='default' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefix=CHECK-O0 --check-prefix=%llvmcheckext ; CHECK-O0: Starting llvm::Module pass manager run -; CHECK-EXT-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> +; CHECK-O0-NEXT: Running pass: AlwaysInlinerPass +; CHECK-O0-NEXT: Running analysis: InnerAnalysisManagerProxy<{{.*}}> +; CHECK-O0-NEXT: Running analysis: ProfileSummaryAnalysis ; CHECK-EXT-NEXT: Starting llvm::Function pass manager run. ; CHECK-EXT-NEXT: Running pass: {{.*}}Bye ; CHECK-EXT-NEXT: Finished llvm::Function pass manager run. diff --git a/llvm/test/Other/new-pm-O0-defaults.ll b/llvm/test/Other/new-pm-O0-defaults.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Other/new-pm-O0-defaults.ll @@ -0,0 +1,70 @@ +; The IR below was crafted so as: +; 1) To have a loop, so we create a loop pass manager +; 2) To be "immutable" in the sense that no pass in the standard +; pipeline will modify it. +; Since no transformations take place, we don't expect any analyses +; to be invalidated. +; Any invalidation that shows up here is a bug, unless we started modifying +; the IR, in which case we need to make it immutable harder. + +; RUN: opt -disable-verify -debug-pass-manager \ +; RUN: -passes='default' -S %s 2>&1 \ +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT +; RUN: opt -disable-verify -debug-pass-manager \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT,CHECK-PRE-LINK +; RUN: opt -disable-verify -debug-pass-manager \ +; RUN: -passes='lto-pre-link' -S %s 2>&1 \ +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-DEFAULT,CHECK-PRE-LINK +; RUN: opt -disable-verify -debug-pass-manager \ +; RUN: -passes='thinlto' -S %s 2>&1 \ +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-THINLTO +; RUN: opt -disable-verify -debug-pass-manager \ +; RUN: -passes='lto' -S %s 2>&1 \ +; RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-LTO + +; CHECK: Starting llvm::Module pass manager run. +; CHECK-DEFAULT-NEXT: Running pass: AlwaysInlinerPass +; CHECK-DEFAULT-NEXT: Running analysis: InnerAnalysisManagerProxy +; CHECK-DEFAULT-NEXT: Running analysis: ProfileSummaryAnalysis +; CHECK-PRE-LINK-NEXT: Running pass: CanonicalizeAliasesPass +; CHECK-PRE-LINK-NEXT: Running pass: NameAnonGlobalPass +; CHECK-THINLTO-NEXT: Running pass: Annotation2MetadataPass +; CHECK-LTO-NEXT: Running pass: Annotation2MetadataPass +; CHECK-LTO-NEXT: Running pass: WholeProgramDevirtPass +; CHECK-LTO-NEXT: Running analysis: InnerAnalysisManagerProxy +; CHECK-LTO-NEXT: Running pass: LowerTypeTestsPass +; CHECK-LTO-NEXT: Running pass: LowerTypeTestsPass +; CHECK-LTO-NEXT: Running pass: AnnotationRemarksPass +; CHECK-NEXT: Running pass: PrintModulePass + +; Make sure we get the IR back out without changes when we print the module. +; CHECK-LABEL: define void @foo(i32 %n) local_unnamed_addr { +; CHECK-NEXT: entry: +; CHECK-NEXT: br label %loop +; CHECK: loop: +; CHECK-NEXT: %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ] +; CHECK-NEXT: %iv.next = add i32 %iv, 1 +; CHECK-NEXT: tail call void @bar() +; CHECK-NEXT: %cmp = icmp eq i32 %iv, %n +; CHECK-NEXT: br i1 %cmp, label %exit, label %loop +; CHECK: exit: +; CHECK-NEXT: ret void +; CHECK-NEXT: } +; +; CHECK-NEXT: Finished llvm::Module pass manager run. + +declare void @bar() local_unnamed_addr + +define void @foo(i32 %n) local_unnamed_addr { +entry: + br label %loop +loop: + %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ] + %iv.next = add i32 %iv, 1 + tail call void @bar() + %cmp = icmp eq i32 %iv, %n + br i1 %cmp, label %exit, label %loop +exit: + ret void +} diff --git a/llvm/test/Other/new-pm-defaults.ll b/llvm/test/Other/new-pm-defaults.ll --- a/llvm/test/Other/new-pm-defaults.ll +++ b/llvm/test/Other/new-pm-defaults.ll @@ -9,84 +9,59 @@ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O1 \ -; RUN: --check-prefix=%llvmcheckext +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O1,%llvmcheckext ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O2 \ -; RUN: --check-prefix=CHECK-O23SZ --check-prefix=%llvmcheckext +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O2,CHECK-O23SZ,%llvmcheckext ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=CHECK-O23SZ --check-prefix=%llvmcheckext +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,CHECK-O23SZ,%llvmcheckext ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-Os \ -; RUN: --check-prefix=CHECK-O23SZ --check-prefix=%llvmcheckext +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-Os,CHECK-O23SZ,%llvmcheckext ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-Oz \ -; RUN: --check-prefix=CHECK-O23SZ --check-prefix=%llvmcheckext +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-Oz,CHECK-O23SZ,%llvmcheckext ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes='lto-pre-link' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O2 \ -; RUN: --check-prefix=CHECK-O23SZ --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-O2-LTO +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-LTO,CHECK-O2,CHECK-O23SZ,%llvmcheckext ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-peephole='no-op-function' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-PEEPHOLE --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-PEEPHOLE,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-late-loop-optimizations='no-op-loop' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-LOOP-LATE --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-LOOP-LATE,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-loop-optimizer-end='no-op-loop' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-LOOP-END --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-LOOP-END,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-scalar-optimizer-late='no-op-function' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-SCALAR-LATE --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-SCALAR-LATE,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-cgscc-optimizer-late='no-op-cgscc' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-CGSCC-LATE --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-CGSCC-LATE,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-vectorizer-start='no-op-function' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-VECTORIZER-START --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-VECTORIZER-START,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-pipeline-start='no-op-module' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-PIPELINE-START --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-START,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-pipeline-start='no-op-module' \ ; RUN: -passes='lto-pre-link' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-PIPELINE-START --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-LTO,CHECK-O3,%llvmcheckext,CHECK-EP-PIPELINE-START,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -passes-ep-optimizer-last='no-op-function' \ ; RUN: -passes='default' -S %s 2>&1 \ -; RUN: | FileCheck %s --check-prefix=CHECK-O --check-prefix=CHECK-O3 \ -; RUN: --check-prefix=%llvmcheckext \ -; RUN: --check-prefix=CHECK-EP-OPTIMIZER-LAST --check-prefix=CHECK-O23SZ +; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-DEFAULT,CHECK-O3,%llvmcheckext,CHECK-EP-OPTIMIZER-LAST,CHECK-O23SZ ; Suppress FileCheck --allow-unused-prefixes=false diagnostics. ; CHECK-Oz: {{^}} @@ -225,8 +200,9 @@ ; CHECK-O-NEXT: Finished llvm::Module pass manager run. ; CHECK-O-NEXT: Running pass: GlobalOptPass ; CHECK-O-NEXT: Running pass: GlobalDCEPass -; CHECK-O2-LTO-NOT: Running pass: EliminateAvailableExternallyPass -; CHECK-O: Running pass: ReversePostOrderFunctionAttrsPass +; CHECK-DEFAULT-NEXT: Running pass: EliminateAvailableExternallyPass +; CHECK-LTO-NOT: Running pass: EliminateAvailableExternallyPass +; CHECK-O-NEXT: Running pass: ReversePostOrderFunctionAttrsPass ; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}GlobalsAA ; CHECK-O-NEXT: Starting llvm::Function pass manager run. ; CHECK-O-NEXT: Running pass: Float2IntPass @@ -274,6 +250,8 @@ ; CHECK-O-NEXT: Running pass: GlobalDCEPass ; CHECK-O-NEXT: Running pass: ConstantMergePass ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo +; CHECK-LTO-NEXT: Running pass: CanonicalizeAliasesPass +; CHECK-LTO-NEXT: Running pass: NameAnonGlobalPass ; CHECK-O-NEXT: Running pass: PrintModulePass ; ; Make sure we get the IR back out without changes when we print the module. diff --git a/llvm/test/Other/new-pm-pgo-O0.ll b/llvm/test/Other/new-pm-pgo-O0.ll --- a/llvm/test/Other/new-pm-pgo-O0.ll +++ b/llvm/test/Other/new-pm-pgo-O0.ll @@ -7,6 +7,8 @@ ; RUN: |FileCheck %s --check-prefixes=USE_PRE_LINK,USE ; RUN: opt -debug-pass-manager -passes='thinlto' -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' %s 2>&1 \ ; RUN: |FileCheck %s --check-prefixes=USE_POST_LINK,USE +; RUN: opt -debug-pass-manager -passes='lto' -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' %s 2>&1 \ +; RUN: |FileCheck %s --check-prefixes=USE_POST_LINK,USE ; ; GEN: Running pass: PGOInstrumentationGen diff --git a/llvm/test/Other/new-pm-thinlto-defaults.ll b/llvm/test/Other/new-pm-thinlto-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-defaults.ll @@ -9,22 +9,22 @@ ; ; Prelink pipelines: ; RUN: opt -disable-verify -debug-pass-manager \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1,CHECK-PRELINK-O,CHECK-PRELINK-O-NODIS ; RUN: opt -disable-verify -debug-pass-manager \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-PRELINK-O,CHECK-PRELINK-O-NODIS ; RUN: opt -disable-verify -debug-pass-manager \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-PRELINK-O,CHECK-PRELINK-O-NODIS,CHECK-EP-PIPELINE-START ; RUN: opt -disable-verify -debug-pass-manager \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ,CHECK-PRELINK-O,CHECK-PRELINK-O-NODIS ; RUN: opt -disable-verify -debug-pass-manager \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ,CHECK-PRELINK-O,CHECK-PRELINK-O-NODIS ; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-DIS,CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-PRELINK-O ; ; Postlink pipelines: @@ -242,6 +242,7 @@ ; CHECK-POSTLINK-O-NEXT: Running pass: GlobalDCEPass ; CHECK-POSTLINK-O-NEXT: Running pass: ConstantMergePass ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo +; CHECK-PRELINK-O-NEXT: Running pass: CanonicalizeAliasesPass ; CHECK-PRELINK-O-NEXT: Running pass: NameAnonGlobalPass ; CHECK-O-NEXT: Running pass: PrintModulePass diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll @@ -4,27 +4,27 @@ ; ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1,CHECK-O123 ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-O123 ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-O123,CHECK-EP-PIPELINE-START ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \ ; RUN: -pgo-kind=pgo-instr-use-pipeline -profile-file='%t.profdata' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ,CHECK-O123 ; ; CHECK-O: Starting {{.*}}Module pass manager run. @@ -220,6 +220,7 @@ ; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis on bar ; CHECK-EXT: Running pass: {{.*}}::Bye ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo +; CHECK-O-NEXT: Running pass: CanonicalizeAliasesPass ; CHECK-O-NEXT: Running pass: NameAnonGlobalPass ; CHECK-O-NEXT: Running pass: PrintModulePass diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll --- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll +++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll @@ -2,27 +2,27 @@ ; ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O1 ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S -passes-ep-pipeline-start='no-op-module' %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O3,CHECK-O23SZ,CHECK-EP-PIPELINE-START ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Os,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager \ ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-Oz,CHECK-O23SZ ; RUN: opt -disable-verify -debug-pass-manager -new-pm-debug-info-for-profiling \ ; RUN: -pgo-kind=pgo-sample-use-pipeline -profile-file='%S/Inputs/new-pm-thinlto-samplepgo-defaults.prof' \ -; RUN: -passes='thinlto-pre-link,name-anon-globals' -S %s 2>&1 \ +; RUN: -passes='thinlto-pre-link' -S %s 2>&1 \ ; RUN: | FileCheck %s --check-prefixes=CHECK-O,CHECK-O2,CHECK-O23SZ ; ; CHECK-O: Starting {{.*}}Module pass manager run. @@ -173,6 +173,7 @@ ; CHECK-O-NEXT: Finished {{.*}}Module pass manager run. ; CHECK-O-NEXT: Running pass: GlobalOptPass ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo +; CHECK-O-NEXT: Running pass: CanonicalizeAliasesPass ; CHECK-O-NEXT: Running pass: NameAnonGlobalPass ; CHECK-O-NEXT: Running pass: PrintModulePass diff --git a/llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll b/llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll --- a/llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll +++ b/llvm/test/Transforms/CanonicalizeAliases/canonicalize.ll @@ -1,6 +1,7 @@ ; RUN: opt -S -canonicalize-aliases < %s | FileCheck %s -; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s | llvm-dis -o - | FileCheck %s ; RUN: opt -S -passes=canonicalize-aliases < %s | FileCheck %s +; RUN: opt -prepare-for-thinlto -O0 -module-summary -o - < %s -enable-new-pm=0 | llvm-dis -o - | FileCheck %s +; RUN: opt -passes='thinlto-pre-link,require' -o - < %s | llvm-dis -o - | FileCheck %s target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/llvm/test/Transforms/NameAnonGlobals/rename.ll b/llvm/test/Transforms/NameAnonGlobals/rename.ll --- a/llvm/test/Transforms/NameAnonGlobals/rename.ll +++ b/llvm/test/Transforms/NameAnonGlobals/rename.ll @@ -1,5 +1,6 @@ ; RUN: opt -S -name-anon-globals < %s | FileCheck %s -; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc < %s +; RUN: opt -prepare-for-thinlto -O0 -module-summary -o %t.bc -enable-new-pm=0 < %s +; RUN: opt -passes='thinlto-pre-link,require' -o %t.bc < %s ; foo contribute to the unique hash for the module