<div dir="ltr">Ah, thanks - not sure why I didn't spot that when I was looking earlier.<br><br>Yeah, you'd have to go back and check the original review threads/discussions when the anchors went in I suppose.<br><br>I doubt the performance matters terribly either way myself, was just a bit easier to commit these as explicit anchors so it was clear they made no change to performance, optimizability, etc.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 30, 2018 at 12:57 PM Fāng-ruì Sòng <<a href="mailto:maskray@google.com">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> Oh, looks like the key function/weak vtable issue was removed from the style guide at some point - maybe we can/should just rip out all the explicit anchors, then?<br>
<br>
Is it still there at<br>
<a href="https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers" rel="noreferrer" target="_blank">https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers</a>.<br>
There is no wording about prefererence of dtor or an explicit<br>
'anchor()'. For MemoryBuffer, the out-of-line dtors is already there<br>
`virtual ~MemoryBuffer();` and removing the unnecessary `anchor()`<br>
might be fine?<br>
On Mon, Jul 30, 2018 at 12:48 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
> What's the advantage of moving the dtor to be out of line and act as a key function? I Think when I originally added a bunch of these Chris Lattner mentioned a slight preference towards an explicit anchor rather than placing the dtor out of line (if it wasn't already) - since the latter might inhibit optimizations like inlining of the dtor in some cases (even with a virtual dtor - not all dtor calls might be virtual, and derived dtors need to call the base dtor, etc).<br>
><br>
> Oh, looks like the key function/weak vtable issue was removed from the style guide at some point - maybe we can/should just rip out all the explicit anchors, then?<br>
><br>
> On Fri, Jul 27, 2018 at 4:12 PM Fangrui Song via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> Author: maskray<br>
>> Date: Fri Jul 27 16:12:11 2018<br>
>> New Revision: 338175<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=338175&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=338175&view=rev</a><br>
>> Log:<br>
>> [Support] Remove unnecessary MemoryBuffer::anchor (where the destructor serves as the key function)<br>
>><br>
>> Modified:<br>
>>     llvm/trunk/include/llvm/Support/MemoryBuffer.h<br>
>>     llvm/trunk/include/llvm/Support/SmallVectorMemoryBuffer.h<br>
>>     llvm/trunk/lib/Support/MemoryBuffer.cpp<br>
>><br>
>> Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=338175&r1=338174&r2=338175&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=338175&r1=338174&r2=338175&view=diff</a><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)<br>
>> +++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Fri Jul 27 16:12:11 2018<br>
>> @@ -43,7 +43,6 @@ class MemoryBuffer {<br>
>>    const char *BufferStart; // Start of the buffer.<br>
>>    const char *BufferEnd;   // End of the buffer.<br>
>><br>
>> -<br>
>>  protected:<br>
>>    MemoryBuffer() = default;<br>
>><br>
>> @@ -148,9 +147,6 @@ public:<br>
>>    virtual BufferKind getBufferKind() const = 0;<br>
>><br>
>>    MemoryBufferRef getMemBufferRef() const;<br>
>> -<br>
>> -private:<br>
>> -  virtual void anchor();<br>
>>  };<br>
>><br>
>>  /// This class is an extension of MemoryBuffer, which allows copy-on-write<br>
>><br>
>> Modified: llvm/trunk/include/llvm/Support/SmallVectorMemoryBuffer.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SmallVectorMemoryBuffer.h?rev=338175&r1=338174&r2=338175&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SmallVectorMemoryBuffer.h?rev=338175&r1=338174&r2=338175&view=diff</a><br>
>> ==============================================================================<br>
>> --- llvm/trunk/include/llvm/Support/SmallVectorMemoryBuffer.h (original)<br>
>> +++ llvm/trunk/include/llvm/Support/SmallVectorMemoryBuffer.h Fri Jul 27 16:12:11 2018<br>
>> @@ -49,6 +49,9 @@ public:<br>
>>      init(this->SV.begin(), this->SV.end(), false);<br>
>>    }<br>
>><br>
>> +  // Key function.<br>
>> +  ~SmallVectorMemoryBuffer() override;<br>
>> +<br>
>>    StringRef getBufferIdentifier() const override { return BufferName; }<br>
>><br>
>>    BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; }<br>
>> @@ -56,7 +59,6 @@ public:<br>
>>  private:<br>
>>    SmallVector<char, 0> SV;<br>
>>    std::string BufferName;<br>
>> -  void anchor() override;<br>
>>  };<br>
>><br>
>>  } // namespace llvm<br>
>><br>
>> Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=338175&r1=338174&r2=338175&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=338175&r1=338174&r2=338175&view=diff</a><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)<br>
>> +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Fri Jul 27 16:12:11 2018<br>
>> @@ -533,5 +533,4 @@ MemoryBufferRef MemoryBuffer::getMemBuff<br>
>>    return MemoryBufferRef(Data, Identifier);<br>
>>  }<br>
>><br>
>> -void MemoryBuffer::anchor() {}<br>
>> -void SmallVectorMemoryBuffer::anchor() {}<br>
>> +SmallVectorMemoryBuffer::~SmallVectorMemoryBuffer() {}<br>
>><br>
>><br>
>> _______________________________________________<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/mailman/listinfo/llvm-commits</a><br>
<br>
<br>
<br>
-- <br>
宋方睿<br>
</blockquote></div>