[cfe-dev] [LLVMdev] [Inliner] passing inline hint to optimizer if it appears explicitly on declaration

Sean Silva chisophugis at gmail.com
Wed Mar 25 17:45:17 PDT 2015


This question is probably more fit for cfe-dev (CC'd). I'd guess that it
has to do with which declaration we look at when determining the function
attributes.

On Wed, Mar 25, 2015 at 5:32 PM, Balaram Makam <bmakam at codeaurora.org>
wrote:

> ping
>
>
>
> *From:* Balaram Makam [mailto:bmakam at codeaurora.org]
> *Sent:* Wednesday, March 25, 2015 4:43 PM
> *To:* 'llvmdev at cs.uiuc.edu'
> *Subject:* [Inliner] passing inline hint to optimizer if it appears
> explicitly on declaration
>
>
>
> All,
>
>
>
> I explicitly pass inline hint to the function declaration of
> foo<int>::add() as in the following example:
>
>
>
> #cat example.cpp
>
> template <class T> class foo {
>
>   public:
>
>     T* tp;
>
>     int elem;
>
>     int maxelem;
>
>     T* add();
>
> };
>
>
>
> template <class T> inline T* foo <T>::add()
>
> {
>
>   if (elem!=maxelem)
>
>     elem++;
>
>   return tp+elem-1;
>
> }
>
>
>
> typedef foo <int> intboundart;
>
>
>
> class bar
>
> {
>
>   void addtobound(intboundart& boundarp);
>
> };
>
>
>
> void bar::addtobound(intboundart& barp)
>
> {
>
>   barp.add();
>
> }
>
>
>
> Yet the IR passed into optimizer doesn’t contain inlinehint attribute:
>
> #clang -cc1 -emit-llvm –o - example.cpp
>
>
>
> <snip>
>
> ; Function Attrs: nounwind
>
> define linkonce_odr i32* @_ZN3fooIiE3addEv(%class.foo* %this) #0 comdat
> align 2 {
>
> <snip>
>
>
>
> Clang will pass inline hint to optimizer only if I declare explicitly in
> the class like this:
>
>
>
> template <class T> class foo {
>
>   public:
>
>     T* tp;
>
>     int elem;
>
>     int maxelem;
>
>     inline T* add();
>
> };
>
>
>
> Isn’t this a clang bug? Any pointers on how to fix this?
>
>
>
> Thanks,
>
> Balaram
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150325/65959e58/attachment.html>


More information about the cfe-dev mailing list