[clang] [llvm] [SystemZ] Global Stackprotector and associated location section (PR #169317)

Dominik Steenken via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 00:52:00 PST 2025


================
@@ -1830,6 +1797,28 @@ unsigned SystemZInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
     return 18;
   if (MI.getOpcode() == TargetOpcode::PATCHABLE_RET)
     return 18 + (MI.getOperand(0).getImm() == SystemZ::CondReturn ? 4 : 0);
+  if ((MI.getOpcode() == SystemZ::MOVE_STACK_GUARD) ||
+      (MI.getOpcode() == SystemZ::COMPARE_STACK_GUARD))
+    return 6;
+  if ((MI.getOpcode() == SystemZ::LOAD_STACK_GUARD_ADDRESS) ||
+      (MI.getOpcode() == TargetOpcode::LOAD_STACK_GUARD)) {
+    StringRef GuardType = MI.getParent()
+                              ->getParent()
+                              ->getFunction()
+                              .getParent()
+                              ->getStackProtectorGuard();
+    unsigned Size = (MI.getOpcode() == TargetOpcode::LOAD_STACK_GUARD)
+                        ? 6
+                        : 0; // lg to load value
+    if (GuardType == "global")
----------------
dominik-steenken wrote:

Ah, this is a case of `clang-format` introducing line breaks that change the perceived meaning of a comment. The comment was meant for the whole statement. Basically, the size of `LOAD_STACK_GUARD[_ADDRESS]` is computed by the size required for loading the stack guard's address (this depends on the guard's type), and then we need to either add `6` for the `lg` in case of `LOAD_STACK_GUARD`, or nothing in case of `LOAD_STACK_GUARD_ADDRESS`.

I'll move the comment one line up, that should make that clear.

https://github.com/llvm/llvm-project/pull/169317


More information about the llvm-commits mailing list