================
@@ -3187,6 +3193,35 @@ 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
+// - The original opcode is ICMP
+// - ICMPType is compatible with unsigned comparison.
+static void adjustForStackGuardCompare(SelectionDAG &DAG, const SDLoc &DL,
+ Comparison &C) {
+
+ // Opcode must be ICMP.
+ if (C.Opcode != SystemZISD::ICMP)
+ return;
+ // ICmpType must be Unsigned or Any.
+ if (C.ICmpType == SystemZICMP::SignedOnly)
+ return;
+ // Op0 must be FrameIndex Load.
+ if (!(ISD::isNormalLoad(C.Op0.getNode()) &&
+ dyn_cast<FrameIndexSDNode>(C.Op0.getOperand(1))))
+ return;
+ // Op1 must be LOAD_STACK_GUARD.
+ if (!C.Op1.isMachineOpcode() ||
+ C.Op1.getMachineOpcode() != SystemZ::LOAD_STACK_GUARD)
+ return;
+
+ // At this point we are sure that this is a proper CMP_STACKGUARD
+ // case, update the opcode to reflect this.
+ C.Opcode = SystemZISD::CMP_STACKGUARD;
+ C.CCValid = SystemZ::CCMASK_ICMP;
----------------
uweigand wrote:
We should *not* set `CCValid` here. The tests above ensure that it must
already have been the correct value, but if it hadn't been, simply changing
`CCValid` (without looking at `CCMask`) would be just wrong.
https://github.com/llvm/llvm-project/pull/169317
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits