[llvm-bugs] [Bug 36491] New: Undesirable rematerialization of stack address computation

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 23 10:54:15 PST 2018


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

            Bug ID: 36491
           Summary: Undesirable rematerialization of stack address
                    computation
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AArch64
          Assignee: unassignedbugs at nondot.org
          Reporter: eugeni.stepanov at gmail.com
                CC: llvm-bugs at lists.llvm.org

$ 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.

-- 
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/20180223/ee288b7b/attachment.html>


More information about the llvm-bugs mailing list