[llvm] [SystemZ] Avoid modifying IR in mcount instrumentation. (PR #152298)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 05:09:24 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-systemz
Author: Dominik Steenken (dominik-steenken)
<details>
<summary>Changes</summary>
This PR changes how the call to `mcount` is inserted in `emitPrologue`. It is now emitted as an external symbol rather than a global variable, preventing potentially unexpected IR modification.
---
Full diff: https://github.com/llvm/llvm-project/pull/152298.diff
1 Files Affected:
- (modified) llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp (+1-3)
``````````diff
diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 6297916310803..ed953fef8c1f1 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -574,13 +574,11 @@ void SystemZELFFrameLowering::emitPrologue(MachineFunction &MF,
// Call mcount (Regmask from CC AnyReg since mcount preserves all normal
// argument registers).
- FunctionCallee FC = MF.getFunction().getParent()->getOrInsertFunction(
- "mcount", Type::getVoidTy(MF.getFunction().getContext()));
const uint32_t *Mask = MF.getSubtarget<SystemZSubtarget>()
.getSpecialRegisters()
->getCallPreservedMask(MF, CallingConv::AnyReg);
BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::CallBRASL))
- .addGlobalAddress(dyn_cast<Function>(FC.getCallee()))
+ .addExternalSymbol(MF.createExternalSymbolName("mcount"))
.addRegMask(Mask);
// Reload return address from 8 bytes above stack pointer.
``````````
</details>
https://github.com/llvm/llvm-project/pull/152298
More information about the llvm-commits
mailing list