Fix for PR14739. It's not safe to fold a load into a call across a store. Thanks...
[oota-llvm.git] / lib / Target / X86 / X86ISelDAGToDAG.cpp
index c1eaa0e654c481bae11e56d454a5da5e1523aa0c..935f9bd715fd1c60ad38e477d66e315af1287095 100644 (file)
@@ -420,6 +420,11 @@ static bool isCalleeLoad(SDValue Callee, SDValue &Chain, bool HasCallSeq) {
 
   if (!Chain.getNumOperands())
     return false;
+  // Since we are not checking for AA here, conservatively abort if the chain
+  // writes to memory. It's not safe to move the callee (a load) across a store.
+  if (isa<MemSDNode>(Chain.getNode()) &&
+      cast<MemSDNode>(Chain.getNode())->writeMem())
+    return false;
   if (Chain.getOperand(0).getNode() == Callee.getNode())
     return true;
   if (Chain.getOperand(0).getOpcode() == ISD::TokenFactor &&