-finline-functions and /Ob2 are currently ignored by Clang. The only way to enable inlining is to use the global O flags, which also enable other options, or to emit LLVM bitcode using Clang, then running opt by hand with the inline pass.
This patch allows to simply use the -finline-functions flag (same as GCC) or /Ob2 in clang-cl mode to enable inlining without other optimizations.
This is the first patch of a serie to improve support for the /Ob flags.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Thanks! Some comments below:
lib/Driver/Tools.cpp | ||
---|---|---|
5335 ↗ | (On Diff #58261) | Please line break this; lines should be <= 80 columns wide. |
5337 ↗ | (On Diff #58261) | I think this can be: InlineArg->render(Args, CmdArgs) instead |
lib/Frontend/CompilerInvocation.cpp | ||
446 ↗ | (On Diff #58261) | This line and 444 need line breaks too. |
test/CodeGen/inline-optim.c | ||
16 ↗ | (On Diff #58261) | I'd suggest using "check-label" for the @foo checks. See http://llvm.org/docs/CommandGuide/FileCheck.html#the-check-label-directive |
24 ↗ | (On Diff #58261) | For all these checks, I'd suggest matching e.g. "call i32 @inline_hint" to make it a little easier to see what' being matched for. I suppose your checks could match either the calls, or the definitions of the called function. |
Thanks!
Updated to respect the 80-columns limit.
Updated the tests to have a clearer checks. (I don't know well the FileCheck, so I took example from test/CodeGen/noinline.c, but this is indeed more comprehensible).
Looks good to me!
Do you have commit access, or would you like me to commit this for you?
majnemer reminded me that /O options can be combined, so e.g. /Odb2 would be a valid combination. I've followed up with r270614 to move the /Ob flags into that mechanism.
Hello,
It seems the new test was commited as .cc instead of .c, which changes the name mangling, making // NOINLINE-LABEL: @foo fail.
Either the file should be renamed, or -x c should be added to clang invocation, or LABEL check updated.
Sigh, I'm not getting many points today.
I renamed the test because when I tried it, the inline_hint() function didn't get inlined in C mode, but it did in C++ mode. But in so doing, I renamed it to .cc, which means the test didn't run at all (it should be .cpp), which is why I didn't notice that the test doesn't pass.
The reason inlining didn't happen was probably because I ran the test for a different target than you did. Which reminds me, the test needs to specify a target triple.
Hopefully I managed to make things right in r270633