[llvm] [SystemZ] Add proper mcount handling (PR #135767)
Dominik Steenken via llvm-commits
llvm-commits at lists.llvm.org
Fri May 2 01:58:14 PDT 2025
================
@@ -558,6 +559,32 @@ void SystemZELFFrameLowering::emitPrologue(MachineFunction &MF,
// to determine the end of the prologue.
DebugLoc DL;
+ // Add mcount instrumentation if necessary.
+ if (MF.getFunction().getFnAttribute("systemz-backend").getValueAsString() ==
+ "insert-mcount") {
+
+ // Store return address 8 bytes above stack pointer.
+ BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
+ .addReg(SystemZ::R14D)
+ .addReg(SystemZ::R15D)
+ .addImm(8)
+ .addReg(0);
+
+ // Call mcount (Regmask 0 to ensure this will not be moved by the
+ // scheduler.).
----------------
dominik-steenken wrote:
I changed the regmask to reflect the note in the ABI which says "[...] it preserves more registers than a normal function, treating all the usual argument
registers as nonvolatile as well".
https://github.com/llvm/llvm-project/pull/135767
More information about the llvm-commits
mailing list