<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-01-26 0:03 GMT+01:00 Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Hi Piotr,</p>
<p>I think makes sense. Modulo bitcasts, the invariant is identified
by a particular pointer SSA value. Given that you can't sensibly
have two nonequivalent invariants associated with the same pointer
SSA value simultaneously, there's no need to also identify the
invariant with a metadata string as well. When we need a new
"identifier" for the pointed-to value, we get one using
invariant.group.barrier.</p>
<p> -Hal</p></div></blockquote><div>What is your opinion about changing invariant.group to just invariant?</div><div><br></div><div>Piotr</div><div> </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><div><div class="h5">
<div class="m_-3771872383292418585moz-cite-prefix">On 01/24/2017 01:39 PM, Piotr Padlewski
via llvm-dev wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Hi,
<div>I would really like to hear some feedback about this.</div>
<div><br>
</div>
<div>Piotr</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">2017-01-20 17:07 GMT+01:00 Piotr
Padlewski <span dir="ltr"><<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><span id="m_-3771872383292418585m_3685817574736257236gmail-docs-internal-guid-f4b3e122-bc9b-30cb-5204-c95e1095750e">
<p dir="ltr" style="text-align:left;line-height:1.38;margin-top:0pt;margin-bottom:3pt"><span style="background-color:transparent;color:rgb(0,0,0);font-family:arial;font-size:14.6667px;white-space:pre-wrap">Hi all,</span></p>
<p dir="ltr" style="text-align:left;line-height:1.38;margin-top:0pt;margin-bottom:3pt"><span style="background-color:transparent;color:rgb(0,0,0);font-family:arial;font-size:14.6667px;white-space:pre-wrap">I would like to propose a new way clang would decorate vtable loads in order to handle devirtualization better.</span></p>
<p dir="ltr" style="text-align:left;line-height:1.38;margin-top:0pt;margin-bottom:3pt"><span style="background-color:transparent;color:rgb(0,0,0);font-family:arial;font-size:14.6667px;white-space:pre-wrap">I've added <b>llvm-dev</b> also, because this can start a discussion about changing invariant.group to just invariant. </span></p>
<p dir="ltr" style="text-align:left;line-height:1.38;margin-top:0pt;margin-bottom:3pt"><span style="background-color:transparent;color:rgb(0,0,0);font-family:arial;font-size:14.6667px;white-space:pre-wrap">PDF version of this RFC can be found here:</span></p>
<p dir="ltr" style="text-align:left;line-height:1.38;margin-top:0pt;margin-bottom:3pt"><a href="https://drive.google.com/file/d/0B72TmzNsY6Z8ZmpOUnB5dDZfSFU/view?usp=sharing" style="font-size:14.6667px;white-space:pre-wrap;font-family:arial;background-color:transparent" target="_blank">https://drive.google.com/file/<wbr>d/0B72TmzNsY6Z8ZmpOUnB5dDZfSFU<wbr>/view?usp=sharing</a></p><h2 style="line-height:1.38;margin-top:18pt;margin-bottom:6pt"><p style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;color:rgb(0,0,0);font-family:arial;font-size:21.3333px;font-weight:400;white-space:pre-wrap">
</span></p><p style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="background-color:transparent;color:rgb(0,0,0);font-family:arial;font-size:21.3333px;font-weight:400;white-space:pre-wrap">Background:</span>
</p></h2><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Initial old design:</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><a href="http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html" style="text-decoration:none" target="_blank"><span style="font-size:14.6667px;font-family:arial;background-color:transparent;text-decoration:underline;vertical-align:baseline;white-space:pre-wrap">http://lists.llvm.org/pipermai<wbr>l/cfe-dev/2015-July/044227.<wbr>html</span></a></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">My talk from LLVM Dev Meeting</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"><a href="http://llvm.org/devmtg/2016-11/#talk6" target="_blank">http://llvm.org/devmtg/2016-11<wbr>/#talk6</a></span></p>
<h2 dir="ltr" style="line-height:1.38;margin-top:18pt;margin-bottom:6pt"><span style="font-size:21.3333px;font-family:arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;vertical-align:baseline;white-space:pre-wrap">The problem</span></h2><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Clang with </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">-fstrict-vtable-pointers </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">decorates vtable loads with metadata corresponding to mangled pointer type name like:</span></p>
<p dir="ltr" style="line-height:1.32955;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,102,187);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">g</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">(A& a){</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> a.foo();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">}</span></p>
<p dir="ltr" style="line-height:1.32955;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">define </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(255,0,0);background-color:rgb(255,170,170);vertical-align:baseline;white-space:pre-wrap">@</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">_Z1gR1A(%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A* dereferenceable(</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">8</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">) %a) local_unnamed_addr </span><span style="font-size:14.6667px;font-family:arial;color:rgb(255,0,0);background-color:rgb(255,170,170);vertical-align:baseline;white-space:pre-wrap">#</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">0</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> {</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(153,119,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">entry:</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> %</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">0</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> = bitcast %</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A* %a to </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> (%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A*)***</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> %vtable = load </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> (%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A*)**, </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> (%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A*)*** %</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">0</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">, !invariant.group !</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">7</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> %</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">1</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> = load </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> (%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A*)*, </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> (%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A*)** %vtable</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> tail call </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> %</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">1</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">(%</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">.A* nonnull %a)</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> ret </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">}</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">!</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,221);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">7</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> = !{!</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:rgb(255,240,240);vertical-align:baseline;white-space:pre-wrap">"_ZTS1A"</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">}</span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">This works well if the pointer type doesn’t change, but when it does, devirtualization might not happen like here:</span></p>
<p dir="ltr" style="line-height:1.32955;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> A {</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> A();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">virtual</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,102,187);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">foo</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">};</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">struct</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> B : A{</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> B();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,136,0);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">virtual</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,102,187);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">foo</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">};</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,102,187);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">g</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">(A& a){</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> a.foo();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> a.foo();</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">}</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,102,187);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">clobber</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">(A&);</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,153);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">void</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> </span><span style="font-size:14.6667px;font-family:arial;color:rgb(0,102,187);background-color:transparent;font-weight:700;vertical-align:baseline;white-space:pre-wrap">f</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">() {</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> B b;</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> clobber(b);</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap"> g(b);</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span><span style="font-size:14.6667px;font-family:arial;color:rgb(51,51,51);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">}</span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">The other problem is that when we combine 2 instructions with different invariant.group metadata, then we pick one of them, because for now we can have only single !invariant.group metadata.</span></p>
<h1 dir="ltr" style="line-height:1.38;margin-top:20pt;margin-bottom:6pt"><span style="font-size:26.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;font-weight:400;vertical-align:baseline;white-space:pre-wrap">The solution</span></h1><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">I had some initial ideas how it can be solved, like </span></p><ol style="margin-top:0pt;margin-bottom:0pt"><li dir="ltr" style="list-style-type:lower-alpha;font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">introducing multi invariant groups</span></p></li><li dir="ltr" style="list-style-type:lower-alpha;font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">having sub invariant groups - like inheritance, so we could figure out that one group is subgroup of another</span></p></li><li dir="ltr" style="list-style-type:lower-alpha;font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;background-color:transparent;vertical-align:baseline;white-space:pre-wrap">decorating all loads with base pointer MD (doesn’t work with multiple inheritance)</span></p></li></ol>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">I consulted my ideas with Krzysztof Pszeniczny, and he proposed something much simpler: we can decorate every invariant.group md with empty metadata.</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">This should work because the lifetime of the object is strictly defined by invariant.group.barrier.</span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">If this holds, we can start discussion about if it makes sense to keep invariant groups, and instead have just “invariant”, that would be equivalent to having invariant.group with the same metadata.</span></p>
<p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">Do you have some thoughts about this approach? I don’t have a mathematical proof, but I am confident that it should be valid.</span></p><div><span style="font-size:14.6667px;font-family:arial;color:rgb(0,0,0);background-color:transparent;vertical-align:baseline;white-space:pre-wrap">
</span></div></span></div>
</blockquote></div>
</div>
<fieldset class="m_-3771872383292418585mimeAttachmentHeader"></fieldset>
</div></div><pre>______________________________<wbr>_________________
LLVM Developers mailing list
<a class="m_-3771872383292418585moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a class="m_-3771872383292418585moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><span class="HOEnZb"><font color="#888888">
</font></span></pre><span class="HOEnZb"><font color="#888888">
</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<pre class="m_-3771872383292418585moz-signature" cols="72">--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre></font></span></div></blockquote></div><br></div></div>