Skip to content

Commit 7d80b94

Browse files
author
Jessica Paquette
committed
Add a utility for converting between different types of remarks
This adds llvm-remarkutil. This is intended to be a general tool for doing stuff with/to remark files. This patch gives it the following powers: * `bitstream2yaml` - To convert bitstream remarks to YAML * `yaml2bitstream` - To convert YAML remarks to bitstream remarks These are both implemented as subcommands, like `llvm-remarkutil bitstream2yaml <input_file> -o -` I ran into an issue where I had some bitstream remarks coming from CI, and I wanted to be able to do stuff with them (e.g. visualize them). But then I noticed we didn't have any tooling for doing that, so I decided to write this thing. Being able to output YAML as a start seemed like a good idea, since it would allow people to reuse any tooling they may have written based around YAML remarks. Hopefully it can grow into a more featureful remark utility. :) Currently there are is an outstanding performance issue (see the TODO) with the bitstream2yaml case. I decided that I'd keep the tool small to start with and have the yaml2bitstream and bitstream2yaml cases be symmetric. Also I moved the remarks documentation to its own header because it seems a little out of place with "basic commands" and "developer tools"; it's really kind of its own thing. Differential Revision: https://reviews.llvm.org/D133646
1 parent d90f7cb commit 7d80b94

17 files changed

+329
-2
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
llvm-remarkutil -
2+
==============================================================
3+
4+
.. program:: llvm-remarkutil
5+
6+
SYNOPSIS
7+
--------
8+
9+
:program:`llvm-remarkutil` [*subcommmand*] [*options*]
10+
11+
DESCRIPTION
12+
-----------
13+
14+
Utility for displaying information from, and converting between different
15+
`remark <https://llvm.org/docs/Remarks.html>`_ formats.
16+
17+
Subcommands
18+
-----------
19+
20+
* :ref:`bitstream2yaml_subcommand` - Reserialize bitstream remarks to YAML.
21+
* :ref:`yaml2bitstream_subcommand` - Reserialize YAML remarks to bitstream.
22+
23+
.. _bitstream2yaml_subcommand:
24+
25+
bitstream2yaml
26+
~~~~~~
27+
28+
.. program:: llvm-remarkutil bitstream2yaml
29+
30+
USAGE: :program:`llvm-remarkutil` bitstream2yaml <input file> -o <output file>
31+
32+
Summary
33+
^^^^^^^^^^^
34+
35+
Takes a bitstream remark file as input, and reserializes that file as YAML.
36+
37+
.. _yaml2bitstream_subcommand:
38+
39+
yaml2bitstream
40+
~~~~~~
41+
42+
.. program:: llvm-remarkutil yaml2bitstream
43+
44+
USAGE: :program:`llvm-remarkutil` yaml2bitstream <input file> -o <output file>
45+
46+
Summary
47+
^^^^^^^^^^^
48+
49+
Takes a YAML remark file as input, and reserializes that file in the bitstream
50+
format.

llvm/docs/CommandGuide/index.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Basic Commands
3333
llvm-otool
3434
llvm-profdata
3535
llvm-readobj
36-
llvm-remark-size-diff
3736
llvm-stress
3837
llvm-symbolizer
3938
opt
@@ -86,3 +85,12 @@ Developer Tools
8685
llvm-pdbutil
8786
llvm-profgen
8887
llvm-tli-checker
88+
89+
Remarks Tools
90+
~~~~~~~~~~~~~~
91+
92+
.. toctree::
93+
:maxdepth: 1
94+
95+
llvm-remark-size-diff
96+
llvm-remarkutil

llvm/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ set(LLVM_TEST_DEPENDS
118118
llvm-readelf
119119
llvm-reduce
120120
llvm-remark-size-diff
121+
llvm-remarkutil
121122
llvm-rtdyld
122123
llvm-sim
123124
llvm-size

llvm/test/lit.cfg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def get_asan_rtlib():
171171
'llvm-tblgen', 'llvm-tapi-diff', 'llvm-undname', 'llvm-windres',
172172
'llvm-c-test', 'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml',
173173
'yaml-bench', 'verify-uselistorder', 'bugpoint', 'llc', 'llvm-symbolizer',
174-
'opt', 'sancov', 'sanstats'])
174+
'opt', 'sancov', 'sanstats', 'llvm-remarkutil'])
175175

176176
# The following tools are optional
177177
tools.extend([
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- !Analysis
2+
Name: StackSize
3+
Function: func0
4+
Args:
5+
- NumStackBytes: '1'
6+
- String: ' stack bytes in function'
7+
...
8+
--- !Analysis
9+
Pass: asm-printer
10+
Name: InstructionCount
11+
Function: func0
12+
Args:
13+
- NumInstructions: '1'
14+
- String: ' instructions in function'
15+
...
Binary file not shown.

llvm/test/tools/llvm-remarkutil/Inputs/empty-file

Whitespace-only changes.
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--- !Analysis
2+
Pass: prologepilog
3+
Name: StackSize
4+
Function: func0
5+
Args:
6+
- NumStackBytes: '1'
7+
- String: ' stack bytes in function'
8+
...
9+
--- !Analysis
10+
Pass: asm-printer
11+
Name: InstructionCount
12+
Function: func0
13+
Args:
14+
- NumInstructions: '1'
15+
- String: ' instructions in function'
16+
...
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RUN: not llvm-remarkutil bitstream2yaml %p/Inputs/broken-remark -o - 2>&1 | FileCheck %s
2+
CHECK: error: Unknown magic number: expecting RMRK, got --- .

0 commit comments

Comments
 (0)