Skip to content
Snippets Groups Projects
Commit a9f4d928 authored by Andrew Trick's avatar Andrew Trick
Browse files

When folding memory operands, preserve existing MachineMemOperands.

This comes into play with patchpoint, which can fold multiple
operands. Since the patchpoint is already treated as a call, the
machine mem operands won't affect anything, and there's nothing to
test. But we still want to do the right thing here to be sure that our
MIs obey the rules.

llvm-svn: 194750
parent 855e0b71
No related branches found
No related tags found
Loading
...@@ -364,6 +364,7 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI, ...@@ -364,6 +364,7 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI,
// Ask the target to do the actual folding. // Ask the target to do the actual folding.
if (MachineInstr *NewMI = foldMemoryOperandImpl(MF, MI, Ops, FI)) { if (MachineInstr *NewMI = foldMemoryOperandImpl(MF, MI, Ops, FI)) {
NewMI->setMemRefs(MI->memoperands_begin(), MI->memoperands_end());
// Add a memory operand, foldMemoryOperandImpl doesn't do that. // Add a memory operand, foldMemoryOperandImpl doesn't do that.
assert((!(Flags & MachineMemOperand::MOStore) || assert((!(Flags & MachineMemOperand::MOStore) ||
NewMI->mayStore()) && NewMI->mayStore()) &&
...@@ -424,9 +425,19 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI, ...@@ -424,9 +425,19 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI,
NewMI = MBB.insert(MI, NewMI); NewMI = MBB.insert(MI, NewMI);
// Copy the memoperands from the load to the folded instruction. // Copy the memoperands from the load to the folded instruction.
NewMI->setMemRefs(LoadMI->memoperands_begin(), if (MI->memoperands_empty()) {
LoadMI->memoperands_end()); NewMI->setMemRefs(LoadMI->memoperands_begin(),
LoadMI->memoperands_end());
}
else {
// Handle the rare case of folding multiple loads.
NewMI->setMemRefs(MI->memoperands_begin(),
MI->memoperands_end());
for (MachineInstr::mmo_iterator I = LoadMI->memoperands_begin(),
E = LoadMI->memoperands_end(); I != E; ++I) {
NewMI->addMemOperand(MF, *I);
}
}
return NewMI; return NewMI;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment