Open
Description
Bugzilla Link | 36491 |
Version | trunk |
OS | Linux |
CC | @echristo,@MatzeB |
Extended Description
$ cat 1.c
void use(void *);
void *p;
void f() {
int x;
p = &x;
use(&x);
}
$ bin/clang 1.c -target aarch64-linux-android -O3 -fomit-frame-pointer -c && bin/llvm-objdump -d -r 1.o
0: fe 0f 1f f8 str x30, [sp, #-16]!
4: 08 00 00 90 adrp x8, #​0
0000000000000004: R_AARCH64_ADR_PREL_PG_HI21 p
8: e9 33 00 91 add x9, sp, #​12
c: e0 33 00 91 add x0, sp, #​12
10: 09 01 00 f9 str x9, [x8]
0000000000000010: R_AARCH64_LDST64_ABS_LO12_NC p
14: 00 00 00 94 bl #0
0000000000000014: R_AARCH64_CALL26 use
18: fe 07 41 f8 ldr x30, [sp], #​16
1c: c0 03 5f d6 ret
Here x0 and x9 could be merged, but RegisterCoalescer would never consider merging into a physical register. Instead it remats ADDXri %stack.0.x, 0, 0.
This is specific to AArch64 backend. The same does not happen on X86 because ADDXri is asCheapAsAMove, while LEA is not.