[PATCH] D44611: [CodeGen] Allow printing MachineMemOperands with less context in SDAGDumper
Francis Visoiu Mistrih via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 18 13:58:39 PDT 2018
thegameg created this revision.
thegameg added a reviewer: craig.topper.
Don't assume `SelectionDAG` is non-null as the targets can use it with a null pointer.
https://reviews.llvm.org/D44611
Files:
lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
Index: lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -426,14 +426,27 @@
// Print the MMO with more information from the SelectionDAG.
static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO,
const SelectionDAG *G) {
- const MachineFunction &MF = G->getMachineFunction();
- const Function &F = MF.getFunction();
- const MachineFrameInfo &MFI = MF.getFrameInfo();
- const TargetInstrInfo *TII = G->getSubtarget().getInstrInfo();
- ModuleSlotTracker MST(F.getParent());
- MST.incorporateFunction(F);
+ const Module *M = nullptr;
+ const MachineFunction *MF = nullptr;
+ const MachineFrameInfo *MFI = nullptr;
+ const TargetInstrInfo *TII = nullptr;
+ LLVMContext *Ctx = nullptr;
+ std::unique_ptr<LLVMContext> CtxPtr;
+ if (G) {
+ MF = &G->getMachineFunction();
+ M = MF->getFunction().getParent();
+ MFI = &MF->getFrameInfo();
+ TII = G->getSubtarget().getInstrInfo();
+ Ctx = G->getContext();
+ } else {
+ CtxPtr = llvm::make_unique<LLVMContext>();
+ Ctx = CtxPtr.get();
+ }
+ ModuleSlotTracker MST(M);
+ if (MF)
+ MST.incorporateFunction(MF->getFunction());
SmallVector<StringRef, 0> SSNs;
- MMO.print(OS, MST, SSNs, *G->getContext(), &MFI, TII);
+ MMO.print(OS, MST, SSNs, *Ctx, MFI, TII);
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44611.138866.patch
Type: text/x-patch
Size: 1519 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180318/d1ac7531/attachment-0001.bin>
More information about the llvm-commits
mailing list