[llvm-bugs] [Bug 31227] New: [ARMv6M] missing tail call opportunities and unneeded instr emitted

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Dec 1 11:20:36 PST 2016


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: unassignedbugs at nondot.org
          Reporter: weimingz at codeaurora.org
                CC: llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20161201/01f4ceeb/attachment.html>


More information about the llvm-bugs mailing list