[llvm-dev] always inliner only works when function is called from external function?

63 views
Skip to first unread message

Andrew Kelley via llvm-dev

unread,
Apr 11, 2017, 3:27:39 AM4/11/17
to LLVM Dev
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?

David Blaikie via llvm-dev

unread,
Apr 11, 2017, 12:28:26 PM4/11/17
to Andrew Kelley, LLVM Dev

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...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply all
Reply to author
Forward
0 new messages