[llvm] 832ceda - [SystemZ] Avoid modifying IR in mcount instrumentation. (#152298)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 08:54:48 PDT 2025
Author: Dominik Steenken
Date: 2025-08-06T17:54:44+02:00
New Revision: 832ceda0c05f6db440a220860b3006f967f3bfd0
URL: https://github.com/llvm/llvm-project/commit/832ceda0c05f6db440a220860b3006f967f3bfd0
DIFF: https://github.com/llvm/llvm-project/commit/832ceda0c05f6db440a220860b3006f967f3bfd0.diff
LOG: [SystemZ] Avoid modifying IR in mcount instrumentation. (#152298)
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.
Fixes: https://github.com/llvm/llvm-project/issues/152238
Added:
Modified:
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 6297916310803..5ee66e3dfa7a8 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("mcount")
.addRegMask(Mask);
// Reload return address from 8 bytes above stack pointer.
More information about the llvm-commits
mailing list