mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-26 21:20:37 +00:00
Final step of instcombine debuginfo; switch a couple more places over to InsertNewInstWith, and use setDebugLoc for the cases which can't be easily handled by the automated mechanisms.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132167 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b29c1d731a
commit
a311c34d2a
@ -1130,6 +1130,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||
Instruction::CastOps opcode =
|
||||
CastInst::getCastOpcode(NC, false, OldRetTy, false);
|
||||
NV = NC = CastInst::Create(opcode, NC, OldRetTy, "tmp");
|
||||
NC->setDebugLoc(Caller->getDebugLoc());
|
||||
|
||||
// If this is an invoke instruction, we should insert it after the first
|
||||
// non-phi, instruction in the normal successor block.
|
||||
|
@ -211,7 +211,7 @@ Value *InstCombiner::EvaluateInDifferentType(Value *V, const Type *Ty,
|
||||
}
|
||||
|
||||
Res->takeName(I);
|
||||
return InsertNewInstBefore(Res, *I);
|
||||
return InsertNewInstWith(Res, *I);
|
||||
}
|
||||
|
||||
|
||||
|
@ -602,10 +602,12 @@ bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) {
|
||||
// Advance to a place where it is safe to insert the new store and
|
||||
// insert it.
|
||||
BBI = DestBB->getFirstNonPHI();
|
||||
InsertNewInstBefore(new StoreInst(MergedVal, SI.getOperand(1),
|
||||
OtherStore->isVolatile(),
|
||||
SI.getAlignment()), *BBI);
|
||||
|
||||
StoreInst *NewSI = new StoreInst(MergedVal, SI.getOperand(1),
|
||||
OtherStore->isVolatile(),
|
||||
SI.getAlignment());
|
||||
InsertNewInstBefore(NewSI, *BBI);
|
||||
NewSI->setDebugLoc(OtherStore->getDebugLoc());
|
||||
|
||||
// Nuke the old stores.
|
||||
EraseInstFromFunction(SI);
|
||||
EraseInstFromFunction(*OtherStore);
|
||||
|
@ -110,16 +110,20 @@ Instruction *InstCombiner::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
||||
}
|
||||
}
|
||||
|
||||
if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst))
|
||||
return CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(),
|
||||
LHSVal, RHSVal);
|
||||
|
||||
if (CmpInst *CIOp = dyn_cast<CmpInst>(FirstInst)) {
|
||||
CmpInst *NewCI = CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(),
|
||||
LHSVal, RHSVal);
|
||||
NewCI->setDebugLoc(FirstInst->getDebugLoc());
|
||||
return NewCI;
|
||||
}
|
||||
|
||||
BinaryOperator *BinOp = cast<BinaryOperator>(FirstInst);
|
||||
BinaryOperator *NewBinOp =
|
||||
BinaryOperator::Create(BinOp->getOpcode(), LHSVal, RHSVal);
|
||||
if (isNUW) NewBinOp->setHasNoUnsignedWrap();
|
||||
if (isNSW) NewBinOp->setHasNoSignedWrap();
|
||||
if (isExact) NewBinOp->setIsExact();
|
||||
NewBinOp->setDebugLoc(FirstInst->getDebugLoc());
|
||||
return NewBinOp;
|
||||
}
|
||||
|
||||
@ -228,6 +232,7 @@ Instruction *InstCombiner::FoldPHIArgGEPIntoPHI(PHINode &PN) {
|
||||
GetElementPtrInst::Create(Base, FixedOperands.begin()+1,
|
||||
FixedOperands.end());
|
||||
if (AllInBounds) NewGEP->setIsInBounds();
|
||||
NewGEP->setDebugLoc(FirstInst->getDebugLoc());
|
||||
return NewGEP;
|
||||
}
|
||||
|
||||
@ -369,7 +374,9 @@ Instruction *InstCombiner::FoldPHIArgLoadIntoPHI(PHINode &PN) {
|
||||
for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
|
||||
cast<LoadInst>(PN.getIncomingValue(i))->setVolatile(false);
|
||||
|
||||
return new LoadInst(PhiVal, "", isVolatile, LoadAlignment);
|
||||
LoadInst *NewLI = new LoadInst(PhiVal, "", isVolatile, LoadAlignment);
|
||||
NewLI->setDebugLoc(FirstLI->getDebugLoc());
|
||||
return NewLI;
|
||||
}
|
||||
|
||||
|
||||
@ -469,20 +476,27 @@ Instruction *InstCombiner::FoldPHIArgOpIntoPHI(PHINode &PN) {
|
||||
}
|
||||
|
||||
// Insert and return the new operation.
|
||||
if (CastInst *FirstCI = dyn_cast<CastInst>(FirstInst))
|
||||
return CastInst::Create(FirstCI->getOpcode(), PhiVal, PN.getType());
|
||||
if (CastInst *FirstCI = dyn_cast<CastInst>(FirstInst)) {
|
||||
CastInst *NewCI = CastInst::Create(FirstCI->getOpcode(), PhiVal,
|
||||
PN.getType());
|
||||
NewCI->setDebugLoc(FirstInst->getDebugLoc());
|
||||
return NewCI;
|
||||
}
|
||||
|
||||
if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(FirstInst)) {
|
||||
BinOp = BinaryOperator::Create(BinOp->getOpcode(), PhiVal, ConstantOp);
|
||||
if (isNUW) BinOp->setHasNoUnsignedWrap();
|
||||
if (isNSW) BinOp->setHasNoSignedWrap();
|
||||
if (isExact) BinOp->setIsExact();
|
||||
BinOp->setDebugLoc(FirstInst->getDebugLoc());
|
||||
return BinOp;
|
||||
}
|
||||
|
||||
CmpInst *CIOp = cast<CmpInst>(FirstInst);
|
||||
return CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(),
|
||||
PhiVal, ConstantOp);
|
||||
CmpInst *NewCI = CmpInst::Create(CIOp->getOpcode(), CIOp->getPredicate(),
|
||||
PhiVal, ConstantOp);
|
||||
NewCI->setDebugLoc(FirstInst->getDebugLoc());
|
||||
return NewCI;
|
||||
}
|
||||
|
||||
/// DeadPHICycle - Return true if this PHI node is only used by a PHI node cycle
|
||||
|
@ -241,7 +241,7 @@ bool InstCombiner::SimplifyAssociativeOrCommutative(BinaryOperator &I) {
|
||||
|
||||
Constant *Folded = ConstantExpr::get(Opcode, C1, C2);
|
||||
Instruction *New = BinaryOperator::Create(Opcode, A, B);
|
||||
InsertNewInstBefore(New, I);
|
||||
InsertNewInstWith(New, I);
|
||||
New->takeName(Op1);
|
||||
I.setOperand(0, New);
|
||||
I.setOperand(1, Folded);
|
||||
@ -1591,7 +1591,8 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
|
||||
DEBUG(errs() << "IC: Old = " << *I << '\n'
|
||||
<< " New = " << *Result << '\n');
|
||||
|
||||
Result->setDebugLoc(I->getDebugLoc());
|
||||
if (!I->getDebugLoc().isUnknown())
|
||||
Result->setDebugLoc(I->getDebugLoc());
|
||||
// Everything uses the new instruction now.
|
||||
I->replaceAllUsesWith(Result);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user