Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Argument promotion not happening for static function. #51521

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52554
Status NEW
Importance P enhancement
Reported by Jeff Muizelaar (jmuizelaar@mozilla.com)
Reported on 2021-11-18 18:35:42 -0800
Last modified on 2021-11-18 18:35:42 -0800
Version trunk
Hardware PC All
CC llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Given:

__attribute__((noinline))
static int foo(const int &x) {
    return x;
}

int r(int x) {
    return foo(x);
}

GCC gives:

foo(int const&) [clone .isra.0]:
        mov     eax, edi
        ret
r(int):
        jmp     foo(int const&) [clone .isra.0]

vs clang's:

r(int):                                  # @r(int)
        push    rax
        mov     dword ptr [rsp + 4], edi
        lea     rdi, [rsp + 4]
        call    foo(int const&)
        pop     rcx
        ret
foo(int const&):                             # @foo(int const&)
        mov     eax, dword ptr [rdi]
        ret