[llvm-bugs] [Bug 41772] New: MachineMemOperand::print - null pointer dereferences
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon May 6 11:20:13 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=41772
Bug ID: 41772
Summary: MachineMemOperand::print - null pointer dereferences
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedbugs at nondot.org
Reporter: llvm-dev at redking.me.uk
CC: francisvm at yahoo.com, llvm-bugs at lists.llvm.org,
luke.cheeseman2 at arm.com, spatel+llvm at rotateright.com
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:
https://llvm.org/reports/scan-build/report-MachineOperand.cpp-print-14-1.html#EndPath
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190506/f27ef1e0/attachment.html>
More information about the llvm-bugs
mailing list