<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - MachineMemOperand::print - null pointer dereferences"
href="https://bugs.llvm.org/show_bug.cgi?id=41772">41772</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>MachineMemOperand::print - null pointer dereferences
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>francisvm@yahoo.com, llvm-bugs@lists.llvm.org, luke.cheeseman2@arm.com, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>The main implementation dereferences the TargetInstrInfo pointer:
void MachineMemOperand::print(raw_ostream &OS, ModuleSlotTracker &MST,
SmallVectorImpl<StringRef> &SSNs,
const LLVMContext &Context,
const MachineFrameInfo *MFI,
const TargetInstrInfo *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)
<< "\" ";
....
}
But we have helper variants:
void MachineMemOperand::print(raw_ostream &OS) const {
ModuleSlotTracker DummyMST(nullptr);
print(OS, DummyMST);
}
void MachineMemOperand::print(raw_ostream &OS, ModuleSlotTracker &MST) const {
SmallVector<StringRef, 0> SSNs;
LLVMContext Ctx;
print(OS, MST, SSNs, Ctx, nullptr, nullptr);
}
That both result in the TTI arg being passed a nullptr.
We either need to update these helpers to always take a TTI arg (reference
instead of a pointer?) or to make the print function check that TTI isn't null
before calling getTargetMMOFlagName).
Found in scan-build CI:
<a href="https://llvm.org/reports/scan-build/report-MachineOperand.cpp-print-14-1.html#EndPath">https://llvm.org/reports/scan-build/report-MachineOperand.cpp-print-14-1.html#EndPath</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>