diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-04-12 12:59:50 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-04-12 12:59:50 +0000 |
commit | 3c0d61b7c0ebb8c333582d75f25d5824c0387a27 (patch) | |
tree | 9dba000560186e7dc91f0ce2a1165a838df88878 | |
parent | 97375359436f2bd9714789a64716ac14e24f9275 (diff) | |
download | bcm5719-llvm-3c0d61b7c0ebb8c333582d75f25d5824c0387a27.tar.gz bcm5719-llvm-3c0d61b7c0ebb8c333582d75f25d5824c0387a27.zip |
[CodeGen] Allow printing MachineMemOperands with less context in SDAGDumper
Don't assume SelectionDAG is non-null as the targets can use it with a
null pointer.
Differential Revision: https://reviews.llvm.org/D44611
llvm-svn: 329908
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp index 6ef3ec84f9f..192141abeb9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp @@ -425,15 +425,28 @@ static Printable PrintNodeId(const SDNode &Node) { // 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 MachineFunction *MF, const Module *M, + const MachineFrameInfo *MFI, + const TargetInstrInfo *TII, LLVMContext &Ctx) { + 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); +} + +static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, + const SelectionDAG *G) { + if (G) { + const MachineFunction *MF = &G->getMachineFunction(); + return printMemOperand(OS, MMO, MF, MF->getFunction().getParent(), + &MF->getFrameInfo(), G->getSubtarget().getInstrInfo(), + *G->getContext()); + } else { + LLVMContext Ctx; + return printMemOperand(OS, MMO, /*MF=*/nullptr, /*M=*/nullptr, + /*MFI=*/nullptr, /*TII=*/nullptr, Ctx); + } } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |