<div dir="ltr">The problem is that the other way around is not true: a function linkonce_odr linkage may be neither inline declared nor have in-class definition.<div><br></div><div>David</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 24, 2015 at 11:53 AM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
<br>
> -----Original Message-----<br>
> From: <a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a>] On<br>
> Behalf Of Easwaran Raman<br>
</span><span class="">> Sent: Wednesday, June 24, 2015 9:54 AM<br>
> To: Xinliang David Li<br>
> Cc: <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>> List<br>
> Subject: Re: [LLVMdev] Inline hint for methods defined in-class<br>
><br>
> Ping.<br>
><br>
> On Wed, Jun 17, 2015 at 4:13 PM, Xinliang David Li <<a href="mailto:davidxl@google.com">davidxl@google.com</a>><br>
> wrote:<br>
> > that looks like a different fix. The case mentioned by Easwaran is<br>
> ><br>
> > class A{<br>
> > int foo () { return 1; }<br>
> > ...<br>
> > };<br>
> ><br>
> > where 'foo' is not explicitly declared with 'inline' keyword.<br>
> ><br>
> > David<br>
> ><br>
> > On Wed, Jun 17, 2015 at 4:07 PM, Balaram Makam <<a href="mailto:bmakam@codeaurora.org">bmakam@codeaurora.org</a>><br>
> wrote:<br>
> >> AFAIK, this was fixed in r233817.<br>
<br>
</span>That was later reverted.<br>
<div><div class="h5"><br>
> >><br>
> >> -----Original Message-----<br>
> >> From: <a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvmdev-bounces@cs.uiuc.edu">llvmdev-bounces@cs.uiuc.edu</a>]<br>
> On<br>
> >> Behalf Of Easwaran Raman<br>
> >> Sent: Wednesday, June 17, 2015 6:59 PM<br>
> >> To: <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
> >> Cc: David Li<br>
> >> Subject: [LLVMdev] Inline hint for methods defined in-class<br>
> >><br>
> >> Clang adds the InlineHint attribute to functions that are explicitly<br>
> marked<br>
> >> inline, but not if they are defined in the class body. I tried the<br>
> following<br>
> >> patch, which I believe handles the in-class definition<br>
> >> case:<br>
> >><br>
> >> --- a/lib/CodeGen/CodeGenFunction.cpp<br>
> >> +++ b/lib/CodeGen/CodeGenFunction.cpp<br>
> >> @@ -630,7 +630,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD,<br>
> >> if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D)) {<br>
> >> if (!CGM.getCodeGenOpts().NoInline) {<br>
> >> for (auto RI : FD->redecls())<br>
> >> - if (RI->isInlineSpecified()) {<br>
> >> + if (RI->isInlined()) {<br>
> >> Fn->addFnAttr(llvm::Attribute::InlineHint);<br>
> >> break;<br>
> >> }<br>
> >><br>
> >> I tried this on C++ benchmarks in SPEC 2006. There is no noticeable<br>
> >> performance difference and the maximum text size increase is < 0.25%.<br>
> >> I then built clang with and without this change. This increases the<br>
> text<br>
> >> size by 4.1%. For measuring performance, I compiled a large (4.8<br>
> million<br>
> >> lines) preprocessed file. This change improves runtime performance by<br>
> 0.9%<br>
> >> (average of 10 runs) in O0 and O2.<br>
> >><br>
> >> I think knowing whether a function is defined inside a class body is a<br>
> >> useful hint to the inliner. FWIW, GCC's inliner doesn't differentiate<br>
> these<br>
> >> from explicit inline functions. If the above results doesn't justify<br>
> this<br>
> >> change, are there other benchmarks that I should evaluate? Another<br>
> >> possibility is to add a separate hint for this instead of using the<br>
> existing<br>
> >> inlinehint to allow for better tuning in the inliner.<br>
<br>
</div></div>A function with an in-class definition will have linkonce_odr linkage,<br>
so it should be possible to identify such functions in the inliner<br>
without introducing the inlinehint attribute.<br>
--paulr<br>
<div class="HOEnZb"><div class="h5"><br>
> >><br>
> >> Thanks,<br>
> >> Easwaran<br>
> >> _______________________________________________<br>
> >> LLVM Developers mailing list<br>
> >> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> >> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
> >><br>
> _______________________________________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" rel="noreferrer" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>