Out << "}";
}
+namespace {
+struct FieldSeparator {
+ bool Skip;
+ FieldSeparator() : Skip(true) {}
+};
+raw_ostream &operator<<(raw_ostream &OS, FieldSeparator &FS) {
+ if (FS.Skip) {
+ FS.Skip = false;
+ return OS;
+ }
+ return OS << ", ";
+}
+} // end namespace
+
+static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N,
+ TypePrinting *TypePrinter,
+ SlotTracker *Machine, const Module *Context) {
+ Out << "!GenericDebugNode(";
+ FieldSeparator FS;
+ Out << FS << "tag: ";
+ if (const char *Tag = dwarf::TagString(N->getTag()))
+ Out << Tag;
+ else
+ Out << N->getTag();
+ if (!N->getHeader().empty()) {
+ Out << FS << "header: \"";
+ PrintEscapedString(N->getHeader(), Out);
+ Out << "\"";
+ }
+ if (N->getNumDwarfOperands()) {
+ Out << FS << "operands: {";
+ FieldSeparator IFS;
+ for (auto &I : N->dwarf_operands()) {
+ Out << IFS;
+ if (!I) {
+ Out << "null";
+ continue;
+ }
+ WriteAsOperandInternal(Out, I, TypePrinter, Machine, Context);
+ }
+ Out << "}";
+ }
+ Out << ")";
+}
+
+static void writeMDLocation(raw_ostream &Out, const MDLocation *DL,
+ TypePrinting *TypePrinter, SlotTracker *Machine,
+ const Module *Context) {
+ Out << "!MDLocation(";
+ FieldSeparator FS;
+ // Always output the line, since 0 is a relevant and important value for it.
+ Out << FS << "line: " << DL->getLine();
+ if (DL->getColumn())
+ Out << FS << "column: " << DL->getColumn();
+ Out << FS << "scope: ";
+ WriteAsOperandInternal(Out, DL->getScope(), TypePrinter, Machine, Context);
+ if (DL->getInlinedAt()) {
+ Out << FS << "inlinedAt: ";
+ WriteAsOperandInternal(Out, DL->getInlinedAt(), TypePrinter, Machine,
+ Context);
+ }
+ Out << ")";
+}
+
static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
TypePrinting *TypePrinter,
SlotTracker *Machine,
const Module *Context) {
- assert(isa<UniquableMDNode>(Node) && "Expected uniquable MDNode");
+ assert(!Node->isTemporary() && "Unexpected forward declaration");
- auto *Uniquable = cast<UniquableMDNode>(Node);
- if (Uniquable->isDistinct())
+ if (Node->isDistinct())
Out << "distinct ";
- switch (Uniquable->getMetadataID()) {
+ switch (Node->getMetadataID()) {
default:
llvm_unreachable("Expected uniquable MDNode");
-#define HANDLE_UNIQUABLE_LEAF(CLASS) \
+#define HANDLE_MDNODE_LEAF(CLASS) \
case Metadata::CLASS##Kind: \
- write##CLASS(Out, cast<CLASS>(Uniquable), TypePrinter, Machine, Context); \
+ write##CLASS(Out, cast<CLASS>(Node), TypePrinter, Machine, Context); \
break;
#include "llvm/IR/Metadata.def"
}