[LLVMbugs] [Bug 8318] New: ARM EABI: inefficient code saving/restoring sp around function call

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Oct 6 15:39:34 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=8318

           Summary: ARM EABI: inefficient code saving/restoring sp around
                    function call
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: john at bass-software.com
                CC: llvmbugs at cs.uiuc.edu


ToT & built both llvm-gcc and clang for arm-unknown-eabi target.

This simple C program:

--8<--
int foo(int a);

int
bar (int a)
{
  return 5 + foo(a);
}
--8<--

Get compiled with clang as:

$ clang -ccc-host-triple armv7-unknown-eabi -S -O3 -o test1.S test1.c && cat
test1.S

--8<--
    .syntax unified
    .cpu cortex-a8
    .eabi_attribute 10, 2
    .eabi_attribute 20, 1
    .eabi_attribute 21, 1
    .eabi_attribute 23, 3
    .eabi_attribute 24, 1
    .eabi_attribute 25, 1
    .file    "test1.c"
    .text
    .globl    bar
    .align    2
    .type    bar,%function
bar:
    push    {r11, lr}
    bl    foo
    mov    r11, sp            <== ???
    add    r0, r0, #5
    mov    sp, r11            <== ???
    ldmia    sp!, {r11, pc}
.Ltmp0:
    .size    bar, .Ltmp0-bar
--8<--

I.e. the save & restore of sp is very odd and unnecessary IMHO.

When using llvm-gcc I don't get that output:

$ arm-unknown-eabi-gcc -mcpu=cortex-a8 -O3 -S -O3 -o test1.S test1.c && cat
test1.S

--8<--
    .syntax unified
    .cpu cortex-a8
    .eabi_attribute 20, 1
    .eabi_attribute 21, 1
    .eabi_attribute 23, 3
    .eabi_attribute 24, 1
    .eabi_attribute 25, 1
    .file    "test1.c"
    .text
    .globl    bar
    .align    2
    .type    bar,%function
bar:
    push    {r11, lr}
    bl    foo
    add    r0, r0, #5
    ldmia    sp!, {r11, pc}
.Ltmp0:
    .size    bar, .Ltmp0-bar


    .ident    "GCC: (GNU) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build)"
--8<--

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list