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: unassignedb...@nondot.org
Reporter: llvm-...@redking.me.uk
CC: franci...@yahoo.com, llvm-bugs@lists.llvm.org,
luke.cheesem...@arm.com, spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs