Don't modify MO while use_iterator is still pointing to it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@161626 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2012-08-09 22:08:24 +00:00
parent 3246176838
commit 69a0aa87f8
2 changed files with 5 additions and 3 deletions

View File

@ -242,13 +242,14 @@ bool MipsDAGToDAGISel::ReplaceUsesWithZeroReg(MachineRegisterInfo *MRI,
// Replace uses with ZeroReg.
for (MachineRegisterInfo::use_iterator U = MRI->use_begin(DstReg),
E = MRI->use_end(); U != E; ++U) {
E = MRI->use_end(); U != E;) {
MachineOperand &MO = U.getOperand();
unsigned OpNo = U.getOperandNo();
MachineInstr *MI = MO.getParent();
++U;
// Do not replace if it is a phi's operand or is tied to def operand.
if (MI->isPHI() || MI->isRegTiedToDefOperand(U.getOperandNo()) ||
MI->isPseudo())
if (MI->isPHI() || MI->isRegTiedToDefOperand(OpNo) || MI->isPseudo())
continue;
MO.setReg(ZeroReg);

View File

@ -4,6 +4,7 @@
define void @zero_u(%struct.unaligned* nocapture %p) nounwind {
entry:
; CHECK: swl $zero
; CHECK: swr $zero
%x = getelementptr inbounds %struct.unaligned* %p, i32 0, i32 0
store i32 0, i32* %x, align 1