[LLVMbugs] [Bug 8921] New: ARM/Thumb interoperability broken in v4T

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 6 07:22:09 PST 2011


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

           Summary: ARM/Thumb interoperability broken in v4T
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rengolin at gmail.com
                CC: llvmbugs at cs.uiuc.edu


The following code generates wrong assembly when compiled to ARM:

extern int c();

int b()
{
  return c()+1;
}


int a()
{
  return b();
}

EABI requires ARM/Thumb interoperability by default (unless you know *exactly*
what you're doing, which is not the case). LLVM back-end (either through clang
or clang+llc) is generating b() as:

b:
        push    {r11, lr}
        mov     r11, sp
        bl      c
        add     r0, r0, #1
        ldmia   sp!, {r11, pc}

which doesn't take into account the instruction set change. The correct way to
return is "bx lr" as a default case. We're having problems when linking against
7TDMI libraries, since it has both ARM and Thumb functions.

The command lines:

$ clang -ccc-host-triple armv4t-none-eabi -mfloat-abi=softfp -S test.c

or

$ clang -ccc-host-triple armv4t-none-eabi -mfloat-abi=softfp -emit-llvm -S
test.c -o test.ll
$ llc -march=arm test.ll -o -

Attaching source, IR and assembly generated with trunk clang+llc.

-- 
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