[llvm-bugs] [Bug 50117] New: Missed opportunity to use tail calls
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Apr 25 11:25:05 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50117
Bug ID: 50117
Summary: Missed opportunity to use tail calls
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
void foo (char *, int n);
int bar (int);
int baz (char *p);
int
test1 (int n)
{
{
char buf[64];
foo (buf, n);
}
return bar (n);
}
void
test2 (char *p)
{
{
char c;
baz (&c);
}
baz (p);
}
test1: # @test1
push rbx
sub rsp, 64
mov ebx, edi
mov rdi, rsp
mov esi, ebx
call foo
mov edi, ebx
call bar // can be jmp bar
add rsp, 64
pop rbx
ret
test2: # @test2
push rbx
sub rsp, 16
mov rbx, rdi
lea rdi, [rsp + 15]
call baz
mov rdi, rbx
call baz // can be jmp baz
add rsp, 16
pop rbx
ret
https://godbolt.org/z/TvM81eYod
In IR I see that we have just call, not "tail call", so a middle-end issue.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210425/205b2f19/attachment.html>
More information about the llvm-bugs
mailing list