unsigned Size = ~0U;
if (!AI->isArrayAllocation() &&
AI->getType()->getElementType()->isSized())
- Size = TD.getTypeSize(AI->getType()->getElementType());
+ Size = (unsigned)TD.getTypeSize(AI->getType()->getElementType());
KillLocs.add(AI, Size);
}
}
// the stored location is already in the tracker, then this is a dead
// store. We can just delete it here, but while we're at it, we also
// delete any trivially dead expression chains.
- unsigned ValSize = TD.getTypeSize(I->getOperand(0)->getType());
+ unsigned ValSize = (unsigned)TD.getTypeSize(I->getOperand(0)->getType());
Value *Ptr = I->getOperand(1);
if (AliasSet *AS = KillLocs.getAliasSetForPointerIfExists(Ptr, ValSize))
for (AliasSet::iterator ASI = AS->begin(), E = AS->end(); ASI != E; ++ASI)
- if (AA.alias(ASI.getPointer(), ASI.getSize(), Ptr, ValSize)
+ if (ASI.getSize() >= ValSize && // Overwriting all of this store.
+ AA.alias(ASI.getPointer(), ASI.getSize(), Ptr, ValSize)
== AliasAnalysis::MustAlias) {
// If we found a must alias in the killed set, then this store really
// is dead. Remember that the various operands of the store now have
// See if this made any operands dead. We do it this way in case the
// instruction uses the same operand twice. We don't want to delete a
// value then reference it.
- while (unsigned NumOps = I->getNumOperands()) {
- Instruction *Op = dyn_cast<Instruction>(I->getOperand(NumOps-1));
- I->op_erase(I->op_end()-1); // Drop from the operand list.
-
- if (Op) DeadInsts.insert(Op); // Attempt to nuke it later.
+ for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) {
+ if (Instruction *Op = dyn_cast<Instruction>(I->getOperand(i)))
+ DeadInsts.insert(Op); // Attempt to nuke it later.
+ I->setOperand(i, 0); // Drop from the operand list.
}
- I->getParent()->getInstList().erase(I);
+ I->eraseFromParent();
++NumOther;
}