]> granicus.if.org Git - llvm/commitdiff
[HotColdSplit] Simplify tests by lowering their splitting thresholds
authorVedant Kumar <vsk@apple.com>
Thu, 17 Jan 2019 21:29:34 +0000 (21:29 +0000)
committerVedant Kumar <vsk@apple.com>
Thu, 17 Jan 2019 21:29:34 +0000 (21:29 +0000)
This gets rid of the brittle/mysterious calls to @sink()/@sideeffect()
peppered throughout the test cases. They are no longer needed to force
splitting to occur.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351480 91177308-0d34-0410-b5e6-96231b3b80d8

25 files changed:
lib/Transforms/IPO/HotColdSplitting.cpp
test/Transforms/HotColdSplit/X86/do-not-split.ll [moved from test/Transforms/HotColdSplit/do-not-split.ll with 94% similarity]
test/Transforms/HotColdSplit/X86/extraction-subregion-breaks-phis.ll [moved from test/Transforms/HotColdSplit/extraction-subregion-breaks-phis.ll with 97% similarity]
test/Transforms/HotColdSplit/X86/outline-expensive.ll
test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll
test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll
test/Transforms/HotColdSplit/eh-pads.ll
test/Transforms/HotColdSplit/eh-typeid-for.ll
test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
test/Transforms/HotColdSplit/lifetime-markers-on-inputs.ll
test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll
test/Transforms/HotColdSplit/minsize.ll
test/Transforms/HotColdSplit/multiple-exits.ll
test/Transforms/HotColdSplit/noreturn.ll
test/Transforms/HotColdSplit/outline-cold-asm.ll
test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
test/Transforms/HotColdSplit/outline-if-then-else.ll
test/Transforms/HotColdSplit/outline-multiple-entry-region.ll
test/Transforms/HotColdSplit/outline-while-loop.ll
test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
test/Transforms/HotColdSplit/region-overlap.ll
test/Transforms/HotColdSplit/split-cold-2.ll
test/Transforms/HotColdSplit/split-out-dbg-val-of-arg.ll
test/Transforms/HotColdSplit/succ-block-with-self-edge.ll
test/Transforms/HotColdSplit/unwind.ll

index 924a7d5fbd9c53783c64059310fa90c65aa18f73..d0f3fdf0c6035b8817853d8a6abbca5438e4eb17 100644 (file)
@@ -69,9 +69,9 @@ static cl::opt<bool> EnableStaticAnalyis("hot-cold-static-analysis",
                               cl::init(true), cl::Hidden);
 
 static cl::opt<int>
