File: Remarks.html

package info (click to toggle)
llvm-toolchain-13 1%3A13.0.1-6~deb10u4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,418,792 kB
  • sloc: cpp: 5,290,827; ansic: 996,570; asm: 544,593; python: 188,212; objc: 72,027; lisp: 30,291; f90: 25,395; sh: 24,900; javascript: 9,780; pascal: 9,398; perl: 7,484; ml: 5,432; awk: 3,523; makefile: 2,892; xml: 953; cs: 573; fortran: 539
file content (835 lines) | stat: -rw-r--r-- 51,118 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835


<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Remarks &#8212; LLVM 13 documentation</title>
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/llvm-theme.css" type="text/css" />
    <script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Source Level Debugging with LLVM" href="SourceLevelDebugging.html" />
    <link rel="prev" title="Reporting Guide" href="ReportingGuide.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head><body>
<div class="logo">
  <a href="index.html">
    <img src="_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="SourceLevelDebugging.html" title="Source Level Debugging with LLVM"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="ReportingGuide.html" title="Reporting Guide"
             accesskey="P">previous</a> |</li>
  <li><a href="https://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="UserGuides.html" accesskey="U">User Guides</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Remarks</a></li> 
      </ul>
    </div>

      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">

<h3>Documentation</h3>

<ul class="want-points">
    <li><a href="https://llvm.org/docs/GettingStartedTutorials.html">Getting Started/Tutorials</a></li>
    <li><a href="https://llvm.org/docs/UserGuides.html">User Guides</a></li>
    <li><a href="https://llvm.org/docs/Reference.html">Reference</a></li>
</ul>

<h3>Getting Involved</h3>

<ul class="want-points">
    <li><a href="https://llvm.org/docs/Contributing.html">Contributing to LLVM</a></li>
    <li><a href="https://llvm.org/docs/HowToSubmitABug.html">Submitting Bug Reports</a></li>
    <li><a href="https://llvm.org/docs/GettingInvolved.html#mailing-lists">Mailing Lists</a></li>
    <li><a href="https://llvm.org/docs/GettingInvolved.html#irc">IRC</a></li>
    <li><a href="https://llvm.org/docs/GettingInvolved.html#meetups-and-social-events">Meetups and Social Events</a></li>
</ul>

<h3>Additional Links</h3>

<ul class="want-points">
    <li><a href="https://llvm.org/docs/FAQ.html">FAQ</a></li>
    <li><a href="https://llvm.org/docs/Lexicon.html">Glossary</a></li>
    <li><a href="https://llvm.org/pubs">Publications</a></li>
    <li><a href="https://github.com/llvm/llvm-project//">Github Repository</a></li>
