From: Vedant Kumar Date: Thu, 17 Jan 2019 21:29:34 +0000 (+0000) Subject: [HotColdSplit] Simplify tests by lowering their splitting thresholds X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c24b6f7e25801d6a3ad89b6592b29d139fb9d98;p=llvm [HotColdSplit] Simplify tests by lowering their splitting thresholds 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 --- diff --git a/lib/Transforms/IPO/HotColdSplitting.cpp b/lib/Transforms/IPO/HotColdSplitting.cpp index 924a7d5fbd9..d0f3fdf0c60 100644 --- a/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/lib/Transforms/IPO/HotColdSplitting.cpp @@ -69,9 +69,9 @@ static cl::opt EnableStaticAnalyis("hot-cold-static-analysis", cl::init(true), cl::Hidden); static cl::opt - 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; diff --git a/test/Transforms/HotColdSplit/do-not-split.ll b/test/Transforms/HotColdSplit/X86/do-not-split.ll similarity index 94% rename from test/Transforms/HotColdSplit/do-not-split.ll rename to test/Transforms/HotColdSplit/X86/do-not-split.ll index d5a8c44cc04..8622f03b2ed 100644 --- a/test/Transforms/HotColdSplit/do-not-split.ll +++ b/test/Transforms/HotColdSplit/X86/do-not-split.ll @@ -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 } diff --git a/test/Transforms/HotColdSplit/extraction-subregion-breaks-phis.ll b/test/Transforms/HotColdSplit/X86/extraction-subregion-breaks-phis.ll 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 11256a443fa..9a751e3b28d 100644 --- a/test/Transforms/HotColdSplit/extraction-subregion-breaks-phis.ll +++ b/test/Transforms/HotColdSplit/X86/extraction-subregion-breaks-phis.ll @@ -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" diff --git a/test/Transforms/HotColdSplit/X86/outline-expensive.ll b/test/Transforms/HotColdSplit/X86/outline-expensive.ll index 5b0cceae2af..3f04283b0c1 100644 --- a/test/Transforms/HotColdSplit/X86/outline-expensive.ll +++ b/test/Transforms/HotColdSplit/X86/outline-expensive.ll @@ -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. diff --git a/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll b/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll index 878db486380..97f5cb8ba6c 100644 --- a/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll +++ b/test/Transforms/HotColdSplit/delete-use-without-def-dbg-val.ll @@ -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: diff --git a/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll b/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll index 5b697727e7d..da3468a7cc8 100644 --- a/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll +++ b/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll @@ -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" diff --git a/test/Transforms/HotColdSplit/eh-pads.ll b/test/Transforms/HotColdSplit/eh-pads.ll index 1197a54bc32..caf02e9002d 100644 --- a/test/Transforms/HotColdSplit/eh-pads.ll +++ b/test/Transforms/HotColdSplit/eh-pads.ll @@ -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) diff --git a/test/Transforms/HotColdSplit/eh-typeid-for.ll b/test/Transforms/HotColdSplit/eh-typeid-for.ll index 75f9e672332..87a5bcc9131 100644 --- a/test/Transforms/HotColdSplit/eh-typeid-for.ll +++ b/test/Transforms/HotColdSplit/eh-typeid-for.ll @@ -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 } diff --git a/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll b/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll index 81a8f423159..3c0f93b0985 100644 --- a/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll +++ b/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll @@ -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" diff --git a/test/Transforms/HotColdSplit/lifetime-markers-on-inputs.ll b/test/Transforms/HotColdSplit/lifetime-markers-on-inputs.ll index c6482f823b4..d46ef784fd6 100644 --- a/test/Transforms/HotColdSplit/lifetime-markers-on-inputs.ll +++ b/test/Transforms/HotColdSplit/lifetime-markers-on-inputs.ll @@ -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) diff --git a/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll b/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll index d8bd55e46dc..cc87f617b4f 100644 --- a/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll +++ b/test/Transforms/HotColdSplit/mark-the-whole-func-cold.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -hotcoldsplit < %s | FileCheck %s +; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s ; Source: ; diff --git a/test/Transforms/HotColdSplit/minsize.ll b/test/Transforms/HotColdSplit/minsize.ll index 69cd0979b94..6955c5c79eb 100644 --- a/test/Transforms/HotColdSplit/minsize.ll +++ b/test/Transforms/HotColdSplit/minsize.ll @@ -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 } diff --git a/test/Transforms/HotColdSplit/multiple-exits.ll b/test/Transforms/HotColdSplit/multiple-exits.ll index 2e7cf84f72e..c41e4f04bf3 100644 --- a/test/Transforms/HotColdSplit/multiple-exits.ll +++ b/test/Transforms/HotColdSplit/multiple-exits.ll @@ -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 diff --git a/test/Transforms/HotColdSplit/noreturn.ll b/test/Transforms/HotColdSplit/noreturn.ll index 66de93432b8..ca0f58815bf 100644 --- a/test/Transforms/HotColdSplit/noreturn.ll +++ b/test/Transforms/HotColdSplit/noreturn.ll @@ -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 diff --git a/test/Transforms/HotColdSplit/outline-cold-asm.ll b/test/Transforms/HotColdSplit/outline-cold-asm.ll index f3685030c1d..8c1a1a88ecf 100644 --- a/test/Transforms/HotColdSplit/outline-cold-asm.ll +++ b/test/Transforms/HotColdSplit/outline-cold-asm.ll @@ -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 } diff --git a/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll b/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll index d10240ab379..64bc94ebd54 100644 --- a/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll +++ b/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll @@ -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( diff --git a/test/Transforms/HotColdSplit/outline-if-then-else.ll b/test/Transforms/HotColdSplit/outline-if-then-else.ll index bbde7651e28..faf663c71c5 100644 --- a/test/Transforms/HotColdSplit/outline-if-then-else.ll +++ b/test/Transforms/HotColdSplit/outline-if-then-else.ll @@ -1,4 +1,4 @@ -; RUN: opt -S -hotcoldsplit < %s | FileCheck %s +; RUN: opt -S -hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s ; Source: ; diff --git a/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll b/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll index 8fd20c0cee7..0275715fc0a 100644 --- a/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll +++ b/test/Transforms/HotColdSplit/outline-multiple-entry-region.ll @@ -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) { ;