[llvm-bugs] [Bug 25722] New: ARM: integrated assembler should replace "ldr rX, =imm" with "mov rX, #imm" if imm can be encoded as immediate

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Dec 2 13:07:30 PST 2015


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: unassignedbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org
    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 at 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 at 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 at 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 at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151202/96cbd523/attachment-0001.html>


More information about the llvm-bugs mailing list