Skip to content

Commit 0f0cfcf

Browse files
authored
CodeGen: Avoid some references to MachineFunction's getMMI (#99652)
MachineFunction's probably should not include a backreference to the owning MachineModuleInfo. Most of these references were used just to query the MCContext, which MachineFunction already directly stores. Other contexts are using it to query the LLVMContext, which can already be accessed through the IR function reference.
1 parent 54dab7d commit 0f0cfcf

27 files changed

+39
-65
lines changed

llvm/include/llvm/CodeGen/TailDuplicator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class TailDuplicator {
4040
const TargetInstrInfo *TII;
4141
const TargetRegisterInfo *TRI;
4242
const MachineBranchProbabilityInfo *MBPI;
43-
const MachineModuleInfo *MMI;
4443
MachineRegisterInfo *MRI;
4544
MachineFunction *MF;
4645
MBFIWrapper *MBFI;

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,8 +2451,7 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
24512451

24522452
int FI = getOrCreateFrameIndex(*cast<AllocaInst>(Arg));
24532453
MCSymbol *FrameAllocSym =
2454-
MF->getMMI().getContext().getOrCreateFrameAllocSymbol(EscapedName,
2455-
Idx);
2454+
MF->getContext().getOrCreateFrameAllocSymbol(EscapedName, Idx);
24562455

24572456
// This should be inserted at the start of the entry block.
24582457
auto LocalEscape =

llvm/lib/CodeGen/MachineInstr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2216,7 +2216,7 @@ void MachineInstr::emitError(StringRef Msg) const {
22162216

22172217
if (const MachineBasicBlock *MBB = getParent())
22182218
if (const MachineFunction *MF = MBB->getParent())
2219-
return MF->getMMI().getModule()->getContext().emitError(LocCookie, Msg);
2219+
return MF->getFunction().getContext().emitError(LocCookie, Msg);
22202220
report_fatal_error(Msg);
22212221
}
22222222

llvm/lib/CodeGen/RegAllocBase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void RegAllocBase::allocatePhysRegs() {
130130
MI->emitError("inline assembly requires more registers than available");
131131
} else if (MI) {
132132
LLVMContext &Context =
133-
MI->getParent()->getParent()->getMMI().getModule()->getContext();
133+
MI->getParent()->getParent()->getFunction().getContext();
134134
Context.emitError("ran out of registers during register allocation");
135135
} else {
136136
report_fatal_error("ran out of registers during register allocation");

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7375,8 +7375,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
73757375
case Intrinsic::codeview_annotation: {
73767376
// Emit a label associated with this metadata.
73777377
MachineFunction &MF = DAG.getMachineFunction();
7378-
MCSymbol *Label =
7379-
MF.getMMI().getContext().createTempSymbol("annotation", true);
7378+
MCSymbol *Label = MF.getContext().createTempSymbol("annotation", true);
73807379
Metadata *MD = cast<MetadataAsValue>(I.getArgOperand(0))->getMetadata();
73817380
MF.addCodeViewAnnotation(Label, cast<MDNode>(MD));
73827381
Res = DAG.getLabelNode(ISD::ANNOTATION_LABEL, sdl, getRoot(), Label);
@@ -7644,9 +7643,8 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
76447643
assert(FuncInfo.StaticAllocaMap.count(Slot) &&
76457644
"can only escape static allocas");
76467645
int FI = FuncInfo.StaticAllocaMap[Slot];
7647-
MCSymbol *FrameAllocSym =
7648-
MF.getMMI().getContext().getOrCreateFrameAllocSymbol(
7649-
GlobalValue::dropLLVMManglingEscape(MF.getName()), Idx);
7646+
MCSymbol *FrameAllocSym = MF.getContext().getOrCreateFrameAllocSymbol(
7647+
GlobalValue::dropLLVMManglingEscape(MF.getName()), Idx);
76507648
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, dl,
76517649
TII->get(TargetOpcode::LOCAL_ESCAPE))
76527650
.addSym(FrameAllocSym)
@@ -7665,9 +7663,8 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
76657663
auto *Idx = cast<ConstantInt>(I.getArgOperand(2));
76667664
unsigned IdxVal =
76677665
unsigned(Idx->getLimitedValue(std::numeric_limits<int>::max()));
7668-
MCSymbol *FrameAllocSym =
7669-
MF.getMMI().getContext().getOrCreateFrameAllocSymbol(
7670-
GlobalValue::dropLLVMManglingEscape(Fn->getName()), IdxVal);
7666+
MCSymbol *FrameAllocSym = MF.getContext().getOrCreateFrameAllocSymbol(
7667+
GlobalValue::dropLLVMManglingEscape(Fn->getName()), IdxVal);
76717668

76727669
Value *FP = I.getArgOperand(1);
76737670
SDValue FPVal = getValue(FP);
@@ -8626,7 +8623,7 @@ SDValue SelectionDAGBuilder::lowerStartEH(SDValue Chain,
86268623

86278624
// Insert a label before the invoke call to mark the try range. This can be
86288625
// used to detect deletion of the invoke via the MachineModuleInfo.
8629-
BeginLabel = MMI.getContext().createTempSymbol();
8626+
BeginLabel = MF.getContext().createTempSymbol();
86308627

86318628
// For SjLj, keep track of which landing pads go with which invokes
86328629
// so as to maintain the ordering of pads in the LSDA.
@@ -8648,11 +8645,10 @@ SDValue SelectionDAGBuilder::lowerEndEH(SDValue Chain, const InvokeInst *II,
86488645
assert(BeginLabel && "BeginLabel should've been set");
86498646

86508647
MachineFunction &MF = DAG.getMachineFunction();
8651-
MachineModuleInfo &MMI = MF.getMMI();
86528648

86538649
// Insert a label at the end of the invoke call to mark the try range. This
86548650
// can be used to detect deletion of the invoke via the MachineModuleInfo.
8655-
MCSymbol *EndLabel = MMI.getContext().createTempSymbol();
8651+
MCSymbol *EndLabel = MF.getContext().createTempSymbol();
86568652
Chain = DAG.getEHLabel(getCurSDLoc(), Chain, EndLabel);
86578653

86588654
// Inform MachineModuleInfo of range.

llvm/lib/CodeGen/TailDuplicator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ void TailDuplicator::initMF(MachineFunction &MFin, bool PreRegAlloc,
9797
TII = MF->getSubtarget().getInstrInfo();
9898
TRI = MF->getSubtarget().getRegisterInfo();
9999
MRI = &MF->getRegInfo();
100-
MMI = &MF->getMMI();
101100
MBPI = MBPIin;
102101
MBFI = MBFIin;
103102
PSI = PSIin;

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ bool TargetLoweringObjectFileXCOFF::ShouldSetSSPCanaryBitInTB(
23232323

23242324
MCSymbol *
23252325
TargetLoweringObjectFileXCOFF::getEHInfoTableSymbol(const MachineFunction *MF) {
2326-
MCSymbol *EHInfoSym = MF->getMMI().getContext().getOrCreateSymbol(
2326+
MCSymbol *EHInfoSym = MF->getContext().getOrCreateSymbol(
23272327
"__ehinfo." + Twine(MF->getFunctionNumber()));
23282328
cast<MCSymbolXCOFF>(EHInfoSym)->setEHInfo();
23292329
return EHInfoSym;

llvm/lib/Target/AArch64/AArch64PointerAuth.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void AArch64PointerAuth::signLR(MachineFunction &MF,
116116
// PAuthLR authentication instructions need to know the value of PC at the
117117
// point of signing (PACI*).
118118
if (MFnI.branchProtectionPAuthLR()) {
119-
MCSymbol *PACSym = MF.getMMI().getContext().createTempSymbol();
119+
MCSymbol *PACSym = MF.getContext().createTempSymbol();
120120
MFnI.setSigningInstrLabel(PACSym);
121121
}
122122

llvm/lib/Target/ARC/ARCFrameLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ void ARCFrameLowering::emitPrologue(MachineFunction &MF,
116116
MachineBasicBlock &MBB) const {
117117
LLVM_DEBUG(dbgs() << "Emit Prologue: " << MF.getName() << "\n");
118118
auto *AFI = MF.getInfo<ARCFunctionInfo>();
119-
MachineModuleInfo &MMI = MF.getMMI();
120-
MCContext &Context = MMI.getContext();
119+
MCContext &Context = MF.getContext();
121120
const MCRegisterInfo *MRI = Context.getRegisterInfo();
122121
const ARCInstrInfo *TII = MF.getSubtarget<ARCSubtarget>().getInstrInfo();
123122
MachineBasicBlock::iterator MBBI = MBB.begin();

llvm/lib/Target/ARM/ARMFrameLowering.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,7 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
735735
MachineBasicBlock::iterator MBBI = MBB.begin();
736736
MachineFrameInfo &MFI = MF.getFrameInfo();
737737
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
738-
MachineModuleInfo &MMI = MF.getMMI();
739-
MCContext &Context = MMI.getContext();
738+
MCContext &Context = MF.getContext();
740739
const TargetMachine &TM = MF.getTarget();
741740
const MCRegisterInfo *MRI = Context.getRegisterInfo();
742741
const ARMBaseRegisterInfo *RegInfo = STI.getRegisterInfo();
@@ -2995,8 +2994,7 @@ void ARMFrameLowering::adjustForSegmentedStacks(
29952994
report_fatal_error("Segmented stacks not supported on this platform.");
29962995

29972996
MachineFrameInfo &MFI = MF.getFrameInfo();
2998-
MachineModuleInfo &MMI = MF.getMMI();
2999-
MCContext &Context = MMI.getContext();
2997+
MCContext &Context = MF.getContext();
30002998
const MCRegisterInfo *MRI = Context.getRegisterInfo();
30012999
const ARMBaseInstrInfo &TII =
30023000
*static_cast<const ARMBaseInstrInfo *>(MF.getSubtarget().getInstrInfo());

0 commit comments

Comments
 (0)