[llvm] r305934 - Do not inline recursive direct calls in sample loader pass.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 10:57:43 PDT 2017


Author: dehao
Date: Wed Jun 21 12:57:43 2017
New Revision: 305934

URL: http://llvm.org/viewvc/llvm-project?rev=305934&view=rev
Log:
Do not inline recursive direct calls in sample loader pass.

Summary: r305009 disables recursive inlining for indirect calls in sample loader pass. The same logic applies to direct recursive calls.

Reviewers: iteratee, davidxl

Reviewed By: iteratee

Subscribers: sanjoy, llvm-commits, eraman

Differential Revision: https://reviews.llvm.org/D34456

Modified:
    llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
    llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof
    llvm/trunk/test/Transforms/SampleProfile/early-inline.ll

Modified: llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp?rev=305934&r1=305933&r2=305934&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/SampleProfile.cpp Wed Jun 21 12:57:43 2017
@@ -690,6 +690,9 @@ bool SampleProfileLoader::inlineHotFunct
     for (auto I : CIS) {
       InlineFunctionInfo IFI(nullptr, ACT ? &GetAssumptionCache : nullptr);
       Function *CalledFunction = CallSite(I).getCalledFunction();
+      // Do not inline recursive calls.
+      if (CalledFunction == &F)
+        continue;
       Instruction *DI = I;
       if (!CalledFunction && !PromotedInsns.count(I) &&
           CallSite(I).isIndirectCall())

Modified: llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof?rev=305934&r1=305933&r2=305934&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof (original)
+++ llvm/trunk/test/Transforms/SampleProfile/Inputs/einline.prof Wed Jun 21 12:57:43 2017
@@ -1,3 +1,6 @@
 _Z3foov:200:100
  1: _Z3barv:0
  3: _Z3barv:100
+recursive:200:100
+ 1: recursive:100
+ 2: recursive:100

Modified: llvm/trunk/test/Transforms/SampleProfile/early-inline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SampleProfile/early-inline.ll?rev=305934&r1=305933&r2=305934&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SampleProfile/early-inline.ll (original)
+++ llvm/trunk/test/Transforms/SampleProfile/early-inline.ll Wed Jun 21 12:57:43 2017
@@ -32,6 +32,19 @@ define internal void @_ZL3barv() !dbg !1
   ret void
 }
 
+; CHECK-LABEL: @recursive
+define void @recursive() !dbg !13 {
+; Recursive calls should not be early-inlined.
+; CHECK-NOT: call void @recursive
+; CHECK: call void @recursive
+; CHECK: call void @recursive
+; CHECK-NOT: call void @recursive
+; CHECK: ret
+  call void @recursive(), !dbg !14
+  call void @recursive(), !dbg !15
+  ret void
+}
+
 declare i32 @__gxx_personality_v0(...)
 
 !llvm.dbg.cu = !{!0}
@@ -46,3 +59,6 @@ declare i32 @__gxx_personality_v0(...)
 !10 = !DILocation(line: 8, column: 5, scope: !11)
 !11 = distinct !DILexicalBlock(scope: !6, file: !1, line: 7, column: 7)
 !12 = distinct !DISubprogram(linkageName: "_ZL3barv", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
+!13 = distinct !DISubprogram(linkageName: "recursive", scope: !1, file: !1, line: 20, scopeLine: 20, unit: !0)
+!14 = !DILocation(line: 21, column: 3, scope: !13)
+!15 = !DILocation(line: 22, column: 3, scope: !13)




More information about the llvm-commits mailing list