[llvm] [SystemZ] Avoid modifying IR in mcount instrumentation. (PR #152298)
Dominik Steenken via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 07:57:06 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"))
----------------
dominik-steenken wrote:
I was looking for examples for `addExternalSymbol` and found both instances (`createExternalSymbolName`, and plain strings). I felt that following the former example would be more conservative. I'll change this to just use a string constant.
https://github.com/llvm/llvm-project/pull/152298
More information about the llvm-commits
mailing list