<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [ARM] Unnecessary reloads from GOT"
   href="https://bugs.llvm.org/show_bug.cgi?id=35221">35221</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[ARM] Unnecessary reloads from GOT
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: ARM
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>eugeni.stepanov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>ARM backend fails to reuse the address of an external variable between basic
blocks and reloads it from GOT on each use.

# cat 1.c
extern char x;
void fail();
void f() {
  if (x) fail();
  if (x) fail();
  if (x) fail();
}


# clang 1.c -O3 -target arm-linux-androideabi -c && objdump -drl 1.o
f():
   0:   e92d4800        push    {fp, lr}
   4:   e1a0b00d        mov     fp, sp
   8:   e59f004c        ldr     r0, [pc, #76]   ; 5c <f+0x5c>
   c:   e79f0000        ldr     r0, [pc, r0]
  10:   e5d00000        ldrb    r0, [r0]
  14:   e3500000        cmp     r0, #0
  18:   0a00000d        beq     54 <f+0x54>
  1c:   ebfffffe        bl      0 <fail>
                        1c: R_ARM_CALL  fail
  20:   e59f0038        ldr     r0, [pc, #56]   ; 60 <f+0x60>
  24:   e79f0000        ldr     r0, [pc, r0]
  28:   e5d00000        ldrb    r0, [r0]
  2c:   e3500000        cmp     r0, #0
  30:   0a000007        beq     54 <f+0x54>
  34:   ebfffffe        bl      0 <fail>
                        34: R_ARM_CALL  fail
  38:   e59f0024        ldr     r0, [pc, #36]   ; 64 <f+0x64>
  3c:   e79f0000        ldr     r0, [pc, r0]
  40:   e5d00000        ldrb    r0, [r0]
  44:   e3500000        cmp     r0, #0
  48:   0a000001        beq     54 <f+0x54>
  4c:   e8bd4800        pop     {fp, lr}
  50:   eafffffe        b       0 <fail>
                        50: R_ARM_JUMP24        fail
  54:   e8bd4800        pop     {fp, lr}
  58:   e12fff1e        bx      lr
  5c:   00000048        .word   0x00000048
                        5c: R_ARM_GOT_PREL      x
  60:   00000034        .word   0x00000034
                        60: R_ARM_GOT_PREL      x
  64:   00000020        .word   0x00000020
                        64: R_ARM_GOT_PREL      x</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>