[llvm] cfa0947 - Cope with MCOperand null Insts (#91794)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 06:35:33 PDT 2024


Author: Nathan Sidwell
Date: 2024-05-14T09:35:30-04:00
New Revision: cfa09473a6f904d214a1b514f41b9d4d9276c927

URL: https://github.com/llvm/llvm-project/commit/cfa09473a6f904d214a1b514f41b9d4d9276c927
DIFF: https://github.com/llvm/llvm-project/commit/cfa09473a6f904d214a1b514f41b9d4d9276c927.diff

LOG: Cope with MCOperand null Insts (#91794)

MCOperand has a constructor that permits a nullptr MCInst, and BOLT makes use of that. Adjust MCOperand's dumper to permit such use.

Added: 
    

Modified: 
    llvm/lib/MC/MCInst.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCInst.cpp b/llvm/lib/MC/MCInst.cpp
index 3cc50ff43513e..639619fe4e991 100644
--- a/llvm/lib/MC/MCInst.cpp
+++ b/llvm/lib/MC/MCInst.cpp
@@ -38,7 +38,10 @@ void MCOperand::print(raw_ostream &OS, const MCRegisterInfo *RegInfo) const {
     OS << "Expr:(" << *getExpr() << ")";
   } else if (isInst()) {
     OS << "Inst:(";
-    getInst()->print(OS, RegInfo);
+    if (const auto *Inst = getInst())
+      Inst->print(OS, RegInfo);
+    else
+      OS << "NULL";
     OS << ")";
   } else
     OS << "UNDEFINED";


        


More information about the llvm-commits mailing list