mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-31 10:34:17 +00:00
bug 122:
- Minimize redundant isa<GlobalValue> usage git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14948 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
21cb67e16a
commit
460f16c625
@ -82,9 +82,8 @@ bool IPCP::processFunction(Function &F) {
|
|||||||
if (*AI == &F) return false; // Passes the function into itself
|
if (*AI == &F) return false; // Passes the function into itself
|
||||||
|
|
||||||
if (!ArgumentConstants[i].second) {
|
if (!ArgumentConstants[i].second) {
|
||||||
if (isa<Constant>(*AI) || isa<GlobalValue>(*AI)) {
|
if (isa<Constant>(*AI)) {
|
||||||
Constant *C = dyn_cast<Constant>(*AI);
|
Constant *C = dyn_cast<Constant>(*AI);
|
||||||
if (!C) C = ConstantPointerRef::get(cast<GlobalValue>(*AI));
|
|
||||||
|
|
||||||
if (!ArgumentConstants[i].first)
|
if (!ArgumentConstants[i].first)
|
||||||
ArgumentConstants[i].first = C;
|
ArgumentConstants[i].first = C;
|
||||||
@ -114,9 +113,6 @@ bool IPCP::processFunction(Function &F) {
|
|||||||
if (!ArgumentConstants[i].second && !AI->use_empty()) {
|
if (!ArgumentConstants[i].second && !AI->use_empty()) {
|
||||||
assert(ArgumentConstants[i].first && "Unknown constant value!");
|
assert(ArgumentConstants[i].first && "Unknown constant value!");
|
||||||
Value *V = ArgumentConstants[i].first;
|
Value *V = ArgumentConstants[i].first;
|
||||||
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
|
|
||||||
V = CPR->getValue();
|
|
||||||
|
|
||||||
AI->replaceAllUsesWith(V);
|
AI->replaceAllUsesWith(V);
|
||||||
++NumArgumentsProped;
|
++NumArgumentsProped;
|
||||||
MadeChange = true;
|
MadeChange = true;
|
||||||
|
@ -78,8 +78,7 @@ static unsigned CountCodeReductionForConstant(Value *V) {
|
|||||||
Instruction &Inst = cast<Instruction>(**UI);
|
Instruction &Inst = cast<Instruction>(**UI);
|
||||||
bool AllOperandsConstant = true;
|
bool AllOperandsConstant = true;
|
||||||
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i)
|
||||||
if (!isa<Constant>(Inst.getOperand(i)) &&
|
if (!isa<Constant>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {
|
||||||
!isa<GlobalValue>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {
|
|
||||||
AllOperandsConstant = false;
|
AllOperandsConstant = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205,7 +204,7 @@ int SimpleInliner::getInlineCost(CallSite CS) {
|
|||||||
// If this is a constant being passed into the function, use the argument
|
// If this is a constant being passed into the function, use the argument
|
||||||
// weights calculated for the callee to determine how much will be folded
|
// weights calculated for the callee to determine how much will be folded
|
||||||
// away with this information.
|
// away with this information.
|
||||||
} else if (isa<Constant>(I) || isa<GlobalVariable>(I)) {
|
} else if (isa<Constant>(I)) {
|
||||||
if (ArgNo < CalleeFI.ArgumentWeights.size())
|
if (ArgNo < CalleeFI.ArgumentWeights.size())
|
||||||
InlineCost -= CalleeFI.ArgumentWeights[ArgNo].ConstantWeight;
|
InlineCost -= CalleeFI.ArgumentWeights[ArgNo].ConstantWeight;
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,7 @@ bool GCSE::runOnFunction(Function &F) {
|
|||||||
VN.getEqualNumberNodes(AI, EqualValues);
|
VN.getEqualNumberNodes(AI, EqualValues);
|
||||||
if (!EqualValues.empty()) {
|
if (!EqualValues.empty()) {
|
||||||
for (unsigned i = 0, e = EqualValues.size(); i != e; ++i)
|
for (unsigned i = 0, e = EqualValues.size(); i != e; ++i)
|
||||||
if (isa<Constant>(EqualValues[i]) ||
|
if (isa<Constant>(EqualValues[i])) {
|
||||||
isa<GlobalValue>(EqualValues[i])) {
|
|
||||||
AI->replaceAllUsesWith(EqualValues[i]);
|
AI->replaceAllUsesWith(EqualValues[i]);
|
||||||
++NumArgsRepl;
|
++NumArgsRepl;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
@ -186,7 +185,7 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) {
|
|||||||
|
|
||||||
// If we are not replacing the instruction with a constant, we cannot do
|
// If we are not replacing the instruction with a constant, we cannot do
|
||||||
// anything special.
|
// anything special.
|
||||||
if (!isa<Constant>(V)) {
|
if (!isa<Constant>(V) || isa<GlobalValue>(V)) {
|
||||||
I->replaceAllUsesWith(V);
|
I->replaceAllUsesWith(V);
|
||||||
|
|
||||||
if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
|
if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
|
||||||
|
@ -211,8 +211,7 @@ static bool DominatesMergePoint(Value *V, BasicBlock *BB, bool AllowAggressive){
|
|||||||
if (cast<LoadInst>(I)->isVolatile())
|
if (cast<LoadInst>(I)->isVolatile())
|
||||||
return false;
|
return false;
|
||||||
if (!isa<AllocaInst>(I->getOperand(0)) &&
|
if (!isa<AllocaInst>(I->getOperand(0)) &&
|
||||||
!isa<Constant>(I->getOperand(0)) &&
|
!isa<Constant>(I->getOperand(0)))
|
||||||
!isa<GlobalValue>(I->getOperand(0)))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Finally, we have to check to make sure there are no instructions
|
// Finally, we have to check to make sure there are no instructions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user