summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2013-11-14 23:45:04 +0000
committerAndrew Trick <atrick@apple.com>2013-11-14 23:45:04 +0000
commita9f4d928ab3a37d8f0c3a738cdba6161bb2e1175 (patch)
tree7d423c7c95f7a0a163699842c17530448b04adf5 /llvm/lib/CodeGen
parent855e0b71d43839d6543e91dd4926f1ab18c88c93 (diff)
downloadbcm5719-llvm-a9f4d928ab3a37d8f0c3a738cdba6161bb2e1175.tar.gz
bcm5719-llvm-a9f4d928ab3a37d8f0c3a738cdba6161bb2e1175.zip
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
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/TargetInstrInfo.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 5e6162fbc31..edeca3d5b83 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -364,6 +364,7 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI,
// Ask the target to do the actual folding.
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.
assert((!(Flags & MachineMemOperand::MOStore) ||
NewMI->mayStore()) &&
@@ -424,9 +425,19 @@ TargetInstrInfo::foldMemoryOperand(MachineBasicBlock::iterator MI,
NewMI = MBB.insert(MI, NewMI);
// Copy the memoperands from the load to the folded instruction.
- NewMI->setMemRefs(LoadMI->memoperands_begin(),
- LoadMI->memoperands_end());
-
+ if (MI->memoperands_empty()) {
+ 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;
}
OpenPOWER on IntegriCloud