</ul>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/Remarks.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="remarks">
<h1>Remarks<a class="headerlink" href="#remarks" title="Permalink to this headline">¶</a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#introduction-to-the-llvm-remark-diagnostics" id="id1">Introduction to the LLVM remark diagnostics</a></p></li>
<li><p><a class="reference internal" href="#enabling-optimization-remarks" id="id2">Enabling optimization remarks</a></p>
<ul>
<li><p><a class="reference internal" href="#remark-diagnostics" id="id3">Remark diagnostics</a></p></li>
<li><p><a class="reference internal" href="#serialized-remarks" id="id4">Serialized remarks</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#serialization-modes" id="id5">Serialization modes</a></p></li>
<li><p><a class="reference internal" href="#yaml-remarks" id="id6">YAML remarks</a></p>
<ul>
<li><p><a class="reference internal" href="#yaml-with-a-string-table" id="id7">YAML with a string table</a></p></li>
<li><p><a class="reference internal" href="#yaml-metadata" id="id8">YAML metadata</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#llvm-bitstream-remarks" id="id9">LLVM bitstream remarks</a></p>
<ul>
<li><p><a class="reference internal" href="#meta-block" id="id10">META_BLOCK</a></p></li>
<li><p><a class="reference internal" href="#remark-block" id="id11">REMARK_BLOCK</a></p></li>
<li><p><a class="reference internal" href="#the-remark-container" id="id12">The remark container</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#opt-viewer" id="id13">opt-viewer</a></p>
<ul>
<li><p><a class="reference internal" href="#opt-viewer-py" id="id14">opt-viewer.py</a></p></li>
<li><p><a class="reference internal" href="#opt-stats-py" id="id15">opt-stats.py</a></p></li>
<li><p><a class="reference internal" href="#opt-diff-py" id="id16">opt-diff.py</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#emitting-remark-diagnostics-in-the-object-file" id="id17">Emitting remark diagnostics in the object file</a></p></li>
<li><p><a class="reference internal" href="#c-api" id="id18">C API</a></p></li>
<li><p><a class="reference internal" href="#remark-streamers" id="id19">Remark streamers</a></p></li>
</ul>
</div>
<div class="section" id="introduction-to-the-llvm-remark-diagnostics">
<h2><a class="toc-backref" href="#id1">Introduction to the LLVM remark diagnostics</a><a class="headerlink" href="#introduction-to-the-llvm-remark-diagnostics" title="Permalink to this headline">¶</a></h2>
<p>LLVM is able to emit diagnostics from passes describing whether an optimization
has been performed or missed for a particular reason, which should give more
insight to users about what the compiler did during the compilation pipeline.</p>
<p>There are three main remark types:</p>
<p><code class="docutils literal notranslate"><span class="pre">Passed</span></code></p>
<blockquote>
<div><p>Remarks that describe a successful optimization performed by the compiler.</p>
<dl class="field-list simple">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">foo</span> <span class="n">inlined</span> <span class="n">into</span> <span class="n">bar</span> <span class="k">with</span> <span class="p">(</span><span class="n">cost</span><span class="o">=</span><span class="n">always</span><span class="p">):</span> <span class="n">always</span> <span class="n">inline</span> <span class="n">attribute</span>
</pre></div>
</div>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">Missed</span></code></p>
<blockquote>
<div><p>Remarks that describe an attempt to an optimization by the compiler that
could not be performed.</p>
<dl class="field-list simple">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">foo</span> <span class="ow">not</span> <span class="n">inlined</span> <span class="n">into</span> <span class="n">bar</span> <span class="n">because</span> <span class="n">it</span> <span class="n">should</span> <span class="n">never</span> <span class="n">be</span> <span class="n">inlined</span>
<span class="p">(</span><span class="n">cost</span><span class="o">=</span><span class="n">never</span><span class="p">):</span> <span class="n">noinline</span> <span class="n">function</span> <span class="n">attribute</span>
</pre></div>
</div>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">Analysis</span></code></p>
<blockquote>
<div><p>Remarks that describe the result of an analysis, that can bring more
information to the user regarding the generated code.</p>
<dl class="field-list simple">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">16</span> <span class="n">stack</span> <span class="nb">bytes</span> <span class="ow">in</span> <span class="n">function</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">10</span> <span class="n">instructions</span> <span class="ow">in</span> <span class="n">function</span>
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="enabling-optimization-remarks">
<h2><a class="toc-backref" href="#id2">Enabling optimization remarks</a><a class="headerlink" href="#enabling-optimization-remarks" title="Permalink to this headline">¶</a></h2>
<p>There are two modes that are supported for enabling optimization remarks in
LLVM: through remark diagnostics, or through serialized remarks.</p>
<div class="section" id="remark-diagnostics">
<h3><a class="toc-backref" href="#id3">Remark diagnostics</a><a class="headerlink" href="#remark-diagnostics" title="Permalink to this headline">¶</a></h3>
<p>Optimization remarks can be emitted as diagnostics. These diagnostics will be
propagated to front-ends if desired, or emitted by tools like <a class="reference internal" href="CommandGuide/llc.html"><span class="doc">llc</span></a> or <a class="reference internal" href="CommandGuide/opt.html"><span class="doc">opt</span></a>.</p>
<dl class="std option">
<dt id="cmdoption-pass-remarks">
<code class="sig-name descname"><span class="pre">-pass-remarks</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;regex&gt;</span></code><a class="headerlink" href="#cmdoption-pass-remarks" title="Permalink to this definition">¶</a></dt>
<dd><p>Enables optimization remarks from passes whose name match the given (POSIX)
regular expression.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-pass-remarks-missed">
<code class="sig-name descname"><span class="pre">-pass-remarks-missed</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;regex&gt;</span></code><a class="headerlink" href="#cmdoption-pass-remarks-missed" title="Permalink to this definition">¶</a></dt>
<dd><p>Enables missed optimization remarks from passes whose name match the given
(POSIX) regular expression.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-pass-remarks-analysis">
<code class="sig-name descname"><span class="pre">-pass-remarks-analysis</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;regex&gt;</span></code><a class="headerlink" href="#cmdoption-pass-remarks-analysis" title="Permalink to this definition">¶</a></dt>
<dd><p>Enables optimization analysis remarks from passes whose name match the given
(POSIX) regular expression.</p>
</dd></dl>

</div>
<div class="section" id="serialized-remarks">
<h3><a class="toc-backref" href="#id4">Serialized remarks</a><a class="headerlink" href="#serialized-remarks" title="Permalink to this headline">¶</a></h3>
<p>While diagnostics are useful during development, it is often more useful to
refer to optimization remarks post-compilation, typically during performance
analysis.</p>
<p>For that, LLVM can serialize the remarks produced for each compilation unit to
a file that can be consumed later.</p>
<p>By default, the format of the serialized remarks is <a class="reference internal" href="#yamlremarks"><span class="std std-ref">YAML</span></a>, and it can be accompanied by a <a class="reference internal" href="#remarkssection"><span class="std std-ref">section</span></a>
in the object files to easily retrieve it.</p>
<p><a class="reference internal" href="CommandGuide/llc.html"><span class="doc">llc</span></a> and <a class="reference internal" href="CommandGuide/opt.html"><span class="doc">opt</span></a> support the
following options:</p>
<p><code class="docutils literal notranslate"><span class="pre">Basic</span> <span class="pre">options</span></code></p>
<blockquote>
<div><dl class="std option">
<dt id="cmdoption-pass-remarks-output">
<code class="sig-name descname"><span class="pre">-pass-remarks-output</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;filename&gt;</span></code><a class="headerlink" href="#cmdoption-pass-remarks-output" title="Permalink to this definition">¶</a></dt>
<dd><p>Enables the serialization of remarks to a file specified in &lt;filename&gt;.</p>
<p>By default, the output is serialized to <a class="reference internal" href="#yamlremarks"><span class="std std-ref">YAML</span></a>.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-pass-remarks-format">
<code class="sig-name descname"><span class="pre">-pass-remarks-format</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;format&gt;</span></code><a class="headerlink" href="#cmdoption-pass-remarks-format" title="Permalink to this definition">¶</a></dt>
<dd><p>Specifies the output format of the serialized remarks.</p>
<p>Supported formats:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#yamlremarks"><span class="std std-ref">yaml</span></a> (default)</p></li>
<li><p><a class="reference internal" href="#yamlstrtabremarks"><span class="std std-ref">yaml-strtab</span></a></p></li>
<li><p><a class="reference internal" href="#bitstreamremarks"><span class="std std-ref">bitstream</span></a></p></li>
</ul>
</dd></dl>