-    MinOutliningThreshold("min-outlining-thresh", cl::init(3), cl::Hidden,
-                          cl::desc("Code size threshold for outlining within a "
-                                   "single BB (as a multiple of TCC_Basic)"));
+    SplittingThreshold("hotcoldsplit-threshold", cl::init(3), cl::Hidden,
+                       cl::desc("Code size threshold for splitting cold code "
+                                "(as a multiple of TCC_Basic)"));
 
 namespace {
 
@@ -131,6 +131,11 @@ static bool mayExtractBlock(const BasicBlock &BB) {
 /// Check whether \p Region is profitable to outline.
 static bool isProfitableToOutline(const BlockSequence &Region,
                                   TargetTransformInfo &TTI) {
+  // If the splitting threshold is set at or below zero, skip the usual
+  // profitability check.
+  if (SplittingThreshold <= 0)
+    return true;
+
   if (Region.size() > 1)
     return true;
 
@@ -142,7 +147,7 @@ static bool isProfitableToOutline(const BlockSequence &Region,
 
     Cost += TTI.getInstructionCost(&I, TargetTransformInfo::TCK_CodeSize);
 
-    if (Cost >= (MinOutliningThreshold * TargetTransformInfo::TCC_Basic))
+    if (Cost >= (SplittingThreshold * TargetTransformInfo::TCC_Basic))
       return true;
   }
   return false;
similarity index 94%
rename from test/Transforms/HotColdSplit/do-not-split.ll
rename to test/Transforms/HotColdSplit/X86/do-not-split.ll
index d5a8c44cc04f2b06a9eb00672e7d74fb47d81d50..8622f03b2eddeab7debff864ede2542c86b7c18b 100644 (file)
@@ -1,5 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
-; RUN: opt -passes=hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=2 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -29,7 +28,6 @@ entry:
   br i1 undef, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
-  call void @sink()
   call void @sink()
   ret void
 
@@ -59,8 +57,6 @@ entry:
   br label %loop
 
 loop:
-  call void @sink()
-  call void @sink()
   call void @sink()
   br label %loop
 }
similarity index 97%
rename from test/Transforms/HotColdSplit/extraction-subregion-breaks-phis.ll
rename to test/Transforms/HotColdSplit/X86/extraction-subregion-breaks-phis.ll
index 11256a443fa70245f78c72d52b946016112eb504..9a751e3b28db7c88a5cb39a222e56f2dc7fa9e56 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=1 < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
index 5b0cceae2af321e0b35fdaab7d255e2d84fc631f..3f04283b0c1a7021fdb34ea1ecb2612b1ef2ab5f 100644 (file)
@@ -1,5 +1,5 @@
 ; The magic number 6 comes from (1 * TCC_Expensive) + (1 * CostOfCallX86).
-; RUN: opt -hotcoldsplit -min-outlining-thresh=6 -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=6 -S < %s | FileCheck %s
 
 ; Test that we outline even though there are only two cold instructions. TTI
 ; should determine that they are expensive in terms of code size.
index 878db4863807591dbbb409f20f53b502415f6cde..97f5cb8ba6c6dd339966e23cc44a3b968b5f74a4 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -20,8 +20,6 @@ if.end:                                           ; preds = %entry
   ; We expect this block to be outlined. That kills the definition of %var.
   %var = add i32 0, 0, !dbg !11
   call void @sink()
-  call void @sink()
-  call void @sink()
   br label %cleanup
 
 cleanup:
index 5b697727e7d36c5f21d88b0798c92cd5459e45f7..da3468a7cc86eab37015182bad1180e6143f8e38 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
index 1197a54bc32f9b27a110b2dca1e5275953408485..caf02e9002d10975f29cb1e8d35122d3bfa5c9a0 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -17,7 +17,6 @@ exception:
 
 continue_exception:
   call void @sideeffect(i32 0)
-  call void @sideeffect(i32 1)
   call void @sink()
   ret void
 
@@ -44,17 +43,19 @@ continue:
 exception:
   ; Note: EH pads are not candidates for region entry points.
   %cleanup = landingpad i8 cleanup
-  ret void
+  br label %trivial-eh-handler
+
+trivial-eh-handler:
+  call void @sideeffect(i32 1)
+  br label %normal
 
 normal:
   call void @sideeffect(i32 0)
-  call void @sideeffect(i32 1)
   ret void
 }
 
 ; CHECK-LABEL: define {{.*}}@foo.cold.1(
 ; CHECK: sideeffect(i32 0)
-; CHECK: sideeffect(i32 1)
 ; CHECK: sink
 
 declare void @sideeffect(i32)
index 75f9e672332e21eef0fece6f7efffe3df16507e8..87a5bcc9131eac447cf177d3969d55875def3383 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 ; Do not outline calls to @llvm.eh.typeid.for. See llvm.org/PR39545.
 
@@ -16,8 +16,6 @@ if.then:
 if.else:
   %t = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*))
   call void @sink()
-  call void @sink()
-  call void @sink()
   ret void
 }
 
index 81a8f4231593440ef6a5970b8844d9d1a70fd24f..3c0f93b0985c961b960815a43d8a87892889db65 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
index c6482f823b4d02ec716c961ef247c82713183125..d46ef784fd650fef626377150665bc63fc730461 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s 2>&1 | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s 2>&1 | FileCheck %s
 
 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
 
index d8bd55e46dc9cd456ae9c07250d30fd1115c156e..cc87f617b4f4dffbddfa0fd08ad12a7d0c62d51a 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 ; Source:
 ; 
