Skip to content

Commit 832ceda

Browse files
[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: #152238
1 parent 0e3a17c commit 832ceda

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,11 @@ void SystemZELFFrameLowering::emitPrologue(MachineFunction &MF,
574574

575575
// Call mcount (Regmask from CC AnyReg since mcount preserves all normal
576576
// argument registers).
577-
FunctionCallee FC = MF.getFunction().getParent()->getOrInsertFunction(
578-
"mcount", Type::getVoidTy(MF.getFunction().getContext()));
579577
const uint32_t *Mask = MF.getSubtarget<SystemZSubtarget>()
580578
.getSpecialRegisters()
581579
->getCallPreservedMask(MF, CallingConv::AnyReg);
582580
BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::CallBRASL))
583-
.addGlobalAddress(dyn_cast<Function>(FC.getCallee()))
581+
.addExternalSymbol("mcount")
584582
.addRegMask(Mask);
585583

586584
// Reload return address from 8 bytes above stack pointer.

0 commit comments

Comments
 (0)