<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 4, 2017 at 8:22 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On 2017-Feb-03, at 18:03, Duncan P. N. Exon Smith via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
>><br>
>> On 2017-Feb-03, at 17:49, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>> wrote:<br>
>><br>
>>><br>
>>> On 2017-Feb-03, at 17:34, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>> wrote:<br>
>>><br>
>>><br>
>>>> On 2017-Feb-03, at 15:55, Peter Collingbourne <<a href="mailto:peter@pcc.me.uk" target="_blank">peter@pcc.me.uk</a>> wrote:<br>
>>>><br>
>>>> On Fri, Feb 3, 2017 at 3:34 PM, Duncan P. N. Exon Smith <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>> wrote:<br>
>>>> I spent some more time on this and I understand the failure.<br>
>>>><br>
>>>> I'm really uncomfortable with the fix, though.  It seems partial -- it fixes the particular crash you found, but couldn't this happen with other fields in DISubprogram?<br>
<br>
</span>I spent a few hours looking more carefully at the testcase and digging into how it happens.  I'm feeling better about your fix as a short-term solution.  While it's papering over a more general problem, I'm convinced it's safer than the current state.  If you add a comment explaining why you need to compare TemplateParams -- to avoid incorrect collisions in mapMetadata when RF_MoveDistinctMDs and a ODR-DISubprogram ("m_fn2" in your testcase) has a non-ODR template parameter (i.e., a DICompositeType that does not have an identifier; "D" in your testcase) -- the code change LGTM (comments on the testcase below).<br>
<br>
It might be nice to add a FIXME to decouple the uniquing logic from the ODR logic.  I thought for a long while about how to clean this up and I didn't find a clear path.  Ideally, we'd have something similar to DICompositeType::buildODRType for DISubprogram and DIDerivedType, and put the logic in LLParser and MetadataLoader.  However: while we can count on the identifier field of DICompositeType being loaded early because it's an MDString, the same is *not* true of the inputs to DISubprogram and DIDerivedType; building them lazily would be difficult.  I also considered adding custom logic to MDNodeMapper (in mapMetadata) that recognizes the pattern, and fixes the operands.  This might better.<br>
<br>
<br>
I think the testcase can be reduced.  This seems sufficient:<br>
--<br>
  void sink(void *);<br>
<br>
  class A {<br>
  public:<br>
    template <typename> void m_fn2() { static int a; }<br>
    virtual void m_fn1();<br>
  };<br>
<br>
  void foo() {<br>
    class B : public A {<br>
    public:<br>
      B() { m_fn2<B>(); }<br>
    };<br>
    sink(new B);<br>
  }<br>
--<br>
<br>
Adrian, does the testcase look good to you?  (Besides minimizing it, I don't have other comments.)<br></blockquote><div><br></div><div>Thanks, I've uploaded a new version of the patch with the reduced test case and a FIXME.</div><div><br></div><div>Peter</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="m_-515274880789662411im m_-515274880789662411HOEnZb"><br>
>>>> Maybe -- I guess that's what I was alluding to in my commit message. Do you think anything could break if I just remove the MDNodeSubsetEqualImpl specialization of DISubprogram?<br>
>>><br>
>>> Yes.  I suspect we'll get a big regression (compile-time? memory?) in -flto=full, and possible a regression in -flto=thin (which is what I was targeting at the time).  IIRC, the point of this was to (a) reduce number of nodes and (b) cut down on ValueMapper traffic (ironically, the same thing that it breaks).<br>
>><br>
>> (It's possible that this didn't affect -flto=full much, and the more recent changes to -flto=thin make this optimization unnecessary.)<br>
><br>
> It looks like there's also a DWARF correctness issue if you back this out (although I have not confirmed).  r203982 added test/Linker/type-unique-odr-a.<wbr>ll (which r266548 augments).  I think r266548 was necessary to prevent regressing that testcase when I took away the string-based pointers.<br>
><br>
>>> Of course, correctness should trump performance, but I'm pretty concerned about turning it off blind.  I'm also still looking for other options...<br>
>>><br>
>>>> Also, where does the ValueMapper run in this opt invocation?  Is that what -run-twice does?<br>
>>>><br>
>>>> Yes, -run-twice causes us to clone the module, which uses ValueMapper. See <a href="http://llvm-cs.pcc.me.uk/tools/opt/opt.cpp#719" rel="noreferrer" target="_blank">http://llvm-cs.pcc.me.uk/tools<wbr>/opt/opt.cpp#719</a><br>
>>><br>
>>> Got it.<br>
>>><br>
>>>> Thanks,<br>
>>>> --<br>
>>>> --<br>
>>>> Peter<br>
><br>
</span><div class="m_-515274880789662411HOEnZb"><div class="m_-515274880789662411h5">> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_-515274880789662411gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div></div>