From: Joseph Huber Date: Fri, 21 Jan 2022 20:43:20 +0000 (-0500) Subject: [PassBuilder] Add OpenMPOpt to default LTO pipeline X-Git-Tag: upstream/15.0.7~18332 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d3a47576c1c122891fe88ac13d8a3a131544c34;p=platform%2Fupstream%2Fllvm.git [PassBuilder] Add OpenMPOpt to default LTO pipeline The LTO support for OpenMP offloading allows us to run the OpenMPOpt pass during the LTO pipeline. This patch introduces an early run of the Module pass and a late run of the CGSCC pass. These are quick no-ops if there is no OpenMP in the module. Depends on D118198 Differential Revision: https://reviews.llvm.org/D118611 --- diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 6110bda..93637c8 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -1454,6 +1454,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, MPM.addPass(RequireAnalysisPass()); } + // Try to run OpenMP optimizations, quick no-op if no OpenMP metadata present. + MPM.addPass(OpenMPOptPass()); + // Remove unused virtual tables to improve the quality of code generated by // whole-program devirtualization and bitset lowering. MPM.addPass(GlobalDCEPass()); @@ -1648,6 +1651,10 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, addVectorPasses(Level, MainFPM, /* IsFullLTO */ true); + // Run the OpenMPOpt CGSCC pass again late. + MPM.addPass( + createModuleToPostOrderCGSCCPassAdaptor(OpenMPOptCGSCCPass())); + invokePeepholeEPCallbacks(MainFPM, Level); MainFPM.addPass(JumpThreadingPass(/*InsertFreezeWhenUnfoldingSelect*/ true)); MPM.addPass(createModuleToFunctionPassAdaptor(std::move(MainFPM), diff --git a/llvm/test/Other/new-pm-lto-defaults.ll b/llvm/test/Other/new-pm-lto-defaults.ll index 73fe5f2..c165102 100644 --- a/llvm/test/Other/new-pm-lto-defaults.ll +++ b/llvm/test/Other/new-pm-lto-defaults.ll @@ -27,6 +27,7 @@ ; CHECK-O: Running pass: Annotation2Metadata ; CHECK-O-NEXT: Running pass: CrossDSOCFIPass +; CHECK-O-NEXT: Running pass: OpenMPOptPass ; CHECK-O-NEXT: Running pass: GlobalDCEPass ; CHECK-O-NEXT: Running pass: ForceFunctionAttrsPass ; CHECK-O-NEXT: Running pass: InferFunctionAttrsPass @@ -87,6 +88,7 @@ ; CHECK-O23SZ-NEXT: Running analysis: GlobalsAA on [module] ; CHECK-O23SZ-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}AAManager ; CHECK-O23SZ-NEXT: Invalidating analysis: AAManager on foo +; CHECK-O23SZ-NEXT: Running pass: OpenMPOptCGSCCPass on (foo) ; CHECK-O23SZ-NEXT: Running pass: LoopSimplifyPass on foo ; CHECK-O23SZ-NEXT: Running analysis: LoopAnalysis on foo ; CHECK-O23SZ-NEXT: Running pass: LCSSAPass on foo