<div dir="ltr"><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="color:black;font-family:Arial,sans-serif;font-size:11pt">Hello all,</span><br></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"><br></span></p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black">During the compilation
process, LLVM automatically derives various attributes about functions and
values (for example that a pointer is nonnull, a function is constant, etc)
that are used within a translation unit.</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black">I propose adding a pass
to LLVM that allows front-ends to output derived attributes. Such a pass would
be useful both for developers and end users to debug programs, either learning
that an expected attribute was learned, or an unexpected attribute was learned
(for example a pointer never being written to).</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black">Evidently the following
might not be the final interface, but one could imagine something like the
following:</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black">$ ./clang foobar.c -g
-Rannotations -O3</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black"> foobar.c:2:1: remark: derived following
attributes for function f: fn_attr("norecurse")
fn_attr("nounwind") fn_attr("readonly") arg_attr(0,
"nocapture") arg_attr(0, "readonly") [-Rannotations]</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black"> double f(double* a) {</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black">foobar.c:</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black">double f(double* a) {</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black"> return a[0];</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Consolas;color:black">}</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black">A work in progress patch
implementing such an optimization remark is available here: <a href="https://reviews.llvm.org/D65169" style="color:rgb(5,99,193)">https://reviews.llvm.org/D65169</a></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black"> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black">Cheers,</span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:12pt;font-family:Calibri,sans-serif"><span style="font-size:11pt;font-family:Arial,sans-serif;color:black">Billy Moses</span></p></div>