Skip to content

Commit d317fe0

Browse files
vladimirradosavljevicakiramenai
authored andcommitted
[EVM][InlineCost] Set threshold to a small value when BB is unreachable-terminated
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 7603797 commit d317fe0

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,8 +1911,15 @@ 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+
// EVM local change begin
1915+
if (Triple(Call.getFunction()->getParent()->getTargetTriple()).isEVM()) {
1916+
constexpr int UnreachableThreshold = 10;
1917+
Threshold = std::min(Threshold, UnreachableThreshold);
1918+
} else {
1919+
Threshold = 0;
1920+
return;
1921+
}
1922+
// EVM local change end
19161923
}
19171924

19181925
Function *Caller = Call.getCaller();

0 commit comments

Comments
 (0)