[PATCH] D58391: [TailCallElim] Add tailcall elimination pass to LTO Pipelines

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 19 13:23:38 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL356511: [TailCallElim] Add tailcall elimination pass to LTO pipelines (authored by rlougher, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58391?vs=187402&id=191381#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58391/new/

https://reviews.llvm.org/D58391

Files:
  llvm/trunk/lib/Passes/PassBuilder.cpp
  llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/trunk/test/LTO/X86/tailcallelim.ll
  llvm/trunk/test/Other/new-pm-lto-defaults.ll


Index: llvm/trunk/test/LTO/X86/tailcallelim.ll
===================================================================
--- llvm/trunk/test/LTO/X86/tailcallelim.ll
+++ llvm/trunk/test/LTO/X86/tailcallelim.ll
@@ -0,0 +1,22 @@
+; Check that the LTO pipelines add the Tail Call Elimination pass.
+
+; RUN: llvm-as < %s > %t1
+; RUN: llvm-lto -o %t2 %t1 --exported-symbol=foo -save-merged-module
+; RUN: llvm-dis < %t2.merged.bc | FileCheck %s
+
+; RUN: llvm-lto2 run -r %t1,foo,plx -r %t1,bar,plx -o %t3 %t1 -save-temps
+; RUN: llvm-dis < %t3.0.4.opt.bc | FileCheck %s
+
+; RUN: llvm-lto2 run -r %t1,foo,plx -r %t1,bar,plx -o %t4 %t1 -save-temps -use-new-pm
+; RUN: llvm-dis < %t4.0.4.opt.bc | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo() {
+; CHECK: tail call void @bar()
+  call void @bar()
+  ret void
+}
+
+declare void @bar()
Index: llvm/trunk/test/Other/new-pm-lto-defaults.ll
===================================================================
--- llvm/trunk/test/Other/new-pm-lto-defaults.ll
+++ llvm/trunk/test/Other/new-pm-lto-defaults.ll
@@ -81,6 +81,7 @@
 ; CHECK-O2-NEXT: Running pass: JumpThreadingPass
 ; CHECK-O2-NEXT: Running analysis: LazyValueAnalysis
 ; CHECK-O2-NEXT: Running pass: SROA on foo
+; CHECK-O2-NEXT: Running pass: TailCallElimPass on foo
 ; CHECK-O2-NEXT: Finished llvm::Function pass manager run.
 ; CHECK-O2-NEXT: Running pass: ModuleToPostOrderCGSCCPassAdaptor<{{.*}}PostOrderFunctionAttrsPass>
 ; CHECK-O2-NEXT: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
Index: llvm/trunk/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/trunk/lib/Passes/PassBuilder.cpp
+++ llvm/trunk/lib/Passes/PassBuilder.cpp
@@ -1185,6 +1185,10 @@
   // Break up allocas
   FPM.addPass(SROA());
 
+  // LTO provides additional opportunities for tailcall elimination due to
+  // link-time inlining, and visibility of nocapture attribute.
+  FPM.addPass(TailCallElimPass());
+
   // Run a few AA driver optimizations here and now to cleanup the code.
   MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
 
Index: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -896,6 +896,10 @@
   // Break up allocas
   PM.add(createSROAPass());
 
+  // LTO provides additional opportunities for tailcall elimination due to
+  // link-time inlining, and visibility of nocapture attribute.
+  PM.add(createTailCallEliminationPass());
+
   // Run a few AA driven optimizations here and now, to cleanup the code.
   PM.add(createPostOrderFunctionAttrsLegacyPass()); // Add nocapture.
   PM.add(createGlobalsAAWrapperPass()); // IP alias analysis.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58391.191381.patch
Type: text/x-patch
Size: 2909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190319/20e3fbbe/attachment.bin>


More information about the llvm-commits mailing list