Skip to content

Commit a6aa936

Browse files
[NFC][AsmPrinter] Pass MJTI by const reference instead of const pointer (#122365)
The caller `AsmPrinter::emitJumpTableInfo` checks [1] `MJTI` is not a null pointer before calling `emitJumpTableEntry` or `emitJumpTableSizesSection`. This patch updates callee function's signature to accept const reference, this way it's explicit `MJTI` won't be nullptr inside the callee. [1] https://github.com/llvm/llvm-project/blob/9d5299eb61a64cd4df5fefa0299b0cf8d917978f/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp#L2857
1 parent 504f6ce commit a6aa936

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

llvm/include/llvm/CodeGen/AsmPrinter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,10 +892,10 @@ class AsmPrinter : public MachineFunctionPass {
892892
// Internal Implementation Details
893893
//===------------------------------------------------------------------===//
894894

895-
void emitJumpTableEntry(const MachineJumpTableInfo *MJTI,
895+
void emitJumpTableEntry(const MachineJumpTableInfo &MJTI,
896896
const MachineBasicBlock *MBB, unsigned uid) const;
897897

898-
void emitJumpTableSizesSection(const MachineJumpTableInfo *MJTI,
898+
void emitJumpTableSizesSection(const MachineJumpTableInfo &MJTI,
899899
const Function &F) const;
900900

901901
void emitLLVMUsedList(const ConstantArray *InitList);

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2922,19 +2922,19 @@ void AsmPrinter::emitJumpTableInfo() {
29222922
// Defer MCAssembler based constant folding due to a performance issue. The
29232923
// label differences will be evaluated at write time.
29242924
for (const MachineBasicBlock *MBB : JTBBs)
2925-
emitJumpTableEntry(MJTI, MBB, JTI);
2925+
emitJumpTableEntry(*MJTI, MBB, JTI);
29262926
}
29272927

29282928
if (EmitJumpTableSizesSection)
2929-
emitJumpTableSizesSection(MJTI, F);
2929+
emitJumpTableSizesSection(*MJTI, F);
29302930

29312931
if (!JTInDiffSection)
29322932
OutStreamer->emitDataRegion(MCDR_DataRegionEnd);
29332933
}
29342934

2935-
void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo *MJTI,
2935+
void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo &MJTI,
29362936
const Function &F) const {
2937-
const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
2937+
const std::vector<MachineJumpTableEntry> &JT = MJTI.getJumpTables();
29382938

29392939
if (JT.empty())
29402940
return;
@@ -2982,17 +2982,17 @@ void AsmPrinter::emitJumpTableSizesSection(const MachineJumpTableInfo *MJTI,
29822982

29832983
/// EmitJumpTableEntry - Emit a jump table entry for the specified MBB to the
29842984
/// current stream.
2985-
void AsmPrinter::emitJumpTableEntry(const MachineJumpTableInfo *MJTI,
2985+
void AsmPrinter::emitJumpTableEntry(const MachineJumpTableInfo &MJTI,
29862986
const MachineBasicBlock *MBB,
29872987
unsigned UID) const {
29882988
assert(MBB && MBB->getNumber() >= 0 && "Invalid basic block");
29892989
const MCExpr *Value = nullptr;
2990-
switch (MJTI->getEntryKind()) {
2990+
switch (MJTI.getEntryKind()) {
29912991
case MachineJumpTableInfo::EK_Inline:
29922992
llvm_unreachable("Cannot emit EK_Inline jump table entry");
29932993
case MachineJumpTableInfo::EK_Custom32:
29942994
Value = MF->getSubtarget().getTargetLowering()->LowerCustomJumpTableEntry(
2995-
MJTI, MBB, UID, OutContext);
2995+
&MJTI, MBB, UID, OutContext);
29962996
break;
29972997
case MachineJumpTableInfo::EK_BlockAddress:
29982998
// EK_BlockAddress - Each entry is a plain address of block, e.g.:
@@ -3026,7 +3026,7 @@ void AsmPrinter::emitJumpTableEntry(const MachineJumpTableInfo *MJTI,
30263026
// If the .set directive avoids relocations, this is emitted as:
30273027
// .set L4_5_set_123, LBB123 - LJTI1_2
30283028
// .word L4_5_set_123
3029-
if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
3029+
if (MJTI.getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
30303030
MAI->doesSetDirectiveSuppressReloc()) {
30313031
Value = MCSymbolRefExpr::create(GetJTSetSymbol(UID, MBB->getNumber()),
30323032
OutContext);
@@ -3042,7 +3042,7 @@ void AsmPrinter::emitJumpTableEntry(const MachineJumpTableInfo *MJTI,
30423042

30433043
assert(Value && "Unknown entry kind!");
30443044

3045-
unsigned EntrySize = MJTI->getEntrySize(getDataLayout());
3045+
unsigned EntrySize = MJTI.getEntrySize(getDataLayout());
30463046
OutStreamer->emitValue(Value, EntrySize);
30473047
}
30483048

0 commit comments

Comments
 (0)