forked from OSchip/llvm-project
parent
6bdfbaf80d
commit
f3edc49ae2
|
@ -2456,10 +2456,8 @@ Instruction *InstCombiner::visitCallSite(CallSite CS) {
|
||||||
bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||||
if (!isa<ConstantExpr>(CS.getCalledValue())) return false;
|
if (!isa<ConstantExpr>(CS.getCalledValue())) return false;
|
||||||
ConstantExpr *CE = cast<ConstantExpr>(CS.getCalledValue());
|
ConstantExpr *CE = cast<ConstantExpr>(CS.getCalledValue());
|
||||||
if (CE->getOpcode() != Instruction::Cast ||
|
if (CE->getOpcode() != Instruction::Cast || !isa<Function>(CE->getOperand(0)))
|
||||||
!isa<GlobalValue>(CE->getOperand(0)))
|
|
||||||
return false;
|
return false;
|
||||||
if (!isa<Function>(CE->getOperand(0))) return false;
|
|
||||||
Function *Callee = cast<Function>(CE->getOperand(0));
|
Function *Callee = cast<Function>(CE->getOperand(0));
|
||||||
Instruction *Caller = CS.getInstruction();
|
Instruction *Caller = CS.getInstruction();
|
||||||
|
|
||||||
|
@ -2809,8 +2807,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) {
|
||||||
Indices.push_back(cast<Constant>(*I));
|
Indices.push_back(cast<Constant>(*I));
|
||||||
|
|
||||||
if (I == E) { // If they are all constants...
|
if (I == E) { // If they are all constants...
|
||||||
Constant *CE =
|
Constant *CE = ConstantExpr::getGetElementPtr(GV, Indices);
|
||||||
ConstantExpr::getGetElementPtr(GV, Indices);
|
|
||||||
|
|
||||||
// Replace all uses of the GEP with the new constexpr...
|
// Replace all uses of the GEP with the new constexpr...
|
||||||
return ReplaceInstUsesWith(GEP, CE);
|
return ReplaceInstUsesWith(GEP, CE);
|
||||||
|
@ -2977,8 +2974,6 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
|
||||||
if (Constant *C = dyn_cast<Constant>(Op))
|
if (Constant *C = dyn_cast<Constant>(Op))
|
||||||
if (C->isNullValue()) // load null -> 0
|
if (C->isNullValue()) // load null -> 0
|
||||||
return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType()));
|
return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType()));
|
||||||
else if (isa<GlobalValue>(C))
|
|
||||||
Op = C;
|
|
||||||
|
|
||||||
// Instcombine load (constant global) into the value loaded...
|
// Instcombine load (constant global) into the value loaded...
|
||||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
|
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
|
||||||
|
|
Loading…
Reference in New Issue