Charles Saternos via llvm-dev
2017-Jul-10 15:55 UTC
[llvm-dev] [ThinLTO] Making ThinLTO functions not fail hasExactDefinition (specifically preventing it from being derefined)
Hey all, I'm working on adding interprocedural FunctionAttrs optimization ( http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionAttrs.cpp) to ThinLTO so it does something similar to what LTO is doing ( https://bugs.llvm.org/show_bug.cgi?id=33648). I've hit a problem with how the FunctionAttrs optimization expects linkage types. In ThinLTO since the linkage type is set to External or AvailableExternally it is unable to apply any of the functionattr optimizations that LTO can (since LTO is able to convert everything to Internal). This is a problem because every functionattr optimization expects an exact definition by calling hasExactDefinition (http://llvm-cs.pcc.me.uk/ include/llvm/IR/GlobalValue.h#387) which doesn't want a derefined function (mayBeDerefined http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#119). According to the current definition, an AvailableExternally function could be derefined so hasExactDefinition fails. Does anyone have any ideas on how to make a function with External/AvailableExternally linkage type have an exact definition? Thanks, Charles -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170710/b3c35754/attachment.html>
Davide Italiano via llvm-dev
2017-Jul-11 19:27 UTC
[llvm-dev] [ThinLTO] Making ThinLTO functions not fail hasExactDefinition (specifically preventing it from being derefined)
On Mon, Jul 10, 2017 at 8:55 AM, Charles Saternos via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hey all, > > I'm working on adding interprocedural FunctionAttrs optimization > (http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionAttrs.cpp) to ThinLTO > so it does something similar to what LTO is doing > (https://bugs.llvm.org/show_bug.cgi?id=33648). I've hit a problem with how > the FunctionAttrs optimization expects linkage types. > > In ThinLTO since the linkage type is set to External or AvailableExternally > it is unable to apply any of the functionattr optimizations that LTO can > (since LTO is able to convert everything to Internal). This is a problem > because every functionattr optimization expects an exact definition by > calling hasExactDefinition > (http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#387) which doesn't > want a derefined function (mayBeDerefined > http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#119). According to > the current definition, an AvailableExternally function could be derefined > so hasExactDefinition fails. > > Does anyone have any ideas on how to make a function with > External/AvailableExternally linkage type have an exact definition? >+ Sanjoy, who did all the derefinement work originally. -- Davide
Sanjoy Das via llvm-dev
2017-Jul-11 21:54 UTC
[llvm-dev] [ThinLTO] Making ThinLTO functions not fail hasExactDefinition (specifically preventing it from being derefined)
Hi Charles, On Tue, Jul 11, 2017 at 12:27 PM, Davide Italiano <davide at freebsd.org> wrote:>> I'm working on adding interprocedural FunctionAttrs optimization >> (http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionAttrs.cpp) to ThinLTO >> so it does something similar to what LTO is doing >> (https://bugs.llvm.org/show_bug.cgi?id=33648). I've hit a problem with how >> the FunctionAttrs optimization expects linkage types. >> >> In ThinLTO since the linkage type is set to External or AvailableExternallyFunctionAttrs should still kick in for external linkage, can you post an IR sample of where that's not happening (since that's a bug IIUC)? As far as available_externally is concerned, preventing FunctionAttrs on them is by design and I'm not sure if there is anything in ThinLTO to fix that (assuming that the functions are, in fact, available_externally). There is some background information on this issue at https://www.playingwithpointers.com/ipo-and-derefinement.html -- Sanjoy>> it is unable to apply any of the functionattr optimizations that LTO can >> (since LTO is able to convert everything to Internal). This is a problem >> because every functionattr optimization expects an exact definition by >> calling hasExactDefinition >> (http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#387) which doesn't >> want a derefined function (mayBeDerefined >> http://llvm-cs.pcc.me.uk/include/llvm/IR/GlobalValue.h#119). According to >> the current definition, an AvailableExternally function could be derefined >> so hasExactDefinition fails. >> >> Does anyone have any ideas on how to make a function with >> External/AvailableExternally linkage type have an exact definition? >> > > + Sanjoy, who did all the derefinement work originally. > > -- > Davide