summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-12-16 07:09:37 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-12-16 07:09:37 +0000
commitfee167fcc0d212656cd3f15d2181d2bc044326a9 (patch)
tree49557c432bc713183969ea0a579d7861ecc5d67e /llvm/lib
parent68c37245d38d1d4d3e587e2e24a49aff4d55b5b4 (diff)
downloadbcm5719-llvm-fee167fcc0d212656cd3f15d2181d2bc044326a9.tar.gz
bcm5719-llvm-fee167fcc0d212656cd3f15d2181d2bc044326a9.zip
IR: Make MDNode::dump() useful by adding addresses
It's horrible to inspect `MDNode`s in a debugger. All of their operands that are `MDNode`s get dumped as `<badref>`, since we can't assign metadata slots in the context of a `Metadata::dump()`. (Why not? Why not assign numbers lazily? Because then each time you called `dump()`, a given `MDNode` could have a different lazily assigned number.) Fortunately, the C memory model gives us perfectly good identifiers for `MDNode`. Add pointer addresses to the dumps, transforming this: (lldb) e N->dump() !{i32 662302, i32 26, <badref>, null} (lldb) e ((MDNode*)N->getOperand(2))->dump() !{i32 4, !"foo"} into: (lldb) e N->dump() !{i32 662302, i32 26, <0x100706ee0>, null} (lldb) e ((MDNode*)0x100706ee0)->dump() !{i32 4, !"foo"} and this: (lldb) e N->dump() 0x101200248 = !{<badref>, <badref>, <badref>, <badref>, <badref>} (lldb) e N->getOperand(0) (const llvm::MDOperand) $0 = { MD = 0x00000001012004e0 } (lldb) e N->getOperand(1) (const llvm::MDOperand) $1 = { MD = 0x00000001012004e0 } (lldb) e N->getOperand(2) (const llvm::MDOperand) $2 = { MD = 0x0000000101200058 } (lldb) e N->getOperand(3) (const llvm::MDOperand) $3 = { MD = 0x00000001012004e0 } (lldb) e N->getOperand(4) (const llvm::MDOperand) $4 = { MD = 0x0000000101200058 } (lldb) e ((MDNode*)0x00000001012004e0)->dump() !{} (lldb) e ((MDNode*)0x0000000101200058)->dump() !{null} into: (lldb) e N->dump() !{<0x1012004e0>, <0x1012004e0>, <0x101200058>, <0x1012004e0>, <0x101200058>} (lldb) e ((MDNode*)0x1012004e0)->dump() !{} (lldb) e ((MDNode*)0x101200058)->dump() !{null} llvm-svn: 224325
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/AsmWriter.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 6153e350e98..1d867fc8371 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1362,7 +1362,9 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Metadata *MD,
Machine = new SlotTracker(Context);
int Slot = Machine->getMetadataSlot(N);
if (Slot == -1)
- Out << "<badref>";
+ // Give the pointer value instead of "badref", since this comes up all
+ // the time when debugging.
+ Out << "<" << N << ">";
else
Out << '!' << Slot;
return;
OpenPOWER on IntegriCloud