https://llvm.org/bugs/show_bug.cgi?id=31227

            Bug ID: 31227
           Summary: [ARMv6M] missing tail call opportunities and unneeded
                    instr emitted
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: weimi...@codeaurora.org
                CC: llvm-bugs@lists.llvm.org
    Classification: Unclassified

test.c:

__attribute__((noinline)) static int foo(int a) {
  return a*10;
}

int caller(int b) {
  b += 10;
  return foo(b);
}

clang -mcpu=cortex-m0 -target armv6m-linux-gnueabi -S -Os test.c -o test.llvm.s

test.llvm.s:
caller:
    .fnstart
    push    {r7, lr}
    add    r7, sp, #0  ==> why do we need this?
    adds    r0, #10
    bl    foo
    pop    {r7, pc}

Other compilers generate:
00000006 <caller>:
   6:    300a          adds    r0, #10
   8:    e7fe          b.n    0 <foo>

LLVM generated code has 2 problems:
1. unneeded instruction "add r7, sp, #0" is emitted
2. Other compiler can do tail call. on armv6m, "b" can be thumb2 with imm11 but
still not a big range. Maybe linker can do trampoline?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to