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
    Classification: Unclassified


__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

    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

Reply via email to