Skip to content

Commit d9d33cb

Browse files
[EVM][InlineCost] When BB is unreachable-terminated allow inlining
For EVM, to return from the contract we are using different instructions (e.g. return, revert) which are followed by unreachable. In the Inliner heuristic, if BB is unreachable-terminated threshold is set to 0 and these callsites are unlikely to be inlined. Instead, add small threshold and continue to calculate cost model, since in some cases we benefit from inlining. Signed-off-by: Vladimir Radosavljevic <[email protected]>
1 parent 2fe3694 commit d9d33cb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,13 @@ InlineCostCallAnalyzer::getHotCallSiteThreshold(CallBase &Call,
19111911
void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
19121912
// If no size growth is allowed for this inlining, set Threshold to 0.
19131913
if (!allowSizeGrowth(Call)) {
1914-
Threshold = 0;
1915-
return;
1914+
if (Triple(Call.getFunction()->getParent()->getTargetTriple()).isEVM()) {
1915+
constexpr int UnreachableThreshold = 10;
1916+
Threshold = std::min(Threshold, UnreachableThreshold);
1917+
} else {
1918+
Threshold = 0;
1919+
return;
1920+
}
19161921
}
19171922

19181923
Function *Caller = Call.getCaller();

0 commit comments

Comments
 (0)