Andrew Kelley via llvm-dev
2017-Apr-11 07:27 UTC
[llvm-dev] always inliner only works when function is called from external function?
Observe: [nix-shell:~/tmp]$ cat test.ll define internal fastcc void @foo() { Entry: call fastcc void @bar() ret void } ; Function Attrs: alwaysinline define internal fastcc void @bar() #0 { Entry: ret void } attributes #0 = { alwaysinline } [nix-shell:~/tmp]$ opt test.ll -always-inline -S ; ModuleID = 'test.ll' source_filename = "test.ll" define internal fastcc void @foo() { Entry: call fastcc void @bar() ret void } ; Function Attrs: alwaysinline define internal fastcc void @bar() #0 { Entry: ret void } attributes #0 = { alwaysinline } If I delete "internal" from foo, then the optimziation pass in fact inlines bar. Is this intentional? Is there a way to make the always inliner pass work on internal functions like this too? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170411/408f3782/attachment.html>
David Blaikie via llvm-dev
2017-Apr-11 16:28 UTC
[llvm-dev] always inliner only works when function is called from external function?
On Tue, Apr 11, 2017 at 12:27 AM Andrew Kelley via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Observe: > > [nix-shell:~/tmp]$ cat test.ll > define internal fastcc void @foo() { > Entry: > call fastcc void @bar() > ret void > } > > ; Function Attrs: alwaysinline > define internal fastcc void @bar() #0 { > Entry: > ret void > } > > attributes #0 = { alwaysinline } > > > [nix-shell:~/tmp]$ opt test.ll -always-inline -S > ; ModuleID = 'test.ll' > source_filename = "test.ll" > > define internal fastcc void @foo() { > Entry: > call fastcc void @bar() > ret void > } > > ; Function Attrs: alwaysinline > define internal fastcc void @bar() #0 { > Entry: > ret void > } > > attributes #0 = { alwaysinline } > > > If I delete "internal" from foo, then the optimziation pass in fact > inlines bar. Is this intentional? Is there a way to make the always inliner > pass work on internal functions like this too? >Is this a really representative test? the internal function has no callers - so it doesn't really matter how it's optimized, right? Because it's dead code. My test case seems to show that if the function is used, then the inliner will inline into it - but if it's dead code, it won't.> _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170411/4645ebdc/attachment.html>