[PATCH] D133903: Fix crash while printing MMO target flags
Stanislav Mekhanoshin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 14 15:46:42 PDT 2022
rampitec created this revision.
rampitec added reviewers: arsenm, foad.
Herald added a subscriber: hiraditya.
Herald added a project: All.
rampitec requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
MachineMemOperand::print can dereference a NULL pointer if TII
is not passed from the printMemOperand. This does not happen while
dumping the DAG/MIR from llc but crashes the debugger if a dump()
method is called from gdb.
https://reviews.llvm.org/D133903
Files:
llvm/lib/CodeGen/MachineOperand.cpp
Index: llvm/lib/CodeGen/MachineOperand.cpp
===================================================================
--- llvm/lib/CodeGen/MachineOperand.cpp
+++ llvm/lib/CodeGen/MachineOperand.cpp
@@ -1102,15 +1102,24 @@
OS << "dereferenceable ";
if (isInvariant())
OS << "invariant ";
- if (getFlags() & MachineMemOperand::MOTargetFlag1)
- OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag1)
- << "\" ";
- if (getFlags() & MachineMemOperand::MOTargetFlag2)
- OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag2)
- << "\" ";
- if (getFlags() & MachineMemOperand::MOTargetFlag3)
- OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag3)
- << "\" ";
+ if (TII) {
+ if (getFlags() & MachineMemOperand::MOTargetFlag1)
+ OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag1)
+ << "\" ";
+ if (getFlags() & MachineMemOperand::MOTargetFlag2)
+ OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag2)
+ << "\" ";
+ if (getFlags() & MachineMemOperand::MOTargetFlag3)
+ OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag3)
+ << "\" ";
+ } else {
+ if (getFlags() & MachineMemOperand::MOTargetFlag1)
+ OS << "\"MOTargetFlag1\" ";
+ if (getFlags() & MachineMemOperand::MOTargetFlag2)
+ OS << "\"MOTargetFlag2\" ";
+ if (getFlags() & MachineMemOperand::MOTargetFlag3)
+ OS << "\"MOTargetFlag3\" ";
+ }
assert((isLoad() || isStore()) &&
"machine memory operand must be a load or store (or both)");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133903.460254.patch
Type: text/x-patch
Size: 1631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220914/cfa6ede3/attachment.bin>
More information about the llvm-commits
mailing list