[PATCH] D110113: [IR]PATCH 2/2: Add MDNode::printTree and dumpTree

Min-Yih Hsu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 20 16:27:41 PDT 2021


myhsu created this revision.
myhsu added reviewers: aprantl, Orlando.
Herald added subscribers: dexonsmith, hiraditya.
myhsu requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch adds the functionalities to print MDNode in tree shape. For example, instead of printing a MDNode like this:

  <0x5643e1166888> = !DILocalVariable(name: "foo", arg: 2, scope: <0x5643e11c9740>, file: <0x5643e11c6ec0>, line: 8, type: <0x5643e11ca8e0>, flags: DIFlagPublic | DIFlagFwdDecl, align: 8)

The printTree/dumpTree functions can give you:

  <0x5643e1166888> = !DILocalVariable(name: "foo", arg: 2, scope: <0x5643e11c9740>, file: <0x5643e11c6ec0>, line: 8, type: <0x5643e11ca8e0>, flags: DIFlagPublic | DIFlagFwdDecl, align: 8)
    <0x5643e11c9740> = distinct !DISubprogram(scope: null, spFlags: 0)
    <0x5643e11c6ec0> = distinct !DIFile(filename: "file.c", directory: "/path/to/dir")
    <0x5643e11ca8e0> = distinct !DIDerivedType(tag: DW_TAG_pointer_type, baseType: <0x5643e11668d8>, size: 1, align: 2)
      <0x5643e11668d8> = !DIBasicType(tag: DW_TAG_unspecified_type, name: "basictype")

Which is useful when using it in debugger. Where sometimes printing the whole module to see all MDNodes is too expensive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D110113

Files:
  llvm/include/llvm/IR/Metadata.h
  llvm/lib/IR/AsmWriter.cpp
  llvm/unittests/IR/MetadataTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110113.373742.patch
Type: text/x-patch
Size: 7695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210920/853d40b5/attachment.bin>


More information about the llvm-commits mailing list