[llvm] CodeGen: Don't assert when printing null GlobalAddress operands (PR #115531)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 16:15:19 PST 2024


================
@@ -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
----------------
arsenm wrote:

```suggestion
    else // Invalid, but may appear in debugging scenarios.
```

https://github.com/llvm/llvm-project/pull/115531


More information about the llvm-commits mailing list