Skip to content

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Oct 16, 2025

The runtime library does not add a SYSTEM_CHECK_GUARD
implementation so the default will be a no-op anyway.

The runtime library does not add a SYSTEM_CHECK_GUARD
implementation so the default will be a no-op anyway.
Copy link
Contributor Author

arsenm commented Oct 16, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm requested review from JonPsson and uweigand October 16, 2025 06:43
@arsenm arsenm marked this pull request as ready for review October 16, 2025 06:43
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2025

@llvm/pr-subscribers-backend-systemz

Author: Matt Arsenault (arsenm)

Changes

The runtime library does not add a SYSTEM_CHECK_GUARD
implementation so the default will be a no-op anyway.


Full diff: https://github.com/llvm/llvm-project/pull/163708.diff

1 Files Affected:

  • (modified) llvm/lib/Target/SystemZ/SystemZISelLowering.h (-2)
diff --git a/llvm/lib/Target/SystemZ/SystemZISelLowering.h b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
index d5b76031766dd..396e78e2845be 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelLowering.h
+++ b/llvm/lib/Target/SystemZ/SystemZISelLowering.h
@@ -606,8 +606,6 @@ class SystemZTargetLowering : public TargetLowering {
 
   /// Override to support customized stack guard loading.
   bool useLoadStackGuardNode(const Module &M) const override { return true; }
-  void insertSSPDeclarations(Module &M) const override {
-  }
 
   MachineBasicBlock *
   EmitInstrWithCustomInserter(MachineInstr &MI,

@uweigand
Copy link
Member

The runtime library does not add a SYSTEM_CHECK_GUARD implementation so the default will be a no-op anyway.

This doesn't look correct to me. Linux on SystemZ uses the LegacyDefaultSystemLibrary settings, which do provide the SYSTEM_CHECK_GUARD, and I verified that after removing the override, the behavior is no longer a no-op.

Now maybe we should have our own settings instead, but right now we do not. (Note that z/OS does have it's own settings, but z/OS is a very different operating system from Linux anyway.)

@arsenm
Copy link
Contributor Author

arsenm commented Oct 17, 2025

This doesn't look correct to me. Linux on SystemZ uses the LegacyDefaultSystemLibrary settings, which do provide the SYSTEM_CHECK_GUARD, and I verified that after removing the override, the behavior is no longer a no-op.

Since no tests change with this, there is a problem. Can you add the missing test coverage @uweigand?

@uweigand
Copy link
Member

This doesn't look correct to me. Linux on SystemZ uses the LegacyDefaultSystemLibrary settings, which do provide the SYSTEM_CHECK_GUARD, and I verified that after removing the override, the behavior is no longer a no-op.

Since no tests change with this, there is a problem. Can you add the missing test coverage @uweigand?

Well, there is a (somewhat minimalistic) test in test/CodeGen/SystemZ/stack-guard.ll. This does not show any difference in generated assembler output based on whether or not that declaration is visible - should it?

You can see differences in verbose dumps, e.g. current mainline:

  $r1l = EAR $a0, implicit-def $r1d
  $r1d = SLLG $r1d, $noreg, 32
  $r1l = EAR $a1
  renamable $r1d = LG $r1d, 40, $noreg
  CG killed renamable $r1d, $r15d, 1184, $noreg, implicit-def $cc :: (volatile load (s64) from %stack.0.StackGuardSlot)

vs. with your patch:

  $r1l = EAR $a0, implicit-def $r1d
  $r1d = SLLG $r1d, $noreg, 32
  $r1l = EAR $a1
  renamable $r1d = LG $r1d, 40, $noreg :: (dereferenceable invariant load (s64) from @__stack_chk_guard)
  CG killed renamable $r1d, $r15d, 1184, $noreg, implicit-def $cc :: (volatile load (s64) from %stack.0.StackGuardSlot)

Not sure if there is any more complex code sequence where that could result in observable assembler differences. Either way, it looks to me like current mainline (without the declaration) is more correct as we do not actually use any global variable __stack_chk_guard but rather a TLS slot (the EAR/SLLG/EAR sequence retrieves the address of the TLS area).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants