Skip to content

missing tail call optimization on RVO #146303

@rockeet

Description

@rockeet
struct Slice {
    const char* data;
    unsigned long size;
    ~Slice();
};
Slice get_s_impl();
Slice get_s() { return get_s_impl(); }

clang produces:

get_s():
        push    rbx
        mov     rbx, rdi
        call    get_s_impl()
        mov     rax, rbx
        pop     rbx
        ret

icc recognized tail call and produces:

get_s():
..B1.1:                         # Preds ..B1.0
        jmp       get_s_impl()                               #7.24

g++ also missed such tail call optimization.

If delete ~Slice;, g++ & clang recognize the tail call, but icc fails.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions