aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/X86
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Target/X86')
-rw-r--r--lib/Target/X86/X86InstrInfo.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp
index ffe2083322..8a5464567f 100644
--- a/lib/Target/X86/X86InstrInfo.cpp
+++ b/lib/Target/X86/X86InstrInfo.cpp
@@ -1825,7 +1825,15 @@ X86InstrInfo::foldMemoryOperand(MachineInstr *MI, unsigned i,
MI->getOperand(0).getReg() == MI->getOperand(1).getReg()) {
OpcodeTablePtr = &RegOp2MemOpTable2Addr;
isTwoAddrFold = true;
+ // Can't write back to CPI or a GV stub.
+ if (MOs[3].isCPI() ||
+ (MOs[3].isGlobal() && isGVStub(MOs[3].getGlobal(), TM)))
+ return NULL;
} else if (i == 0) { // If operand 0
+ // Can't write back to CPI or a GV stub.
+ if (MOs[3].isCPI() ||
+ (MOs[3].isGlobal() && isGVStub(MOs[3].getGlobal(), TM)))
+ return NULL;
if (MI->getOpcode() == X86::MOV16r0)
NewMI = MakeM0Inst(*this, X86::MOV16mi, MOs, MI);
else if (MI->getOpcode() == X86::MOV32r0)