</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">Content</span> <span class="pre">configuration</span></code></p>
<blockquote>
<div><dl class="std option">
<dt id="cmdoption-pass-remarks-filter">
<code class="sig-name descname"><span class="pre">-pass-remarks-filter</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;regex&gt;</span></code><a class="headerlink" href="#cmdoption-pass-remarks-filter" title="Permalink to this definition">¶</a></dt>
<dd><p>Only passes whose name match the given (POSIX) regular expression will be
serialized to the final output.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-pass-remarks-with-hotness">
<code class="sig-name descname"><span class="pre">-pass-remarks-with-hotness</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pass-remarks-with-hotness" title="Permalink to this definition">¶</a></dt>
<dd><p>With PGO, include profile count in optimization remarks.</p>
</dd></dl>

<dl class="std option">
<dt id="cmdoption-pass-remarks-hotness-threshold">
<code class="sig-name descname"><span class="pre">-pass-remarks-hotness-threshold</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-pass-remarks-hotness-threshold" title="Permalink to this definition">¶</a></dt>
<dd><p>The minimum profile count required for an optimization remark to be
emitted.</p>
</dd></dl>

</div></blockquote>
<p>Other tools that support remarks:</p>
<p><strong class="program">llvm-lto</strong></p>
<blockquote>
<div><dl class="std option">
<dt id="cmdoption-lto-pass-remarks-output">
<code class="sig-name descname"><span class="pre">-lto-pass-remarks-output</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;filename&gt;</span></code><a class="headerlink" href="#cmdoption-lto-pass-remarks-output" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-lto-pass-remarks-filter">
<code class="sig-name descname"><span class="pre">-lto-pass-remarks-filter</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;regex&gt;</span></code><a class="headerlink" href="#cmdoption-lto-pass-remarks-filter" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-lto-pass-remarks-format">
<code class="sig-name descname"><span class="pre">-lto-pass-remarks-format</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;format&gt;</span></code><a class="headerlink" href="#cmdoption-lto-pass-remarks-format" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-lto-pass-remarks-with-hotness">
<code class="sig-name descname"><span class="pre">-lto-pass-remarks-with-hotness</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lto-pass-remarks-with-hotness" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-lto-pass-remarks-hotness-threshold">
<code class="sig-name descname"><span class="pre">-lto-pass-remarks-hotness-threshold</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-lto-pass-remarks-hotness-threshold" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</div></blockquote>
<p><strong class="program">gold-plugin</strong> and <strong class="program">lld</strong></p>
<blockquote>
<div><dl class="std option">
<dt id="cmdoption-opt-remarks-filename">
<code class="sig-name descname"><span class="pre">-opt-remarks-filename</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;filename&gt;</span></code><a class="headerlink" href="#cmdoption-opt-remarks-filename" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-opt-remarks-filter">
<code class="sig-name descname"><span class="pre">-opt-remarks-filter</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;regex&gt;</span></code><a class="headerlink" href="#cmdoption-opt-remarks-filter" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-opt-remarks-format">
<code class="sig-name descname"><span class="pre">-opt-remarks-format</span></code><code class="sig-prename descclassname"><span class="pre">=&lt;format&gt;</span></code><a class="headerlink" href="#cmdoption-opt-remarks-format" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="std option">
<dt id="cmdoption-opt-remarks-with-hotness">
<code class="sig-name descname"><span class="pre">-opt-remarks-with-hotness</span></code><code class="sig-prename descclassname"></code><a class="headerlink" href="#cmdoption-opt-remarks-with-hotness" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</div></blockquote>
</div>
</div>
<div class="section" id="serialization-modes">
<h2><a class="toc-backref" href="#id5">Serialization modes</a><a class="headerlink" href="#serialization-modes" title="Permalink to this headline">¶</a></h2>
<p>There are two modes available for serializing remarks:</p>
<p><code class="docutils literal notranslate"><span class="pre">Separate</span></code></p>
<blockquote>
<div><p>In this mode, the remarks and the metadata are serialized separately. The
client is responsible for parsing the metadata first, then use the metadata
to correctly parse the remarks.</p>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">Standalone</span></code></p>
<blockquote>
<div><p>In this mode, the remarks and the metadata are serialized to the same
stream. The metadata will always come before the remarks.</p>
<p>The compiler does not support emitting standalone remarks. This mode is
more suited for post-processing tools like linkers, that can merge the
remarks for one whole project.</p>
</div></blockquote>
</div>
<div class="section" id="yaml-remarks">
<span id="yamlremarks"></span><h2><a class="toc-backref" href="#id6">YAML remarks</a><a class="headerlink" href="#yaml-remarks" title="Permalink to this headline">¶</a></h2>
<p>A typical remark serialized to YAML looks like this:</p>
<div class="highlight-yaml notranslate"><div class="highlight"><pre><span></span><span class="nn">---</span> <span class="kt">!&lt;TYPE&gt;</span>
<span class="nt">Pass</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">&lt;pass&gt;</span>
<span class="nt">Name</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">&lt;name&gt;</span>
<span class="nt">DebugLoc</span><span class="p">:</span> <span class="p p-Indicator">{</span><span class="nt"> File</span><span class="p">:</span> <span class="nv">&lt;file&gt;</span><span class="p p-Indicator">,</span><span class="nt"> Line</span><span class="p">:</span> <span class="nv">&lt;line&gt;</span><span class="p p-Indicator">,</span><span class="nt"> Column</span><span class="p">:</span> <span class="nv">&lt;column&gt;</span> <span class="p p-Indicator">}</span>
<span class="nt">Function</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">&lt;function&gt;</span>
<span class="nt">Hotness</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">&lt;hotness&gt;</span>
<span class="nt">Args</span><span class="p">:</span>
  <span class="p p-Indicator">-</span> <span class="nt">&lt;key&gt;</span><span class="p">:</span> <span class="l l-Scalar l-Scalar-Plain">&lt;value&gt;</span>
    <span class="nt">DebugLoc</span><span class="p">:</span> <span class="p p-Indicator">{</span><span class="nt"> File</span><span class="p">:</span> <span class="nv">&lt;arg-file&gt;</span><span class="p p-Indicator">,</span><span class="nt"> Line</span><span class="p">:</span> <span class="nv">&lt;arg-line&gt;</span><span class="p p-Indicator">,</span><span class="nt"> Column</span><span class="p">:</span> <span class="nv">&lt;arg-column&gt;</span> <span class="p p-Indicator">}</span>