index 69cd0979b94596c5458c85e713a693373bc27654..6955c5c79eb1791133df5f4ea265e06ac0b9aa75 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -13,8 +13,6 @@ if.then:
   ret void
 
 if.else:
-  call void @sink()
-  call void @sink()
   call void @sink()
   ret void
 }
index 2e7cf84f72e49131c3a7891f849911d51a3c15ef..c41e4f04bf36044d4dbbf40f2d675eacf924e83b 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 ; Source:
 ;
@@ -55,7 +55,6 @@ return:                                           ; preds = %exit2, %exit1
 }
 
 ; CHECK-LABEL: define {{.*}}@foo.cold.1(
-; TODO: Eliminate this unnecessary unconditional branch.
 ; CHECK: br
 ; CHECK: [[exit1Stub:.*]]:
 ; CHECK-NEXT: ret i1 true
index 66de93432b87511272531bb41ebc1cd480f133b8..ca0f58815bf430932260a60dd81b11c987e5ac48 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -33,8 +33,6 @@ define void @bar(i32) {
   br i1 %2, label %sink, label %exit
 
 sink:
-  tail call void @_Z10sideeffectv()
-  tail call void @_Z10sideeffectv()
   tail call void @_Z10sideeffectv()
   call void @llvm.trap()
   unreachable
index f3685030c1d8b136eec0f81fcaea3c41d29e05b7..8c1a1a88ecf4c0e800be43c8532bbd0d616cfee1 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -19,8 +19,6 @@ if.then:
 if.else:
   call void asm "", ""()
   call void @sink()
-  call void @sink()
-  call void @sink()
   ret void
 }
 
index d10240ab3795d410cf208fe4ee4be1d7ef490e6c..64bc94ebd545d537af708c2a05ce6031a42964a5 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s 2>&1 | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s 2>&1 | FileCheck %s
 
 ; CHECK-LABEL: define {{.*}}@fun
 ; CHECK: call {{.*}}@fun.cold.2(
index bbde7651e28121ac1da59bdf2c61fc372398dcbb..faf663c71c54c97290da8bc6d9460bf2611f27fa 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 ; Source:
 ;
index 8fd20c0cee78cc4131bbc26eb328793b1a4dc03d..0275715fc0a10b4f1814917236dd20e2bb548d3b 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 ; Source:
 ;
@@ -26,11 +26,9 @@ target triple = "x86_64-apple-macosx10.14.0"
 
 ; CHECK-LABEL: define {{.*}}@_Z3fooii.cold.1
 ; CHECK: call void @_Z10sideeffecti(i32 1)
-; CHECK: call void @_Z10sideeffecti(i32 11)
 
 ; CHECK-LABEL: define {{.*}}@_Z3fooii.cold.2
 ; CHECK: call void @_Z10sideeffecti(i32 0)
-; CHECK: call void @_Z10sideeffecti(i32 10)
 
 ; CHECK-LABEL: define {{.*}}@_Z3fooii.cold.3
 ; CHECK: call void @_Z4sinkv
@@ -50,7 +48,6 @@ define void @_Z3fooii(i32, i32) {
 
 ; <label>:8:                                      ; preds = %5
   call void @_Z10sideeffecti(i32 0)
-  call void @_Z10sideeffecti(i32 10)
   br label %14
 
 ; <label>:9:                                      ; preds = %5
@@ -60,7 +57,6 @@ define void @_Z3fooii(i32, i32) {
 
 ; <label>:12:                                     ; preds = %9
   call void @_Z10sideeffecti(i32 1)
-  call void @_Z10sideeffecti(i32 11)
   br label %14
 
 ; <label>:13:                                     ; preds = %9
index 4c4e1f9284e95723217b5af970fe3fadf6823a24..6337726ca13322364874be7d8545ed9ec337a133 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 ; Source:
 ;
index 6e8b13a31223b43fa0e47005cbc9d00302693919..cb12befcf463c61af9f99562239be9a16947e623 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -19,7 +19,6 @@ entry:
 coldbb:
   call void @sink()
   call void @sideeffect()
-  call void @sideeffect()
   br i1 undef, label %if.end, label %coldbb2
 
 coldbb2:
index 8064a545200f2ac9a1d715156ef60e58c035d41b..6ab65c069ec915752040e1505dca25521ef07ccd 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 ; Source:
 ;
@@ -8,14 +8,12 @@
 ;     if (cond1) {
 ;         if (cond2) { // This is the first cold region we visit.
 ;             sideeffect(0);
-;             sideeffect(10);
 ;             sink(0);
 ;         }
 ;
 ;         // There's a larger, overlapping cold region here. But we ignore it.
 ;         // This could be improved.
 ;         sideeffect(1);
-;         sideeffect(11);
 ;         sink(1);
 ;     }
 ; }
@@ -42,13 +40,11 @@ define void @_Z3fooii(i32, i32) {
 
 ; <label>:10:                                     ; preds = %7
   call void @_Z10sideeffecti(i32 0)
-  call void @_Z10sideeffecti(i32 10)
   call void @_Z4sinki(i32 0) #3
   br label %11
 
 ; <label>:11:                                     ; preds = %10, %7
   call void @_Z10sideeffecti(i32 1)
-  call void @_Z10sideeffecti(i32 11)
   call void @_Z4sinki(i32 1) #3
   br label %12
 
@@ -58,7 +54,6 @@ define void @_Z3fooii(i32, i32) {
 
 ; CHECK-LABEL: define {{.*}}@_Z3fooii.cold.1
 ; CHECK: call void @_Z10sideeffecti(i32 0)
-; CHECK: call void @_Z10sideeffecti(i32 10)
 
 declare void @_Z10sideeffecti(i32)
 
index 66c6fbb1b8d3cbf0a8a820472b95416c609b2035..0ce1681793075f03976af1c31e55a8b92e8c829e 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: opt -hotcoldsplit -pass-remarks=hotcoldsplit -S < %s 2>&1 | FileCheck %s
-; RUN: opt -passes=hotcoldsplit -pass-remarks=hotcoldsplit -S < %s 2>&1 | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -pass-remarks=hotcoldsplit -S < %s 2>&1 | FileCheck %s
+; RUN: opt -hotcoldsplit-threshold=0 -passes=hotcoldsplit -pass-remarks=hotcoldsplit -S < %s 2>&1 | FileCheck %s
 
 ; Make sure this compiles. This test used to fail with an invalid phi node: the
 ; two predecessors were outlined and the SSA representation was invalid.
index becfaf8e63d3f728c6a54c0f6035b382a1f98eca..54ca19511c086cedf6b1e2c8a3ac90f23694ec10 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -17,8 +17,6 @@ if.then:                                          ; preds = %entry
 if.end:                                           ; preds = %entry
   call void @llvm.dbg.value(metadata i32 %arg1, metadata !9, metadata !DIExpression()), !dbg !11
   call void @sink()
-  call void @sink()
-  call void @sink()
   ret void
 }
 
index f8cff9e863e246b4b3101de918ba723d81658dfe..5197f4061e6d8e51a94514a591ff72da747b2bc7 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
+; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -15,7 +15,6 @@ entry:
 coldbb:
   call void @sink()
   call void @sideeffect()
-  call void @sideeffect()
   br i1 undef, label %if.end, label %coldbb2
 
 coldbb2:
@@ -39,7 +38,6 @@ entry:
 coldbb:
   call void @sink()
   call void @sideeffect()
-  call void @sideeffect()
   br i1 undef, label %if.end, label %coldbb2
 
 coldbb2:
index 4715ef2ab8676a852233c8918f433a8de77a9025..adcae98d9bb30aae145a08314acd85f8dd620c50 100644 (file)
@@ -1,4 +1,4 @@
-; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+; RUN: opt -hotcoldsplit -hotcoldsplit-threshold=0 -S < %s | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.14.0"
@@ -18,7 +18,6 @@ exception:
 
 continue_exception:
   call void @sideeffect(i32 0)
-  call void @sideeffect(i32 1)
   call void @sink()
   resume i32 undef