Skip to content

Commit 7d80ee5

Browse files
authored
CodeGen: Use IR function to query Module instead of MachineModuleInfo (#99755)
1 parent e77a01d commit 7d80ee5

9 files changed

+16
-17
lines changed

llvm/lib/CodeGen/CFGuardLongjmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ FunctionPass *llvm::createCFGuardLongjmpPass() { return new CFGuardLongjmp(); }
6262
bool CFGuardLongjmp::runOnMachineFunction(MachineFunction &MF) {
6363

6464
// Skip modules for which the cfguard flag is not set.
65-
if (!MF.getMMI().getModule()->getModuleFlag("cfguard"))
65+
if (!MF.getFunction().getParent()->getModuleFlag("cfguard"))
6666
return false;
6767

6868
// Skip functions that do not have calls to _setjmp.

llvm/lib/CodeGen/EHContGuardCatchret.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ FunctionPass *llvm::createEHContGuardCatchretPass() {
6262
bool EHContGuardCatchret::runOnMachineFunction(MachineFunction &MF) {
6363

6464
// Skip modules for which the ehcontguard flag is not set.
65-
if (!MF.getMMI().getModule()->getModuleFlag("ehcontguard"))
65+
if (!MF.getFunction().getParent()->getModuleFlag("ehcontguard"))
6666
return false;
6767

6868
// Skip functions that do not have catchret

llvm/lib/CodeGen/KCFI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ bool KCFI::emitCheck(MachineBasicBlock &MBB,
8989
}
9090

9191
bool KCFI::runOnMachineFunction(MachineFunction &MF) {
92-
const Module *M = MF.getMMI().getModule();
92+
const Module *M = MF.getFunction().getParent();
9393
if (!M->getModuleFlag("kcfi"))
9494
return false;
9595

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
6666
CodeEmitter.reset(TM.getTarget().createMCCodeEmitter(
6767
*Subtarget->getInstrInfo(), MF.getContext()));
6868

69-
EmitFPOData =
70-
Subtarget->isTargetWin32() && MF.getMMI().getModule()->getCodeViewFlag();
69+
const Module *M = MF.getFunction().getParent();
70+
EmitFPOData = Subtarget->isTargetWin32() && M->getCodeViewFlag();
7171

72-
IndCSPrefix =
73-
MF.getMMI().getModule()->getModuleFlag("indirect_branch_cs_prefix");
72+
IndCSPrefix = M->getModuleFlag("indirect_branch_cs_prefix");
7473

7574
SetupMachineFunction(MF);
7675

llvm/lib/Target/X86/X86FrameLowering.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,6 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
15301530
MachineBasicBlock::iterator MBBI = MBB.begin();
15311531
MachineFrameInfo &MFI = MF.getFrameInfo();
15321532
const Function &Fn = MF.getFunction();
1533-
MachineModuleInfo &MMI = MF.getMMI();
15341533
X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
15351534
uint64_t MaxAlign = calculateMaxStackAlign(MF); // Desired stack alignment.
15361535
uint64_t StackSize = MFI.getStackSize(); // Number of bytes to allocate.
@@ -1545,8 +1544,8 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF,
15451544
bool IsWin64Prologue = isWin64Prologue(MF);
15461545
bool NeedsWin64CFI = IsWin64Prologue && Fn.needsUnwindTableEntry();
15471546
// FIXME: Emit FPO data for EH funclets.
1548-
bool NeedsWinFPO =
1549-
!IsFunclet && STI.isTargetWin32() && MMI.getModule()->getCodeViewFlag();
1547+
bool NeedsWinFPO = !IsFunclet && STI.isTargetWin32() &&
1548+
MF.getFunction().getParent()->getCodeViewFlag();
15501549
bool NeedsWinCFI = NeedsWin64CFI || NeedsWinFPO;
15511550
bool NeedsDwarfCFI = needsDwarfCFI(MF);
15521551
Register FramePtr = TRI->getFrameRegister(MF);
@@ -3521,7 +3520,7 @@ void X86FrameLowering::adjustForHiPEPrologue(
35213520

35223521
// HiPE-specific values
35233522
NamedMDNode *HiPELiteralsMD =
3524-
MF.getMMI().getModule()->getNamedMetadata("hipe.literals");
3523+
MF.getFunction().getParent()->getNamedMetadata("hipe.literals");
35253524
if (!HiPELiteralsMD)
35263525
report_fatal_error(
35273526
"Can't generate HiPE prologue without runtime parameters");

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,8 @@ void X86DAGToDAGISel::PreprocessISelDAG() {
922922
if (Imm == EndbrImm || isEndbrImm64(Imm)) {
923923
// Check that the cf-protection-branch is enabled.
924924
Metadata *CFProtectionBranch =
925-
MF->getMMI().getModule()->getModuleFlag("cf-protection-branch");
925+
MF->getFunction().getParent()->getModuleFlag(
926+
"cf-protection-branch");
926927
if (CFProtectionBranch || IndirectBranchTracking) {
927928
SDLoc dl(N);
928929
SDValue Complement = CurDAG->getConstant(~Imm, dl, VT, false, true);

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35882,7 +35882,7 @@ X86TargetLowering::emitEHSjLjSetJmp(MachineInstr &MI,
3588235882
MIB.addMBB(restoreMBB);
3588335883
MIB.setMemRefs(MMOs);
3588435884

35885-
if (MF->getMMI().getModule()->getModuleFlag("cf-protection-return")) {
35885+
if (MF->getFunction().getParent()->getModuleFlag("cf-protection-return")) {
3588635886
emitSetJmpShadowStackFix(MI, thisMBB);
3588735887
}
3588835888

@@ -36158,7 +36158,7 @@ X86TargetLowering::emitEHSjLjLongJmp(MachineInstr &MI,
3615836158
MachineBasicBlock *thisMBB = MBB;
3615936159

3616036160
// When CET and shadow stack is enabled, we need to fix the Shadow Stack.
36161-
if (MF->getMMI().getModule()->getModuleFlag("cf-protection-return")) {
36161+
if (MF->getFunction().getParent()->getModuleFlag("cf-protection-return")) {
3616236162
thisMBB = emitLongJmpShadowStackFix(MI, thisMBB);
3616336163
}
3616436164

@@ -57981,7 +57981,7 @@ SDValue X86TargetLowering::expandIndirectJTBranch(const SDLoc &dl,
5798157981
SDValue Value, SDValue Addr,
5798257982
int JTI,
5798357983
SelectionDAG &DAG) const {
57984-
const Module *M = DAG.getMachineFunction().getMMI().getModule();
57984+
const Module *M = DAG.getMachineFunction().getFunction().getParent();
5798557985
Metadata *IsCFProtectionSupported = M->getModuleFlag("cf-protection-branch");
5798657986
if (IsCFProtectionSupported) {
5798757987
// In case control-flow branch protection is enabled, we need to add

llvm/lib/Target/X86/X86IndirectBranchTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static bool needsPrologueENDBR(MachineFunction &MF, const Module *M) {
116116
bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) {
117117
const X86Subtarget &SubTarget = MF.getSubtarget<X86Subtarget>();
118118

119-
const Module *M = MF.getMMI().getModule();
119+
const Module *M = MF.getFunction().getParent();
120120
// Check that the cf-protection-branch is enabled.
121121
Metadata *isCFProtectionSupported = M->getModuleFlag("cf-protection-branch");
122122

llvm/lib/Target/X86/X86ReturnThunks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool X86ReturnThunks::runOnMachineFunction(MachineFunction &MF) {
7878
Rets.push_back(&Term);
7979

8080
bool IndCS =
81-
MF.getMMI().getModule()->getModuleFlag("indirect_branch_cs_prefix");
81+
MF.getFunction().getParent()->getModuleFlag("indirect_branch_cs_prefix");
8282
const MCInstrDesc &CS = ST.getInstrInfo()->get(X86::CS_PREFIX);
8383
const MCInstrDesc &JMP = ST.getInstrInfo()->get(X86::TAILJMPd);
8484

0 commit comments

Comments
 (0)