</pre></div>
</div>
<p>The following entries are mandatory:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;TYPE&gt;</span></code>: can be <code class="docutils literal notranslate"><span class="pre">Passed</span></code>, <code class="docutils literal notranslate"><span class="pre">Missed</span></code>, <code class="docutils literal notranslate"><span class="pre">Analysis</span></code>,
<code class="docutils literal notranslate"><span class="pre">AnalysisFPCommute</span></code>, <code class="docutils literal notranslate"><span class="pre">AnalysisAliasing</span></code>, <code class="docutils literal notranslate"><span class="pre">Failure</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;pass&gt;</span></code>: the name of the pass that emitted this remark.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;name&gt;</span></code>: the name of the remark coming from <code class="docutils literal notranslate"><span class="pre">&lt;pass&gt;</span></code>.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;function&gt;</span></code>: the mangled name of the function.</p></li>
</ul>
<p>If a <code class="docutils literal notranslate"><span class="pre">DebugLoc</span></code> entry is specified, the following fields are required:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;file&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;line&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;column&gt;</span></code></p></li>
</ul>
<p>If an <code class="docutils literal notranslate"><span class="pre">arg</span></code> entry is specified, the following fields are required:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;key&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;value&gt;</span></code></p></li>
</ul>
<p>If a <code class="docutils literal notranslate"><span class="pre">DebugLoc</span></code> entry is specified within an <code class="docutils literal notranslate"><span class="pre">arg</span></code> entry, the following
fields are required:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;arg-file&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;arg-line&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;arg-column&gt;</span></code></p></li>
</ul>
<div class="section" id="yaml-with-a-string-table">
<span id="yamlstrtabremarks"></span><h3><a class="toc-backref" href="#id7">YAML with a string table</a><a class="headerlink" href="#yaml-with-a-string-table" title="Permalink to this headline">¶</a></h3>
<p>The YAML serialization supports the usage of a string table by using the
<code class="docutils literal notranslate"><span class="pre">yaml-strtab</span></code> format.</p>
<p>This format replaces strings in the YAML output with integers representing the
index in the string table that can be provided separately through metadata.</p>
<p>The following entries can take advantage of the string table while respecting
YAML rules:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;pass&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;name&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;function&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;file&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;value&gt;</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">&lt;arg-file&gt;</span></code></p></li>
</ul>
<p>Currently, none of the tools in <a class="reference internal" href="#optviewer"><span class="std std-ref">the opt-viewer directory</span></a>
support this format.</p>
</div>
<div class="section" id="yaml-metadata">
<span id="optviewer"></span><h3><a class="toc-backref" href="#id8">YAML metadata</a><a class="headerlink" href="#yaml-metadata" title="Permalink to this headline">¶</a></h3>
<p>The metadata used together with the YAML format is:</p>
<ul class="simple">
<li><p>a magic number: “REMARKS\0”</p></li>
<li><p>the version number: a little-endian uint64_t</p></li>
<li><p>the total size of the string table (the size itself excluded):
little-endian uint64_t</p></li>
<li><p>a list of null-terminated strings</p></li>
</ul>
<p>Optional:</p>
<ul class="simple">
<li><p>the absolute file path to the serialized remark diagnostics: a
null-terminated string.</p></li>
</ul>
<p>When the metadata is serialized separately from the remarks, the file path
should be present and point to the file where the remarks are serialized to.</p>
<p>In case the metadata only acts as a header to the remarks, the file path can be
omitted.</p>
</div>
</div>
<div class="section" id="llvm-bitstream-remarks">
<span id="bitstreamremarks"></span><h2><a class="toc-backref" href="#id9">LLVM bitstream remarks</a><a class="headerlink" href="#llvm-bitstream-remarks" title="Permalink to this headline">¶</a></h2>
<p>This format is using <a class="reference internal" href="BitCodeFormat.html"><span class="doc">LLVM bitstream</span></a> to serialize remarks
and their associated metadata.</p>
<p>A bitstream remark stream can be identified by the magic number <code class="docutils literal notranslate"><span class="pre">&quot;RMRK&quot;</span></code> that
is placed at the very beginning.</p>
<p>The format for serializing remarks is composed of two different block types:</p>
<div class="section" id="meta-block">
<span id="bitstreamremarksmetablock"></span><h3><a class="toc-backref" href="#id10">META_BLOCK</a><a class="headerlink" href="#meta-block" title="Permalink to this headline">¶</a></h3>
<p>The block providing information about the rest of the content in the stream.</p>
<p>Exactly one block is expected. Having multiple metadata blocks is an error.</p>
<p>This block can contain the following records:</p>
<p id="bitstreamremarksrecordmetacontainerinfo"><code class="docutils literal notranslate"><span class="pre">RECORD_META_CONTAINER_INFO</span></code></p>
<blockquote>
<div><p>The container version and type.</p>
<p>Version: u32</p>
<p>Type:    u2</p>
</div></blockquote>
<p id="bitstreamremarksrecordmetaremarkversion"><code class="docutils literal notranslate"><span class="pre">RECORD_META_REMARK_VERSION</span></code></p>
<blockquote>
<div><p>The version of the remark entries. This can change independently from the
container version.</p>
<p>Version: u32</p>
</div></blockquote>
<p id="bitstreamremarksrecordmetastrtab"><code class="docutils literal notranslate"><span class="pre">RECORD_META_STRTAB</span></code></p>
<blockquote>
<div><p>The string table used by the remark entries. The format of the string table
is a sequence of strings separated by <code class="docutils literal notranslate"><span class="pre">\0</span></code>.</p>
</div></blockquote>
<p id="bitstreamremarksrecordmetaexternalfile"><code class="docutils literal notranslate"><span class="pre">RECORD_META_EXTERNAL_FILE</span></code></p>
<blockquote>
<div><p>The external remark file path that contains the remark blocks associated
with this metadata. This is an absolute path.</p>
</div></blockquote>
</div>
<div class="section" id="remark-block">
<span id="bitstreamremarksremarkblock"></span><h3><a class="toc-backref" href="#id11">REMARK_BLOCK</a><a class="headerlink" href="#remark-block" title="Permalink to this headline">¶</a></h3>
<p>The block describing a remark entry.</p>
<p>0 or more blocks per file are allowed. Each block will depend on the
<a class="reference internal" href="#bitstreamremarksmetablock"><span class="std std-ref">META_BLOCK</span></a> in order to be parsed correctly.</p>
<p>This block can contain the following records:</p>
<p><code class="docutils literal notranslate"><span class="pre">RECORD_REMARK_HEADER</span></code></p>
<blockquote>
<div><p>The header of the remark. This contains all the mandatory information about
a remark.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 36%" />
<col style="width: 64%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Type</p></td>
<td><p>u3</p></td>
</tr>
<tr class="row-even"><td><p>Remark name</p></td>
<td><p>VBR6 (string table index)</p></td>
</tr>
<tr class="row-odd"><td><p>Pass name</p></td>
<td><p>VBR6 (string table index)</p></td>
</tr>
<tr class="row-even"><td><p>Function name</p></td>
<td><p>VBR6 (string table index)</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">RECORD_REMARK_DEBUG_LOC</span></code></p>
<blockquote>
<div><p>The source location for the corresponding remark. This record is optional.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 23%" />
<col style="width: 77%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>File</p></td>
<td><p>VBR7 (string table index)</p></td>
</tr>
<tr class="row-even"><td><p>Line</p></td>
<td><p>u32</p></td>
</tr>
<tr class="row-odd"><td><p>Column</p></td>
<td><p>u32</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">RECORD_REMARK_HOTNESS</span></code></p>
<blockquote>
<div><p>The hotness of the remark. This record is optional.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 42%" />
<col style="width: 58%" />
</colgroup>
<tbody>
<tr class="row-odd"><td colspan="2"><p>Hotness | VBR8 (string table index)</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">RECORD_REMARK_ARG_WITH_DEBUGLOC</span></code></p>
<blockquote>
<div><p>A remark argument with an associated debug location.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 23%" />
<col style="width: 77%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Key</p></td>
<td><p>VBR7 (string table index)</p></td>
</tr>
<tr class="row-even"><td><p>Value</p></td>
<td><p>VBR7 (string table index)</p></td>
</tr>
<tr class="row-odd"><td><p>File</p></td>
<td><p>VBR7 (string table index)</p></td>
</tr>
<tr class="row-even"><td><p>Line</p></td>
<td><p>u32</p></td>
</tr>
<tr class="row-odd"><td><p>Column</p></td>
<td><p>u32</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">RECORD_REMARK_ARG_WITHOUT_DEBUGLOC</span></code></p>
<blockquote>
<div><p>A remark argument with an associated debug location.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 23%" />
<col style="width: 77%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Key</p></td>
<td><p>VBR7 (string table index)</p></td>
</tr>
<tr class="row-even"><td><p>Value</p></td>
<td><p>VBR7 (string table index)</p></td>
</tr>
</tbody>
</table>
</div></blockquote>
</div>
<div class="section" id="the-remark-container">
<h3><a class="toc-backref" href="#id12">The remark container</a><a class="headerlink" href="#the-remark-container" title="Permalink to this headline">¶</a></h3>
<p>Bitstream remarks are designed to be used in two different modes:</p>
<p><code class="docutils literal notranslate"><span class="pre">The</span> <span class="pre">separate</span> <span class="pre">mode</span></code></p>
<blockquote>
<div><p>The separate mode is the mode that is typically used during compilation. It
provides a way to serialize the remark entries to a stream while some
metadata is kept in memory to be emitted in the product of the compilation
(typically, an object file).</p>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">The</span> <span class="pre">standalone</span> <span class="pre">mode</span></code></p>
<blockquote>
<div><p>The standalone mode is typically stored and used after the distribution of
a program. It contains all the information that allows the parsing of all
the remarks without having any external dependencies.</p>
</div></blockquote>
<p>In order to support multiple modes, the format introduces the concept of a
bitstream remark container type.</p>
<p id="bitstreamremarksseparateremarksmeta"><code class="docutils literal notranslate"><span class="pre">SeparateRemarksMeta:</span> <span class="pre">the</span> <span class="pre">metadata</span> <span class="pre">emitted</span> <span class="pre">separately</span></code></p>
<blockquote>
<div><p>This container type expects only a <a class="reference internal" href="#bitstreamremarksmetablock"><span class="std std-ref">META_BLOCK</span></a> containing only:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetacontainerinfo"><span class="std std-ref">RECORD_META_CONTAINER_INFO</span></a></p></li>
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetastrtab"><span class="std std-ref">RECORD_META_STRTAB</span></a></p></li>
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetaexternalfile"><span class="std std-ref">RECORD_META_EXTERNAL_FILE</span></a></p></li>
</ul>
<p>Typically, this is emitted in a section in the object files, allowing
clients to retrieve remarks and their associated metadata directly from
intermediate products.</p>
</div></blockquote>
<p><code class="docutils literal notranslate"><span class="pre">SeparateRemarksFile:</span> <span class="pre">the</span> <span class="pre">remark</span> <span class="pre">entries</span> <span class="pre">emitted</span> <span class="pre">separately</span></code></p>
<blockquote>
<div><p>This container type expects only a <a class="reference internal" href="#bitstreamremarksmetablock"><span class="std std-ref">META_BLOCK</span></a> containing only:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetacontainerinfo"><span class="std std-ref">RECORD_META_CONTAINER_INFO</span></a></p></li>
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetaremarkversion"><span class="std std-ref">RECORD_META_REMARK_VERSION</span></a></p></li>
</ul>
<p>This container type expects 0 or more <a class="reference internal" href="#bitstreamremarksremarkblock"><span class="std std-ref">REMARK_BLOCK</span></a>.</p>
<p>Typically, this is emitted in a side-file alongside an object file, and is
made to be able to stream to without increasing the memory consumption of
the compiler. This is referenced by the <a class="reference internal" href="#bitstreamremarksrecordmetaexternalfile"><span class="std std-ref">RECORD_META_EXTERNAL_FILE</span></a> entry in the
<a class="reference internal" href="#bitstreamremarksseparateremarksmeta"><span class="std std-ref">SeparateRemarksMeta</span></a> container.</p>
</div></blockquote>
<p>When the parser tries to parse a container that contains the metadata for the
separate remarks, it should parse the version and type, then keep the string
table in memory while opening the external file, validating its metadata and
parsing the remark entries.</p>
<p>The container versions from the separate container should match in order to
have a well-formed file.</p>
<p><code class="docutils literal notranslate"><span class="pre">Standalone:</span> <span class="pre">the</span> <span class="pre">metadata</span> <span class="pre">and</span> <span class="pre">the</span> <span class="pre">remark</span> <span class="pre">entries</span> <span class="pre">emitted</span> <span class="pre">together</span></code></p>
<blockquote>
<div><p>This container type expects only a <a class="reference internal" href="#bitstreamremarksmetablock"><span class="std std-ref">META_BLOCK</span></a> containing only:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetacontainerinfo"><span class="std std-ref">RECORD_META_CONTAINER_INFO</span></a></p></li>
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetaremarkversion"><span class="std std-ref">RECORD_META_REMARK_VERSION</span></a></p></li>
<li><p><a class="reference internal" href="#bitstreamremarksrecordmetastrtab"><span class="std std-ref">RECORD_META_STRTAB</span></a></p></li>
</ul>
<p>This container type expects 0 or more <a class="reference internal" href="#bitstreamremarksremarkblock"><span class="std std-ref">REMARK_BLOCK</span></a>.</p>
</div></blockquote>
<p>A complete output of <strong class="program">llvm-bcanalyzer</strong> on the different container types:</p>
<p><code class="docutils literal notranslate"><span class="pre">SeparateRemarksMeta</span></code></p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&lt;BLOCKINFO_BLOCK/&gt;
&lt;Meta BlockID=8 NumWords=13 BlockCodeSize=3&gt;
  &lt;Container info codeid=1 abbrevid=4 op0=5 op1=0/&gt;
  &lt;String table codeid=3 abbrevid=5/&gt; blob data = &#39;pass\\x00key\\x00value\\x00&#39;
  &lt;External File codeid=4 abbrevid=6/&gt; blob data = &#39;/path/to/file/name&#39;
