mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-01 00:33:09 +00:00
Only apply the devirtualization bonus once instead of per-call site in the
target function. Fixes part of rdar://8546196 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124044 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8184e289db
commit
7020f12ee8
@ -146,17 +146,18 @@ void CodeMetrics::analyzeBasicBlock(const BasicBlock *BB) {
|
|||||||
// performance boost we can expect if the specified value is constant.
|
// performance boost we can expect if the specified value is constant.
|
||||||
unsigned CodeMetrics::CountBonusForConstant(Value *V) {
|
unsigned CodeMetrics::CountBonusForConstant(Value *V) {
|
||||||
unsigned Bonus = 0;
|
unsigned Bonus = 0;
|
||||||
|
bool indirectCallBonus = false;
|
||||||
for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){
|
for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){
|
||||||
User *U = *UI;
|
User *U = *UI;
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(U)) {
|
if (CallInst *CI = dyn_cast<CallInst>(U)) {
|
||||||
// Turning an indirect call into a direct call is a BIG win
|
// Turning an indirect call into a direct call is a BIG win
|
||||||
if (CI->getCalledValue() == V)
|
if (CI->getCalledValue() == V)
|
||||||
Bonus += InlineConstants::IndirectCallBonus;
|
indirectCallBonus = true;
|
||||||
}
|
}
|
||||||
else if (InvokeInst *II = dyn_cast<InvokeInst>(U)) {
|
else if (InvokeInst *II = dyn_cast<InvokeInst>(U)) {
|
||||||
// Turning an indirect call into a direct call is a BIG win
|
// Turning an indirect call into a direct call is a BIG win
|
||||||
if (II->getCalledValue() == V)
|
if (II->getCalledValue() == V)
|
||||||
Bonus += InlineConstants::IndirectCallBonus;
|
indirectCallBonus = true;
|
||||||
}
|
}
|
||||||
// FIXME: Eliminating conditional branches and switches should
|
// FIXME: Eliminating conditional branches and switches should
|
||||||
// also yield a per-call performance boost.
|
// also yield a per-call performance boost.
|
||||||
@ -187,6 +188,9 @@ unsigned CodeMetrics::CountBonusForConstant(Value *V) {
|
|||||||
Bonus += CountBonusForConstant(&Inst);
|
Bonus += CountBonusForConstant(&Inst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (indirectCallBonus) Bonus += InlineConstants::IndirectCallBonus;
|
||||||
|
|
||||||
return Bonus;
|
return Bonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user