Chris, is this how the tbaa for vtable loads/stores should look like? <div><br></div><div>Metadata: </div><div><div>!0 = metadata !{metadata !"vtable pointer", metadata !1}</div><div>!1 = metadata !{metadata !"omnipotent char", metadata !2}</div>
<div>!2 = metadata !{metadata !"Simple C/C++ TBAA", null}</div><div>...</div></div><div><br></div><div>Load: </div><div><div>  %0 = bitcast %struct.A* %a to void (%struct.A*)***</div><div>  %vtable = load void (%struct.A*)*** %0, align 8, !tbaa !0</div>
</div><div><br></div><div>Store: </div><div>  %0 = getelementptr inbounds %struct.B* %this, i64 0, i32 0, i32 0</div><div>  store i32 (...)** bitcast (i8** getelementptr inbounds ([5 x i8*]* @_ZTV1B, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, align 8, !tbaa !0</div>
<div><br></div><div>--kcc </div><div><br></div><div><br></div><div><br></div><div><br><br><div class="gmail_quote">On Wed, Mar 21, 2012 at 12:57 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div class="im"><br><div><div>On Mar 21, 2012, at 11:53 AM, Kostya Serebryany wrote:</div>
<br><blockquote type="cite"><span style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div>> The gcc Ada front-end does this too, in quite a range of situations.  For<br>> example multiple threads racily initialize a pointer variable, but they all<br>> initialize to the same value.  The various valgrind based race detection<br>
> tools all complain about this, which makes them much less useful than they<br>> might be for Ada.<br><br></div>FWIW, after thinking about this for awhile, I realize that we already have the tools to handle this: TBAA.<br>
<br>It would be general goodness for clang to emit VTable loads and stores in their with their own TBAA type class (one that does not even alias "char*").</blockquote><div><br></div><div>Indeed, sounds very nice.</div>
<div>I'll try to make a patch that adds TBAA metadata to VTable loads (unless someone else knows how to do it off the top of his head). </div></span><br></blockquote></div><br></div><div>Sounds great, thanks Kostya,</div>
<div><br></div><div>-Chris</div></div></blockquote></div><br></div>