&lt;/Meta&gt;
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">SeparateRemarksFile</span></code></p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&lt;BLOCKINFO_BLOCK/&gt;
&lt;Meta BlockID=8 NumWords=3 BlockCodeSize=3&gt;
  &lt;Container info codeid=1 abbrevid=4 op0=0 op1=1/&gt;
  &lt;Remark version codeid=2 abbrevid=5 op0=0/&gt;
&lt;/Meta&gt;
&lt;Remark BlockID=9 NumWords=8 BlockCodeSize=4&gt;
  &lt;Remark header codeid=5 abbrevid=4 op0=2 op1=0 op2=1 op3=2/&gt;
  &lt;Remark debug location codeid=6 abbrevid=5 op0=3 op1=99 op2=55/&gt;
  &lt;Remark hotness codeid=7 abbrevid=6 op0=999999999/&gt;
  &lt;Argument with debug location codeid=8 abbrevid=7 op0=4 op1=5 op2=6 op3=11 op4=66/&gt;
&lt;/Remark&gt;
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">Standalone</span></code></p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>&lt;BLOCKINFO_BLOCK/&gt;
&lt;Meta BlockID=8 NumWords=15 BlockCodeSize=3&gt;
  &lt;Container info codeid=1 abbrevid=4 op0=5 op1=2/&gt;
  &lt;Remark version codeid=2 abbrevid=5 op0=30/&gt;
  &lt;String table codeid=3 abbrevid=6/&gt; blob data = &#39;pass\\x00remark\\x00function\\x00path\\x00key\\x00value\\x00argpath\\x00&#39;
