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?
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.