diff options
author | Vedant Kumar <vsk@apple.com> | 2018-10-23 19:41:12 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-10-23 19:41:12 +0000 |
commit | 503154615dac70491fef4797da6b35761320aaa1 (patch) | |
tree | 918f593721da57c2eea4c75be662b4dfbcfa52e8 /llvm/lib/Transforms/IPO/HotColdSplitting.cpp | |
parent | 551a9585ce5c8e1e2afa5cbd8dc7a7c4fe5fdb85 (diff) | |
download | bcm5719-llvm-503154615dac70491fef4797da6b35761320aaa1.tar.gz bcm5719-llvm-503154615dac70491fef4797da6b35761320aaa1.zip |
[HotColdSplitting] Attach MinSize to outlined code
Outlined code is cold by assumption, so it makes sense to optimize it
for minimal code size rather than 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. This is probably
because a comparatively 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.
Differential Revision: https://reviews.llvm.org/D53518
llvm-svn: 345072
Diffstat (limited to 'llvm/lib/Transforms/IPO/HotColdSplitting.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/HotColdSplitting.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp index 1d804ccb767..d3e086e972a 100644 --- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp +++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp @@ -360,6 +360,13 @@ HotColdSplitting::extractColdRegion(const SmallVectorImpl<BasicBlock *> &Region, 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); ORE.emit([&]() { return OptimizationRemark(DEBUG_TYPE, "HotColdSplit", |