&lt;/Meta&gt;
&lt;Remark BlockID=9 NumWords=8 BlockCodeSize=4&gt;
  &lt;Remark header codeid=5 abbrevid=4 op0=2 op1=1 op2=0 op3=2/&gt;
  &lt;Remark debug location codeid=6 abbrevid=5 op0=3 op1=99 op2=55/&gt;
  &lt;Remark hotness codeid=7 abbrevid=6 op0=999999999/&gt;
  &lt;Argument with debug location codeid=8 abbrevid=7 op0=4 op1=5 op2=6 op3=11 op4=66/&gt;
&lt;/Remark&gt;
</pre></div>
</div>
</div>
</div>
<div class="section" id="opt-viewer">
<h2><a class="toc-backref" href="#id13">opt-viewer</a><a class="headerlink" href="#opt-viewer" title="Permalink to this headline">¶</a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">opt-viewer</span></code> directory contains a collection of tools that visualize and
summarize serialized remarks.</p>
<p>The tools only support the <code class="docutils literal notranslate"><span class="pre">yaml</span></code> format.</p>
<div class="section" id="opt-viewer-py">
<span id="optviewerpy"></span><h3><a class="toc-backref" href="#id14">opt-viewer.py</a><a class="headerlink" href="#opt-viewer-py" title="Permalink to this headline">¶</a></h3>
<p>Output a HTML page which gives visual feedback on compiler interactions with
your program.</p>
<blockquote>
<div><dl class="field-list simple">
<dt class="field-odd">Examples</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ opt-viewer.py my_yaml_file.opt.yaml
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ opt-viewer.py my_build_dir/
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="opt-stats-py">
<h3><a class="toc-backref" href="#id15">opt-stats.py</a><a class="headerlink" href="#opt-stats-py" title="Permalink to this headline">¶</a></h3>
<p>Output statistics about the optimization remarks in the input set.</p>
<blockquote>
<div><dl class="field-list simple">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ opt-stats.py my_yaml_file.opt.yaml

