static void printIRValueReference(raw_ostream &OS, const Value &V, ModuleSlotTracker &MST) { if (isa<GlobalValue>(V)) { V.printAsOperand(OS, /*PrintType=*/false, MST); return; } if (isa<Constant>(V)) { // Machine memory operands can load/store to/from constant value pointers. OS << '`'; V.printAsOperand(OS, /*PrintType=*/true, MST); OS << '`'; return; } OS << "%ir."; if (V.hasName()) { printLLVMNameWithoutPrefix(OS, V.getName()); return; } int Slot = MST.getCurrentFunction() ? MST.getLocalSlot(&V) : -1; MachineOperand::printIRSlotNumber(OS, Slot); }
static void printIRBlockReference(raw_ostream &OS, const BasicBlock &BB, ModuleSlotTracker &MST) { OS << "%ir-block."; if (BB.hasName()) { printLLVMNameWithoutPrefix(OS, BB.getName()); return; } Optional<int> Slot; if (const Function *F = BB.getParent()) { if (F == MST.getCurrentFunction()) { Slot = MST.getLocalSlot(&BB); } else if (const Module *M = F->getParent()) { ModuleSlotTracker CustomMST(M, /*ShouldInitializeAllMetadata=*/false); CustomMST.incorporateFunction(*F); Slot = CustomMST.getLocalSlot(&BB); } } if (Slot) MachineOperand::printIRSlotNumber(OS, *Slot); else OS << "<unknown>"; }