[LLVMdev] inlining hint
David Vandevoorde
daveed at vandevoorde.com
Wed Aug 26 19:29:40 PDT 2009
On Aug 26, 2009, at 10:14 PM, Chris Lattner wrote:
> On Aug 26, 2009, at 7:02 PM, David Vandevoorde wrote:
>>> It's actually the other way around. llvm has always ignored the
>>> "inline" keyword and now we are finding out we are missing some
>>> important cases.
>>
>> Okay. It's the "other way around" in terms of history, but it looks
>> like the conclusion might be the same: Purely heuristics-based
>> inlining hasn't been proven entirely competitive yet (for C++)?
>
> That is what is unclear. We have no empirical evidence that
> listening to inline will improve the situation more than just
> increasing the inlining threshold across the board. Even if we did,
> I would still be uncomfortable with this: "hasn't been proven
> entirely competitive yet" implies that we've pursued the current
> inliner and tried hard to make it better without listening to
> inline. In fact, the current inliner is almost completely untuned
> and has many known problems.
Definitely: Efforts in this area are almost certainly not a waste.
Even if it turns out you need to take "inline" into account, a better
(back end) inliner is likely to be an appreciable improvement.
My point is mostly that I'm not aware of an existing, competitive C++
compiler that always ignores the "this is a C++ inline function" bit.
That doesn't mean it's not possible, and in fact I'm all for pursuing
it. I _do_ believe that it means that current C++ programs should
only define functions inline if there is good reason to think that
inlining the typical call to that function is a plus.
(P.S., I _have_ worked with a compiler that had a separate flag to
ignore "inline" because a customer has gone inline-crazy and ignoring
inline became a competitive advantage at that point.)
> I am concerned that "listening to inline" will paper over other
> things that could be solved in much better ways. If the inlining
> heuristics were already considered to be well tuned and a study
> showed that 'listening to inline' was better than increasing the
> threshold, then I'd be a believer.
Skepticism is good...
> I am also much more pessimistic about the world's C++ code than
> some. It turns out that not all c++ programmers are totally
> awesome :)
?? Shocked! I'm shocked!!
>
>> My GCC installation here appears to inline g in the following
>> example:
>>
>> inline int g(int x) { return x; }
>>
>> int main() {
>> return g(3);
>> }
>>
>> with just "-O1", but it doesn't do so when I drop the "inline"
>> keyword.
>
> LLVM already does that at -O1 without listening to inline because
> the code is obviously smaller with the inline.
I just wanted to make sure that the observation that GCC ignores
"inline" (implicit or explicit) until -O2 is double-checked (if it
turns out to matter).
Daveed
More information about the llvm-dev
mailing list