Skip to content

Commit e9dc6c5

Browse files
authored
CodeGen: Don't assert when printing null GlobalAddress operands (#115531)
1 parent a201ba1 commit e9dc6c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: llvm/lib/CodeGen/MachineOperand.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,11 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
909909
OS << printJumpTableEntryReference(getIndex());
910910
break;
911911
case MachineOperand::MO_GlobalAddress:
912-
getGlobal()->printAsOperand(OS, /*PrintType=*/false, MST);
912+
if (const auto *GV = getGlobal())
913+
getGlobal()->printAsOperand(OS, /*PrintType=*/false, MST);
914+
else // Invalid, but may appear in debugging scenarios.
915+
OS << "globaladdress(null)";
916+
913917
printOperandOffset(OS, getOffset());
914918
break;
915919
case MachineOperand::MO_ExternalSymbol: {

0 commit comments

Comments
 (0)