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

            Bug ID: 25722
           Summary: ARM: integrated assembler should replace "ldr rX,
                    =imm" with "mov rX, #imm" if imm can be encoded as
                    immediate
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: ARM
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

gas does that, it produces smaller code, and it prevents follow-on "out of
range pc-relative fixup value" errors if the ldr is in a large-ish code block
and the offset to the constant pool is too large.

Example (reduced from boringssl):

thakis@thakis:~/src/chrome/src$ head arm.S
.fpu neon
.text
.align 4
.global foo
.hidden foo
.type foo, %function

ldr r4, =0
mov r1, r2
mov r1, r2
/* repeat previous instruction 2000 times here */

thakis@thakis:~/src/chrome/src$
third_party/llvm-build/Release+Asserts/bin/clang -c arm.S -march=armv7-a 
-target arm-linux-androideab
arm.S:8:1: error: out of range pc-relative fixup value
ldr r4, =0
^
thakis@thakis:~/src/chrome/src$
third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc
-c arm.S
thakis@thakis:~/src/chrome/src$
third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objdump
-D -marm arm.o  | head

arm.o:     file format elf32-littlearm


Disassembly of section .text:

00000000 <.text>:
       0:    e3a04000     mov    r4, #0
       4:    e1a01002     mov    r1, r2
       8:    e1a01002     mov    r1, r2

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

Reply via email to