<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<blockquote type="cite"
cite="mid:mailman.12136.1595898758.1392.llvm-dev@lists.llvm.org">
<blockquote type="cite" style="color: #000000;">
<pre class="moz-quote-pre" wrap="">On Jul 27, 2020, at 10:11 AM, David Greene via llvm-dev <a class="moz-txt-link-rfc2396E" href="mailto:llvm-dev@lists.llvm.org" moz-do-not-send="true"><llvm-dev@lists.llvm.org></a> wrote:
Son Tuan VU via llvm-dev <a class="moz-txt-link-rfc2396E" href="mailto:llvm-dev@lists.llvm.org" moz-do-not-send="true"><llvm-dev@lists.llvm.org></a> writes:
</pre>
<blockquote type="cite" style="color: #000000;">
<pre class="moz-quote-pre" wrap="">Currently metadata (other than debug info) can be attached to IR
instructions but disappears during DAG selection.
My question is why we do not keep the metadata during code lowering and
then attach to MachineInstr, just as for IR instructions? Is there any
technical challenge, or is it only because nobody wants to do so?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">I have wanted codegen metadata for a very long time so I'm interested to
hear the history behind this choice, and more importantly, whether
adding such capability would be generally acceptable to the community.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">The first questions need to be “what does it mean?”, “how does it work?”, and “what is it useful for?”. It is hard to evaluate a proposal without that.</pre>
</blockquote>
<p><tt>Hi everyone,</tt></p>
<p><tt>I'm trying to answer to each of these questions; it is likely
the answers won't be<br>
exhaustive, but I hope they will serve as a starting point for
an interesting<br>
proposal (from my point of view and the one of </tt><tt>Son
Tuan VU and </tt><tt>David Greene):</tt></p>
<p><tt>- "What does it mean?": it means to preserve specific
information, represented as<br>
metadata assigned to instructions, from the IR level, down to
the codegen phases.</tt></p>
<p><tt>- "How does it work?": metadata should be preserved during
the several<br>
back-end transformations; for instance, during the lowering
phase, DAGCombine<br>
performs several optimization to the IR, potentially
combining several<br>
instructions. The new instruction should, then, assigned with
metadata obtained<br>
as a proper combination of the original ones (e.g., a union
of metadata<br>
information).</tt></p>
<p><tt> It might be possible to have a dedicated data-structure
for such metadata info,<br>
and an instance of such structure assigned to each
instruction.<br>
</tt></p>
<p><tt>- "What is it useful for?": I think it is quite
context-specific; but,<br>
in general, it is useful when some "higher-level"<br>
information (e.g., that can</tt><tt> be discovered only before
the back-end<br>
stage of the compiler) are required in the back-end to perform
"semantic"-related<br>
optimizations.<br>
<br>
</tt></p>
<p><tt>To give an (quite generic) example where such codegen
metadata may be useful: in the field<br>
of "secure compilation", preservation of security properties
during the compilation<br>
phases is essential; such properties are specified in the
high-level specifications of<br>
the program, and may be expressed with IR metadata. The
possibility to keep such IR<br>
metadata in the codegen phases may allow preservation of
properties that may be invalidated<br>
by codegen phases.</tt></p>
<p><tt><br>
</tt></p>
<p><tt>Cheers,<br>
-- Lorenzo<br>
</tt></p>
<blockquote type="cite"
cite="mid:mailman.12136.1595898758.1392.llvm-dev@lists.llvm.org">
<pre class="moz-quote-pre" wrap="">Metadata isn’t free - it must be maintained or invalidated for it to be useful. The details on that dramatically shape whether it can be used for any given purpose.
-Chris</pre>
</blockquote>
</body>
</html>