================
@@ -3187,6 +3194,45 @@ static void adjustICmpTruncate(SelectionDAG &DAG, const 
SDLoc &DL,
   }
 }
 
+// Adjust if a given Compare is a check of the stack guard against a stack
+// guard instance on the stack. Specifically, this checks if:
+// - The operands are a load of the stack guard, and a load from a stack slot
+// - Those operand values are not used elsewhere <-- asserts if this is not
+//   true!
+static void adjustForStackGuardCompare(SelectionDAG &DAG, const SDLoc &DL,
+                                       Comparison &C) {
+  SDValue StackGuardLoad;
+  LoadSDNode *FILoad;
+
+  if (C.Op0.isMachineOpcode() &&
+      C.Op0.getMachineOpcode() == SystemZ::LOAD_STACK_GUARD &&
+      ISD::isNormalLoad(C.Op1.getNode()) &&
+      dyn_cast<FrameIndexSDNode>(C.Op1.getOperand(1))) {
+    StackGuardLoad = C.Op0;
+    FILoad = cast<LoadSDNode>(C.Op1);
+  } else if ((C.Op1.isMachineOpcode() &&
+              C.Op1.getMachineOpcode() == SystemZ::LOAD_STACK_GUARD &&
+              ISD::isNormalLoad(C.Op0.getNode()) &&
+              dyn_cast<FrameIndexSDNode>(C.Op0.getOperand(1)))) {
+    StackGuardLoad = C.Op1;
+    FILoad = cast<LoadSDNode>(C.Op0);
+  } else {
----------------
uweigand wrote:

You should do this *after* the operand swapping, then you wouldn't have to 
consider both cases here.

https://github.com/llvm/llvm-project/pull/169317
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to