<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Dec 19, 2014 at 2:39 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">Are we sure we want to go this way? MachO can't even represent generalized comdats. If we want to fix the conflation of weak linkage and implicit single-member comdat groups, it might be nice to have a lighter weight more memory efficient way of representing this.<div><br></div><div>Right now every C++ inline function gets linkonce_odr, a linkage enum packed into a bitfield to say that it needs a comdat. With this change, we will copy the long C++ mangled name into a separate symbol table for not much gain.</div><div><br></div><div>Maybe we should turn linkage into a flags enum? Something like ODR, Discardable, Weak, ImplicitComdat.</div></div></blockquote><div><br></div><div>Crazy idea: let's make Comdat a value type which wraps either a GlobalValue (basic single symbol selectany case) or a ComdatGroup (advanced, funky selection or multi-symbol case). Then GlobalValue::getComdat() can check a few bits and return a little single-pointer wrapper depending on what kind of thing it is, and IR passes can treat it uniformly.</div><div><br></div><div>The IR for the simple inline function case would be something like:</div><div><div>define void @f() comdat { ; no $f sigil</div><div>  ret void</div><div>}</div></div><div><br></div><div>I'm not sure how we would write the global variable case. Today we write:</div><div><div>$v = comdat any</div></div><div><div>@v = global i32 0, comdat $v</div></div><div><br></div><div>I don't think we can write this due to ambiguity:</div><div>@v = global i32 0, comdat<br></div><div>$v = ...</div><div><br></div><div>Maybe we could pretend it's linkage and write this?</div><div><div>@v = comdat global i32 0</div></div><div><br></div><div>Maybe functions should look like this?</div><div><div>define comdat void @f() { ret void }</div></div></div></div></div>