<div dir="ltr"><div><span style="font-size:12.8px">Hey Mehdi,</span></div><span style="font-size:12.8px"><div><span style="font-size:12.8px"><br></span></div>> I think ThinLTO can fix most of it. My idea was to propagate function attribute even for simple function declarations!</span><br><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Alright - I'll look into this approach - seems like the way too go.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks,</span></div><div><span style="font-size:12.8px">Charles</span></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 12, 2017 at 12:51 PM, Mehdi AMINI via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">2017-07-11 14:54 GMT-07:00 Sanjoy Das via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Charles,<br>
<span><br>
On Tue, Jul 11, 2017 at 12:27 PM, Davide Italiano <<a href="mailto:davide@freebsd.org" target="_blank">davide@freebsd.org</a>> wrote:<br>
>> I'm working on adding interprocedural FunctionAttrs optimization<br>
>> (<a href="http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionAttrs.cpp" rel="noreferrer" target="_blank">http://llvm-cs.pcc.me.uk/lib/<wbr>Transforms/IPO/FunctionAttrs.c<wbr>pp</a>) to ThinLTO<br>
>> so it does something similar to what LTO is doing<br>
>> (<a href="https://bugs.llvm.org/show_bug.cgi?id=33648" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bu<wbr>g.cgi?id=33648</a>). I've hit a problem with how<br>
>> the FunctionAttrs optimization expects linkage types.<br>
>><br>
>> In ThinLTO since the linkage type is set to External or AvailableExternally<br>
<br>
</span>FunctionAttrs should still kick in for external linkage, can you post<br>
an IR sample of where that's not happening (since that's a bug IIUC)?<br>
<br>
As far as available_externally is concerned, preventing FunctionAttrs<br>
on them is by design and I'm not sure if there is anything in ThinLTO<br>
to fix that (assuming that the functions are, in fact,<br>
available_externally).<br></blockquote><div><br></div></span><div>I think ThinLTO can fix most of it. My idea was to propagate function attribute even for simple function declarations!</div><div><br></div><div>The reason I believe LTO can circumvent the "derefinement" issue is because the attributes computed after optimization during the compile phase are propagated only after the linker decided which "version" of an ODR function we will pick in the final binary. </div><div><br></div><div>I believe this is valid, as long as later optimizations in the ThinLTO backend can't "undo" an attribute (or can't change the attribute list to be less restrictive). For example if a function is `read_none` after the compile phase. During the ThinLTO thin-link we can propagate this attribute to every uses (after deciding that this is the copy we want to keep for this function). However if a later optimization invalidate the read_none attributes, it's over. I doubt this can happen though (as in general it would invalidate previous optimizations).</div><div><br></div><div>-- </div><div>Mehdi</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
There is some background information on this issue at<br>
<a href="https://www.playingwithpointers.com/ipo-and-derefinement.html" rel="noreferrer" target="_blank">https://www.playingwithpointer<wbr>s.com/ipo-and-derefinement.<wbr>html</a><br>
<br>
-- Sanjoy<br>
</span><div class="m_8706402121855080801HOEnZb"><div class="m_8706402121855080801h5"><span class=""><br>
<br>
>> it is unable to apply any of the functionattr optimizations that LTO can<br>
>> (since LTO is able to convert everything to Internal). This is a problem<br>
>> because every functionattr optimization expects an exact definition by<br>
>> calling hasExactDefinition<br>
>> (<a href="http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#387" rel="noreferrer" target="_blank">http://llvm-cs.pcc.me.uk/incl<wbr>ude/llvm/IR/GlobalValue.h#387</a>) which doesn't<br>
>> want a derefined function (mayBeDerefined<br>
>> <a href="http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#119" rel="noreferrer" target="_blank">http://llvm-cs.pcc.me.uk/inclu<wbr>de/llvm/IR/GlobalValue.h#119</a>). According to<br>
>> the current definition, an AvailableExternally function could be derefined<br>
>> so hasExactDefinition fails.<br>
>><br>
>> Does anyone have any ideas on how to make a function with<br>
>> External/AvailableExternally linkage type have an exact definition?<br>
>><br>
><br>
> + Sanjoy, who did all the derefinement work originally.<br>
><br>
> --<br>
> Davide<br></span>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>