Total number of remarks           3


Top 10 remarks by pass:
  inline                         33%
  asm-printer                    33%
  prologepilog                   33%

Top 10 remarks:
  asm-printer/InstructionCount   33%
  inline/NoDefinition            33%
  prologepilog/StackSize         33%
</pre></div>
</div>
</div></blockquote>
</div>
<div class="section" id="opt-diff-py">
<h3><a class="toc-backref" href="#id16">opt-diff.py</a><a class="headerlink" href="#opt-diff-py" title="Permalink to this headline">¶</a></h3>
<p>Produce a new YAML file which contains all of the changes in optimizations
between two YAML files.</p>
<p>Typically, this tool should be used to do diffs between:</p>
<ul class="simple">
<li><p>new compiler + fixed source vs old compiler + fixed source</p></li>
<li><p>fixed compiler + new source vs fixed compiler + old source</p></li>
</ul>
<p>This diff file can be displayed using <a class="reference internal" href="#optviewerpy"><span class="std std-ref">opt-viewer.py</span></a>.</p>
<blockquote>
<div><dl class="field-list simple">
<dt class="field-odd">Example</dt>
<dd class="field-odd"><p></p></dd>
</dl>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ opt-diff.py my_opt_yaml1.opt.yaml my_opt_yaml2.opt.yaml -o my_opt_diff.opt.yaml
$ opt-viewer.py my_opt_diff.opt.yaml
</pre></div>
</div>
</div></blockquote>
</div>
</div>
<div class="section" id="emitting-remark-diagnostics-in-the-object-file">
<span id="remarkssection"></span><h2><a class="toc-backref" href="#id17">Emitting remark diagnostics in the object file</a><a class="headerlink" href="#emitting-remark-diagnostics-in-the-object-file" title="Permalink to this headline">¶</a></h2>
<p>A section containing metadata on remark diagnostics will be emitted for the
following formats:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">yaml-strtab</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">bitstream</span></code></p></li>
</ul>
<p>This can be overridden by using the flag <code class="docutils literal notranslate"><span class="pre">-remarks-section=&lt;bool&gt;</span></code>.</p>
<p>The section is named:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">__LLVM,__remarks</span></code> (MachO)</p></li>
</ul>
</div>
<div class="section" id="c-api">
<h2><a class="toc-backref" href="#id18">C API</a><a class="headerlink" href="#c-api" title="Permalink to this headline">¶</a></h2>
<p>LLVM provides a library that can be used to parse remarks through a shared
library named <code class="docutils literal notranslate"><span class="pre">libRemarks</span></code>.</p>
<p>The typical usage through the C API is like the following:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">LLVMRemarkParserRef</span> <span class="n">Parser</span> <span class="o">=</span> <span class="n">LLVMRemarkParserCreateYAML</span><span class="p">(</span><span class="n">Buf</span><span class="p">,</span> <span class="n">Size</span><span class="p">);</span>
<span class="n">LLVMRemarkEntryRef</span> <span class="n">Remark</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span>
<span class="k">while</span> <span class="p">((</span><span class="n">Remark</span> <span class="o">=</span> <span class="n">LLVMRemarkParserGetNext</span><span class="p">(</span><span class="n">Parser</span><span class="p">)))</span> <span class="p">{</span>
   <span class="c1">// use Remark</span>
   <span class="n">LLVMRemarkEntryDispose</span><span class="p">(</span><span class="n">Remark</span><span class="p">);</span> <span class="c1">// Release memory.</span>
<span class="p">}</span>
<span class="kt">bool</span> <span class="n">HasError</span> <span class="o">=</span> <span class="n">LLVMRemarkParserHasError</span><span class="p">(</span><span class="n">Parser</span><span class="p">);</span>
<span class="n">LLVMRemarkParserDispose</span><span class="p">(</span><span class="n">Parser</span><span class="p">);</span>
</pre></div>
</div>
</div>
<div class="section" id="remark-streamers">
<h2><a class="toc-backref" href="#id19">Remark streamers</a><a class="headerlink" href="#remark-streamers" title="Permalink to this headline">¶</a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">RemarkStreamer</span></code> interface is used to unify the serialization
capabilities of remarks across all the components that can generate remarks.</p>
<p>All remark serialization should go through the main remark streamer, the
<code class="docutils literal notranslate"><span class="pre">llvm::remarks::RemarkStreamer</span></code> set up in the <code class="docutils literal notranslate"><span class="pre">LLVMContext</span></code>. The interface
takes remark objects converted to <code class="docutils literal notranslate"><span class="pre">llvm::remarks::Remark</span></code>, and takes care of
serializing it to the requested format, using the requested type of metadata,
etc.</p>
<p>Typically, a specialized remark streamer will hold a reference to the one set
up in the <code class="docutils literal notranslate"><span class="pre">LLVMContext</span></code>, and will operate on its own type of diagnostics.</p>
<p>For example, LLVM IR passes will emit <code class="docutils literal notranslate"><span class="pre">llvm::DiagnosticInfoOptimization*</span></code>
that get converted to <code class="docutils literal notranslate"><span class="pre">llvm::remarks::Remark</span></code> objects.  Then, clang could set
up its own specialized remark streamer that takes <code class="docutils literal notranslate"><span class="pre">clang::Diagnostic</span></code>
objects. This can allow various components of the frontend to emit remarks
using the same techniques as the LLVM remarks.</p>
<p>This gives us the following advantages:</p>
<ul class="simple">
<li><p>Composition: during the compilation pipeline, multiple components can set up
their specialized remark streamers that all emit remarks through the same
main streamer.</p></li>
<li><p>Re-using the remark infrastructure in <code class="docutils literal notranslate"><span class="pre">lib/Remarks</span></code>.</p></li>
<li><p>Using the same file and format for the remark emitters created throughout the
compilation.</p></li>
</ul>
<p>at the cost of an extra layer of abstraction.</p>
</div>
</div>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="SourceLevelDebugging.html" title="Source Level Debugging with LLVM"
             >next</a> |</li>
        <li class="right" >
          <a href="ReportingGuide.html" title="Reporting Guide"
             >previous</a> |</li>
  <li><a href="https://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="index.html">Documentation</a>&raquo;</li>

          <li class="nav-item nav-item-1"><a href="UserGuides.html" >User Guides</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">Remarks</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2021, LLVM Project.
      Last updated on 2021-09-18.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.5.4.
    </div>
  </body>
</html>