[PATCH] D53518: [HotColdSplitting] Attach MinSize to outlined code
Vedant Kumar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 22 11:39:43 PDT 2018
vsk created this revision.
vsk added reviewers: hiraditya, sebpop.
Outlined code is cold by assumption, so it makes more sense to optimize
it for minimal code size versus performance.
After r344869 moved the splitting pass to the end of the IR pipeline,
this does not result in much of a code size reduction. Only a small
number backend transforms make use of the MinSize hint.
Running LNT on x86_64, I see that 33/1020 binaries shrink for a total of
919 bytes of TEXT reduction. I didn't measure a significant performance
impact.
https://reviews.llvm.org/D53518
Files:
llvm/lib/Transforms/IPO/HotColdSplitting.cpp
llvm/test/Transforms/HotColdSplit/minsize.ll
Index: llvm/test/Transforms/HotColdSplit/minsize.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/HotColdSplit/minsize.ll
@@ -0,0 +1,32 @@
+; RUN: opt -hotcoldsplit -S < %s | FileCheck %s
+
+; CHECK-LABEL: @fun
+; CHECK: codeRepl:
+; CHECK-NEXT: call void @fun_if.else
+
+define void @fun() {
+entry:
+ br i1 undef, label %if.then, label %if.else
+
+if.then:
+ ret void
+
+if.else:
+ br label %if.then4
+
+if.then4:
+ br i1 undef, label %if.then5, label %if.end
+
+if.then5:
+ br label %cleanup
+
+if.end:
+ br label %cleanup
+
+cleanup:
+ %cleanup.dest.slot.0 = phi i32 [ 1, %if.then5 ], [ 0, %if.end ]
+ unreachable
+}
+
+; CHECK: define {{.*}} @fun_if.else{{.*}}#[[outlined_func_attr:[0-9]+]]
+; CHECK: attributes #[[outlined_func_attr]] = { {{.*}}minsize
Index: llvm/lib/Transforms/IPO/HotColdSplitting.cpp
===================================================================
--- llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -358,6 +358,13 @@
CS.setCallingConv(CallingConv::Cold);
}
CI->setIsNoInline();
+
+ // Try to make the outlined code as small as possible on the assumption
+ // that it's cold.
+ assert(!OutF->hasFnAttribute(Attribute::OptimizeNone) &&
+ "An outlined function should never be marked optnone");
+ OutF->addFnAttr(Attribute::MinSize);
+
LLVM_DEBUG(llvm::dbgs() << "Outlined Region: " << *OutF);
return OutF;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53518.170462.patch
Type: text/x-patch
Size: 1508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181022/b13afeb1/attachment.bin>
More information about the llvm-commits
mailing list