[PATCH] D31137: [Inliner] Update Inliner code not to subtract CallPenalty twice
Evgeny Astigeevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 20 09:55:01 PDT 2017
eastig created this revision.
Revision 286814 introduced:
--- llvm/trunk/lib/Analysis/InlineCost.cpp 2016/10/10 21:47:28 283805
+++ llvm/trunk/lib/Analysis/InlineCost.cpp 2016/11/14 11:14:41 286814
@@ -1255,7 +1255,9 @@
Cost -= InlineConstants::InstrCost;
}
}
-
+ // The call instruction also disappears after inlining.
+ Cost -= InlineConstants::InstrCost + InlineConstants::CallPenalty;
+
// If there is only one call of the function, and it has internal linkage,
// the cost of inlining it drops dramatically.
bool OnlyOneCallAndLocalLinkage =
But the patch did not update Inliner code:
shouldBeDeferred(Function *Caller, CallSite CS, InlineCost IC,
...
// FIXME: All of this logic should be sunk into getInlineCost. It relies on
// FIXME: All of this logic should be sunk into getInlineCost. It relies on
// the internal implementation of the inline cost metrics rather than
// treating them as truly abstract units etc.
TotalSecondaryCost = 0;
// The candidate cost to be imposed upon the current function.
int CandidateCost = IC.getCost() - (InlineConstants::CallPenalty + 1);
As a result CallPenalty is subtracted twice.
The current patch fixes the issue.
I'd like to thank Easwaran who noticed the issue.
https://reviews.llvm.org/D31137
Files:
lib/Transforms/IPO/Inliner.cpp
Index: lib/Transforms/IPO/Inliner.cpp
===================================================================
--- lib/Transforms/IPO/Inliner.cpp
+++ lib/Transforms/IPO/Inliner.cpp
@@ -289,7 +289,7 @@
// treating them as truly abstract units etc.
TotalSecondaryCost = 0;
// The candidate cost to be imposed upon the current function.
- int CandidateCost = IC.getCost() - (InlineConstants::CallPenalty + 1);
+ int CandidateCost = IC.getCost() - 1;
// This bool tracks what happens if we do NOT inline C into B.
bool callerWillBeRemoved = Caller->hasLocalLinkage();
// This bool tracks what happens if we DO inline C into B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31137.92342.patch
Type: text/x-patch
Size: 638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170320/ba02fe77/attachment.bin>
More information about the llvm-commits
mailing list