Index: lib/CodeGen/MachineOperand.cpp =================================================================== --- lib/CodeGen/MachineOperand.cpp +++ lib/CodeGen/MachineOperand.cpp @@ -461,7 +461,10 @@ printLLVMNameWithoutPrefix(OS, V.getName()); return; } - MachineOperand::printIRSlotNumber(OS, MST.getLocalSlot(&V)); + if (MST.getCurrentFunction()) + MachineOperand::printIRSlotNumber(OS, MST.getLocalSlot(&V)); + else + OS << "?"; } static void printSyncScope(raw_ostream &OS, const LLVMContext &Context, Index: lib/Target/SystemZ/SystemZISelDAGToDAG.cpp =================================================================== --- lib/Target/SystemZ/SystemZISelDAGToDAG.cpp +++ lib/Target/SystemZ/SystemZISelDAGToDAG.cpp @@ -71,19 +71,19 @@ // True if the address can (and must) include ADJDYNALLOC. bool isDynAlloc() { return Form == FormBDXDynAlloc; } - void dump() { + void dump(const llvm::SelectionDAG *DAG) { errs() << "SystemZAddressingMode " << this << '\n'; errs() << " Base "; if (Base.getNode()) - Base.getNode()->dump(); + Base.getNode()->dump(DAG); else errs() << "null\n"; if (hasIndexField()) { errs() << " Index "; if (Index.getNode()) - Index.getNode()->dump(); + Index.getNode()->dump(DAG); else errs() << "null\n"; } @@ -589,7 +589,7 @@ if (AM.isDynAlloc() && !AM.IncludesDynAlloc) return false; - LLVM_DEBUG(AM.dump()); + LLVM_DEBUG(AM.dump(CurDAG)); return true; } Index: test/CodeGen/SystemZ/isel-debug.ll =================================================================== --- /dev/null +++ test/CodeGen/SystemZ/isel-debug.ll @@ -0,0 +1,19 @@ +; RUN: llc < %s -mtriple=s390x-linux-gnu -debug-only=systemz-isel -o - 2>&1 | \ +; RUN: FileCheck %s + +; REQUIRES: asserts +; +; Check that some debug output is printed without problems. +; CHECK: SystemZAddressingMode +; CHECK: Base +; CHECK: Index +; CHECK: Disp + +define void @fun(i64* %ptr) { +entry: + %0 = bitcast i64* %ptr to i32** + %1 = load i32*, i32** %0, align 8 + %xpv_pv = getelementptr inbounds i32, i32* %1 + store i32 0, i32* %xpv_pv + ret void +}