<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55816>55816</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [ARM][ASSEMBLER] literal pool entries are not merged
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            backend:ARM,
            missed-optimization
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nickdesaulniers
      </td>
    </tr>
</table>

<pre>
    [reported](https://lore.kernel.org/linux-arm-kernel/20220530112417.2492510-1-ardb@kernel.org/) by @ardbiesheuvel 

Consider the following asm:
```asm
.global foo
foo:
  ldr r0, =foo
  ldr r0, =foo
```
With `arm-linux-gnueabi-as x.s -o x.o; llvm-objdump -dr x.o` we get:
```asm
00000000 <foo>:
       0: 00 00 1f e5   ldr     r0, [pc, #-0]           @ 0x8 <$d>
       4: 04 00 1f e5   ldr     r0, [pc, #-4]           @ 0x8 <$d>

00000008 <$d>:
       8:       00 00 00 00     .word   0x00000000
                        00000008:  R_ARM_ABS32  foo
```
with `clang --target=arm-linux-gnueabi x.s -c; llvm-objdump -dr x.o` we get:
```asm
00000000 <foo>:
       0: 00 00 9f e5   ldr     r0, [pc]                @ 0x8 <$d.1>
       4: 00 00 9f e5   ldr     r0, [pc]                @ 0xc <$d.1+0x4>

00000008 <$d.1>:
       8:       00 00 00 00     .word   0x00000000
                        00000008:  R_ARM_ABS32  foo
       c:       00 00 00 00     .word   0x00000000
                        0000000c:  R_ARM_ABS32  foo
```
I'm guessing we could save some space by not repeatedly emitting the same data twice with two different relocations.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VcFymzAQ_Rq4aGCEABsOHOw4nelMc0kOPWYEWmMlAjGSiJ1-fVdgJ3GbpGk7E0aDxWp5ertPftRaPFZBvjYwaONABPkmYMXOucEG6SpgX3AobSC-B9ODirVpfUT24yHipovmMIYYZYzmKU0SliXLmGUlyxMaJZgl6iCjZ-8HrCT1I8GwX5VgdzA-gCIB3QR0Nd8vdG-lAEPcDshWK6X3sm8Jt50nNicu6Dx8cIrErdI1V5iv54CfnNIJUcIQQwN2QYJ085TzVvwJfn78Lt2O-M2w7LkBbT8Cr2XELTnElkQaf3C7NVHqoYt0fSfGbiARgvv4gpI9kBbcO_zp8UIeFxP1yxfsp4tigGACjmRLICfYtBL54_1YQb4emmnC0oiinuT5woYTeig8esAy4eFfYmcTdvZB7Oxj2GeFnS3_UlkxBcq5tmngU7zXRvjo4dSaE2o5jxOwp06ub1fXV7er9U3KcOktIfdHIRvF8UBFkeNmUmXzm7KzrM3nSVq-0_azbr_W8jh5XdB_Rm5eILM1PWR_EHUm8GmyHjdo_meD5i_OzdeALTvSjmCtdyJUvtGjEsTyByBWd3gbeAPe2XrtCFoqcLRU9Uigk875d7yXWY6ZgjtO3F5i-nQc3V4TIbdbMND7V5VuuJNogXEoqlSUaclDJ50Cb9ZI1vs0Tm5uLq_W3y6vvYRKOjDofYPWiiCKQV8l3MBEpgM84yIcjarOzb3F3cc6bnTnfR0P-fEnGoy-g8bho7QWa8ZJnhfJItxVQEtIizIRbJksqFjSLZQgigaKbVkkuQgVr0FZTzVgrObNPfT4j1953ozN_sE6hAUR6cHJTv6YivWL-SaU1fQxWeC3BPfLk5izkglRbst6maYFFHg6oeNSxZ6o_6SEppo412NrcVFJ6-zzIke92h6m1nl8PrqdNlUvm3sBlo-ql2BsOJVZTTX-BJY75Sw">