if (*AI == &F) return false; // Passes the function into itself
if (!ArgumentConstants[i].second) {
- if (isa<Constant>(*AI) || isa<GlobalValue>(*AI)) {
+ if (isa<Constant>(*AI)) {
Constant *C = dyn_cast<Constant>(*AI);
- if (!C) C = ConstantPointerRef::get(cast<GlobalValue>(*AI));
if (!ArgumentConstants[i].first)
ArgumentConstants[i].first = C;
if (!ArgumentConstants[i].second && !AI->use_empty()) {
assert(ArgumentConstants[i].first && "Unknown constant value!");
Value *V = ArgumentConstants[i].first;
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
- V = CPR->getValue();
-
AI->replaceAllUsesWith(V);
++NumArgumentsProped;
MadeChange = true;
Instruction &Inst = cast<Instruction>(**UI);
bool AllOperandsConstant = true;
for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i)
- if (!isa<Constant>(Inst.getOperand(i)) &&
- !isa<GlobalValue>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {
+ if (!isa<Constant>(Inst.getOperand(i)) && Inst.getOperand(i) != V) {
AllOperandsConstant = false;
break;
}
// 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
// away with this information.
- } else if (isa<Constant>(I) || isa<GlobalVariable>(I)) {
+ } else if (isa<Constant>(I)) {
if (ArgNo < CalleeFI.ArgumentWeights.size())
InlineCost -= CalleeFI.ArgumentWeights[ArgNo].ConstantWeight;
}
VN.getEqualNumberNodes(AI, EqualValues);
if (!EqualValues.empty()) {
for (unsigned i = 0, e = EqualValues.size(); i != e; ++i)
- if (isa<Constant>(EqualValues[i]) ||
- isa<GlobalValue>(EqualValues[i])) {
+ if (isa<Constant>(EqualValues[i])) {
AI->replaceAllUsesWith(EqualValues[i]);
++NumArgsRepl;
Changed = true;
// If we are not replacing the instruction with a constant, we cannot do
// anything special.
- if (!isa<Constant>(V)) {
+ if (!isa<Constant>(V) || isa<GlobalValue>(V)) {
I->replaceAllUsesWith(V);
if (InvokeInst *II = dyn_cast<InvokeInst>(I)) {
if (cast<LoadInst>(I)->isVolatile())
return false;
if (!isa<AllocaInst>(I->getOperand(0)) &&
- !isa<Constant>(I->getOperand(0)) &&
- !isa<GlobalValue>(I->getOperand(0)))
+ !isa<Constant>(I->getOperand(0)))
return false;
// Finally, we have to check to make sure there are no instructions