<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_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/<wbr>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"><br></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><br></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/<wbr>pipermail/cfe-dev/2015-July/<wbr>044227.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-<wbr>11/#talk6</a></span></p><br><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><br><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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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><br><br><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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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><br><br><br><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><br><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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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"><br class="m_3685817574736257236gmail-kix-line-break"></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><br><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><br><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><br><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><br><br><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><br><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"><br></span></div></span></div>
</blockquote></div><br></div>