From da89d1812aa31f7b5f5407514109e362cf92c882 Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Thu, 8 Feb 2018 05:02:00 +0000 Subject: [CodeGen] Print MachineBasicBlock labels using MIR syntax in -debug output Instead of: %bb.1: derived from LLVM BB %for.body print: bb.1.for.body: Also use MIR syntax for MBB attributes like "align", "landing-pad", etc. llvm-svn: 324563 --- llvm/lib/CodeGen/MachineBasicBlock.cpp | 46 ++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp') diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 1ed810bf817..7da604cc176 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -270,6 +270,7 @@ void MachineBasicBlock::print(raw_ostream &OS, const SlotIndexes *Indexes, const Function &F = MF->getFunction(); const Module *M = F.getParent(); ModuleSlotTracker MST(M); + MST.incorporateFunction(F); print(OS, MST, Indexes, IsStandalone); } @@ -286,21 +287,40 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, if (Indexes) OS << Indexes->getMBBStartIdx(this) << '\t'; - OS << printMBBReference(*this) << ": "; - - const char *Comma = ""; - if (const BasicBlock *LBB = getBasicBlock()) { - OS << Comma << "derived from LLVM BB "; - LBB->printAsOperand(OS, /*PrintType=*/false, MST); - Comma = ", "; + OS << "bb." << getNumber(); + bool HasAttributes = false; + if (const auto *BB = getBasicBlock()) { + if (BB->hasName()) { + OS << "." << BB->getName(); + } else { + HasAttributes = true; + OS << " ("; + int Slot = MST.getLocalSlot(BB); + if (Slot == -1) + OS << ""; + else + OS << (Twine("%ir-block.") + Twine(Slot)).str(); + } } - if (isEHPad()) { OS << Comma << "EH LANDING PAD"; Comma = ", "; } - if (hasAddressTaken()) { OS << Comma << "ADDRESS TAKEN"; Comma = ", "; } - if (Alignment) - OS << Comma << "Align " << Alignment << " (" << (1u << Alignment) - << " bytes)"; - OS << '\n'; + if (hasAddressTaken()) { + OS << (HasAttributes ? ", " : " ("); + OS << "address-taken"; + HasAttributes = true; + } + if (isEHPad()) { + OS << (HasAttributes ? ", " : " ("); + OS << "landing-pad"; + HasAttributes = true; + } + if (getAlignment()) { + OS << (HasAttributes ? ", " : " ("); + OS << "align " << getAlignment(); + HasAttributes = true; + } + if (HasAttributes) + OS << ")"; + OS << ":\n"; const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); if (!livein_empty()) { -- cgit v1.2.3