[all-commits] [llvm/llvm-project] b2d078: [IR]PATCH 1/2: Add AsmWriterContext into AsmWriter
Min-Yih Hsu via All-commits
all-commits at lists.llvm.org
Sat Oct 2 21:21:34 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: b2d078fb0cac9e31eae616211275925a4d858f09
https://github.com/llvm/llvm-project/commit/b2d078fb0cac9e31eae616211275925a4d858f09
Author: Min-Yih Hsu <minyihh at uci.edu>
Date: 2021-10-02 (Sat, 02 Oct 2021)
Changed paths:
M llvm/lib/IR/AsmWriter.cpp
Log Message:
-----------
[IR]PATCH 1/2: Add AsmWriterContext into AsmWriter
AsmWriterContext is a simple compound that stores TypePrinting,
SlotTracker (i.e. "Machine" in AsmWriter), and Module instances -- three
of the most commonly used objects in the AsmWriter infrastructure.
Previously these three objects are passed as separate function arguments
to most of the printer functions in this file. Tidying them up can bring
easier code refactoring on printer functions in the future (e.g. when we
want to pass additional objects to all printer functions).
NOTE: Theoritically, this patch should be NFC.
Differential Revision: https://reviews.llvm.org/D110112
Commit: 475de8da011c8ae79c453fa43593ec5b35f52962
https://github.com/llvm/llvm-project/commit/475de8da011c8ae79c453fa43593ec5b35f52962
Author: Min-Yih Hsu <minyihh at uci.edu>
Date: 2021-10-02 (Sat, 02 Oct 2021)
Changed paths:
M llvm/include/llvm/IR/Metadata.h
M llvm/lib/IR/AsmWriter.cpp
M llvm/unittests/IR/MetadataTest.cpp
Log Message:
-----------
[IR]PATCH 2/2: Add MDNode::printTree and dumpTree
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.
Differential Revision: https://reviews.llvm.org/D110113
Compare: https://github.com/llvm/llvm-project/compare/d6a4294d1362...475de8da011c
More information about the All-commits
mailing list