[llvm] [SystemZ] Avoid modifying IR in mcount instrumentation. (PR #152298)
Ulrich Weigand via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 08:32:51 PDT 2025
================
@@ -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"))
----------------
uweigand wrote:
Actually, it looks like using `createExternalSymbolName` would be leaking memory here - it allocated a buffer, but this is then never freed ... So string constants should be strictly better here.
https://github.com/llvm/llvm-project/pull/152298
More information about the llvm-commits
mailing list