================
@@ -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 {
+ return;
+ }
+ // Assert that the values of the loads are not used elsewhere.
+ // Bail for now. TODO: What is the proper response here?
+ assert(
+ SDValue(FILoad, 0).hasOneUse() &&
+ "Value of stackguard loaded from stack must be used for compare only!");
+ assert(StackGuardLoad.hasOneUse() &&
+ "Value of reference stackguard must be used for compare only!");
----------------
uweigand wrote:
While correct incoming IR should pass those checks, we will not make anything
worse with this transformation for other IR - so this check doesn't provide any
value. Problems in the IR are not bugs here and should not lead to assertion
failures.
https://github.com/llvm/llvm-project/pull/169317
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits