[LLVMdev] Inlining
Dustin Laurence
dllaurence at dslextreme.com
Sat Jan 9 01:46:29 PST 2010
On 01/08/2010 09:17 PM, Nick Lewycky wrote:
> Try using 'internal' linkage instead of 'linkonce'.
That did it, thanks.
---
gemini:~/Projects/LLVM/Tests/Inline(0)$ cat testInline.optdis.ll
; ModuleID = 'testInline.optbc'
define i32 @main(i32 %argc, i8** nocapture %argv) nounwind readnone {
ret i32 42
}
gemini:~/Projects/LLVM/Tests/Inline(0)$
---
> If you're sure you
> really want linkonce then you'd need to use linkonce_odr to get inlining
> here.
I'm sure of nothing. I only used it because the IR Reference says
linkonce:
Globals with "linkonce" linkage are merged with other globals of
the same name when linkage occurs. This is typically used to
implement inline functions, templates, or other code which must be
generated in each translation unit that uses it. Unreferenced
linkonce globals are allowed to be discarded.
So I thought it was telling me to use linkonce for inline functions.+
A bit more experimentation shows that it still inlines with the default
linkage, the only difference being it retains a non-inlined version as
well. With 'internal' it omits the non-inlined version. I think I see
why that's true.
> Also, drop the alwaysinline attribute and '-always-inline' flag. The
> normal inliner (aka. "opt -inline" which is run as part of "opt -O3")
> should inline it.
Yes, it still did after I removed them. Since I'm clearly not guessing
well here, when would one want to use "alwaysinline"?
Dustin
More information about the llvm-dev
mailing list