Index: llvm/lib/Target/X86/X86CallFrameOptimization.cpp =================================================================== --- llvm/lib/Target/X86/X86CallFrameOptimization.cpp +++ llvm/lib/Target/X86/X86CallFrameOptimization.cpp @@ -562,6 +562,7 @@ unsigned NumOps = DefMov->getDesc().getNumOperands(); for (unsigned i = NumOps - X86::AddrNumOperands; i != NumOps; ++i) Push->addOperand(DefMov->getOperand(i)); + Push->cloneMergedMemRefs(MF, {&*DefMov, &*Store}); DefMov->eraseFromParent(); } else { @@ -569,6 +570,7 @@ Push = BuildMI(MBB, Context.Call, DL, TII->get(PushOpcode)) .addReg(Reg) .getInstr(); + Push->cloneMemRefs(MF, *Store); } break; } Index: llvm/lib/Target/X86/X86ISelDAGToDAG.cpp =================================================================== --- llvm/lib/Target/X86/X86ISelDAGToDAG.cpp +++ llvm/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -1393,6 +1393,8 @@ And.getOperand(6) /* Chain */ }; MachineSDNode *Test = CurDAG->getMachineNode(NewOpc, SDLoc(N), MVT::i32, MVT::Other, Ops); + CurDAG->setNodeMemRefs( + Test, cast(And.getNode())->memoperands()); ReplaceUses(N, Test); MadeChange = true; continue;