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

Dominik Steenken via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 9 06:16:28 PST 2026


================
@@ -996,6 +1023,63 @@ void SystemZAsmPrinter::LowerPATCHABLE_RET(const MachineInstr &MI,
   recordSled(BeginOfSled, MI, SledKind::FUNCTION_EXIT, 2);
 }
 
+void SystemZAsmPrinter::lowerLOAD_SGA(const MachineInstr &MI,
+                                      SystemZMCInstLower &Lower) {
+  Register AddrReg = MI.getOperand(0).getReg();
+  const MachineBasicBlock &MBB = *(MI.getParent());
+  const MachineFunction &MF = *(MBB.getParent());
+  const MachineRegisterInfo &MRI = MF.getRegInfo();
+  const Module *M = MF.getFunction().getParent();
+
+  if (MI.getOpcode() == SystemZ::LOAD_TSGA) {
+    // EAR can only load the low subregister so use a shift for %a0 to produce
+    // the GR containing %a0 and %a1.
+    const Register Reg32 =
+        MRI.getTargetRegisterInfo()->getSubReg(AddrReg, SystemZ::subreg_l32);
+
+    // ear <reg>, %a0
+    EmitToStreamer(
+        *OutStreamer,
+        MCInstBuilder(SystemZ::EAR).addReg(Reg32).addReg(SystemZ::A0));
+
+    // sllg <reg>, <reg>, 32
+    EmitToStreamer(*OutStreamer, MCInstBuilder(SystemZ::SLLG)
+                                     .addReg(AddrReg)
+                                     .addReg(AddrReg)
+                                     .addReg(0)
+                                     .addImm(32));
+
+    // ear <reg>, %a1
+    EmitToStreamer(
+        *OutStreamer,
+        MCInstBuilder(SystemZ::EAR).addReg(Reg32).addReg(SystemZ::A1));
+    return;
+  }
+  if (MI.getOpcode() == SystemZ::LOAD_GSGA) {
----------------
dominik-steenken wrote:

I split this up, and then inlined the `emitStackProtectorLocEntry`, removing that function.

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


More information about the llvm-commits mailing list