From e9dc6c5fbb6d2c2c93095acb6ff4ca0b515057ed Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 3 Dec 2024 19:15:56 -0500 Subject: CodeGen: Don't assert when printing null GlobalAddress operands (#115531) --- llvm/lib/CodeGen/MachineOperand.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachineOperand.cpp') diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index d9e5e9d..18027b2 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -909,7 +909,11 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, OS << printJumpTableEntryReference(getIndex()); break; case MachineOperand::MO_GlobalAddress: - getGlobal()->printAsOperand(OS, /*PrintType=*/false, MST); + if (const auto *GV = getGlobal()) + getGlobal()->printAsOperand(OS, /*PrintType=*/false, MST); + else // Invalid, but may appear in debugging scenarios. + OS << "globaladdress(null)"; + printOperandOffset(OS, getOffset()); break; case MachineOperand::MO_ExternalSymbol: { -- cgit v1.1