[llvm-dev] understanding llvm's codegen for function forwarding
Andrew Kelley via llvm-dev
llvm-dev at lists.llvm.org
Fri Nov 23 11:49:27 PST 2018
When compiling this LLVM IR with -O0 (no optimizations)
define internal fastcc void @bar2(%Bar* nonnull sret) unnamed_addr #2 !dbg !74 {
Entry:
call fastcc void @bar(%Bar* sret %0), !dbg !79
ret void, !dbg !81
}
why does this generate this?
0000000000000090 <bar2>:
90: 55 push %rbp
91: 48 89 e5 mov %rsp,%rbp
94: 48 83 ec 10 sub $0x10,%rsp
98: 48 89 f8 mov %rdi,%rax
9b: 48 89 45 f8 mov %rax,-0x8(%rbp)
9f: e8 0c 00 00 00 callq b0 <bar>
a4: 48 8b 45 f8 mov -0x8(%rbp),%rax
a8: 48 83 c4 10 add $0x10,%rsp
ac: 5d pop %rbp
ad: c3 retq
ae: 66 90 xchg %ax,%ax
instead of something like this?
0000000000000090 <bar2>:
9f: e8 0c 00 00 00 callq b0 <bar>
ad: c3 retq
when I add `musttail` to the IR it gives me this assembly:
00000000000000a0 <bar2>:
a0: 55 push %rbp
a1: 48 89 e5 mov %rsp,%rbp
a4: 48 83 ec 10 sub $0x10,%rsp
a8: 48 89 f8 mov %rdi,%rax
ab: 48 89 45 f8 mov %rax,-0x8(%rbp)
af: 48 83 c4 10 add $0x10,%rsp
b3: 5d pop %rbp
b4: e9 07 00 00 00 jmpq c0 <bar>
b9: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
which does not have a call instruction but it has prologue that I
would not expect.
What's going on here? Is this something that can not really be
improved without optimization passes?
More information about the llvm-dev
mailing list