llvm.org GIT mirror llvm / 300b37a
[PassManager] Run global optimizations after the inliner. The inliner performs some kind of dead code elimination as it goes, but there are cases that are not really caught by it. We might at some point consider teaching the inliner about them, but it is OK for now to run GlobalOpt + GlobalDCE in tandem as their benefits generally outweight the cost, making the whole pipeline faster. This fixes PR34652. Differential Revision: https://reviews.llvm.org/D38154 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314997 91177308-0d34-0410-b5e6-96231b3b80d8 Davide Italiano 1 year, 11 months ago
3 changed file(s) with 17 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
488488 // Start of CallGraph SCC passes.
489489 if (!DisableUnitAtATime)
490490 MPM.add(createPruneEHPass()); // Remove dead EH info
491 bool RunInliner = false;
491492 if (Inliner) {
492493 MPM.add(Inliner);
493494 Inliner = nullptr;
495 RunInliner = true;
494496 }
495497 if (!DisableUnitAtATime)
496498 MPM.add(createPostOrderFunctionAttrsLegacyPass());
504506 // pass manager that we are specifically trying to avoid. To prevent this
505507 // we must insert a no-op module pass to reset the pass manager.
506508 MPM.add(createBarrierNoopPass());
509
510 // The inliner performs some kind of dead code elimination as it goes,
511 // but there are cases that are not really caught by it. We might
512 // at some point consider teaching the inliner about them, but it
513 // is OK for now to run GlobalOpt + GlobalDCE in tandem as their
514 // benefits generally outweight the cost, making the whole pipeline
515 // faster.
516 if (RunInliner) {
517 MPM.add(createGlobalOptimizerPass());
518 MPM.add(createGlobalDCEPass());
519 }
520
507521 if (RunPartialInlining)
508522 MPM.add(createPartialInliningPass());
509523
0 ; RUN: opt -mtriple=amdgcn-- -O1 -S -inline-threshold=1 -amdgpu-early-inline-all %s | FileCheck %s
11
2 ; CHECK: @c_alias
32 @c_alias = alias i32 (i32), i32 (i32)* @callee
43
54 define i32 @callee(i32 %x) {
1615 ; CHECK: mul i32
1716 ; CHECK-NOT: call i32
1817
18 ; CHECK: define i32 @c_alias
1919 define amdgpu_kernel void @caller(i32 %x) {
2020 entry:
2121 %res = call i32 @callee(i32 %x)
5555 ; a barrier pass.
5656 ; CHECK-O2: A No-Op Barrier Pass
5757 ; Reduce the size of the IR ASAP after the inliner.
58 ; CHECK-O2-NEXT: Global Variable Optimizer
59 ; CHECK-O2: Dead Global Elimination
5860 ; CHECK-O2-NEXT: Eliminate Available Externally
5961 ; Inferring function attribute should be right after the CGSCC pipeline, before
6062 ; any other optimizations/analyses.