https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91386

            Bug ID: 91386
           Summary: open-iscsi iscsiadm miscompiled by LTO on aarch64
           Product: gcc
           Version: 9.1.1
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sch...@linux-m68k.org
  Target Milestone: ---
            Target: aarch64-*-*

This is the start of main from iscsiadm:

    8fe0:       d13003ff        sub     sp, sp, #0xc00
    8fe4:       a9007bfd        stp     x29, x30, [sp]
    8fe8:       910003fd        mov     x29, sp
    8fec:       a9025bf5        stp     x21, x22, [sp, #32]
    8ff0:       2a0003f6        mov     w22, w0
    8ff4:       f0000420        adrp    x0, 8f000
<iscsi_ifaces_get@plt+0x86030>
    8ff8:       a90153f3        stp     x19, x20, [sp, #16]
    8ffc:       f9479800        ldr     x0, [x0, #3888]
    9000:       a90363f7        stp     x23, x24, [sp, #48]
    9004:       d10983ff        sub     sp, sp, #0x260
    9008:       aa0103f7        mov     x23, x1
    900c:       f9400001        ldr     x1, [x0]
    9010:       f9072fe1        str     x1, [sp, #3672]
    9014:       d2800001        mov     x1, #0x0                        // #0
    9018:       b90397ff        str     wzr, [sp, #916]
    901c:       b9039bff        str     wzr, [sp, #920]
    9020:       f901d7ff        str     xzr, [sp, #936]
    9024:       f901dbff        str     xzr, [sp, #944]
    9028:       97fffd12        bl      8470 <iscsi_context_new@plt>
    902c:       f9017fe0        str     x0, [sp, #760]
    9030:       b4007540        cbz     x0, 9ed8 <iscsi_ifaces_get@plt+0xf08>
    9034:       f90153f9        str     x25, [sp, #672]
    9038:       b0000021        adrp    x1, e000 <iscsi_ifaces_get@plt+0x5030>
    903c:       f90157fa        str     x26, [sp, #680]
    9040:       910d0021        add     x1, x1, #0x340
    9044:       f9015bfb        str     x27, [sp, #688]
    9048:       911263e0        add     x0, sp, #0x498
    904c:       f900011c        str     x28, [x8]

The last insn is part of the prologue to save register x28, but x8 is never
set.

This breaks during peephole2:

(insn/f:TI 7430 7429 7271 4 (set (mem/c:DI (plus:DI (reg/f:DI 31 sp)
                (const_int 696 [0x2b8])) [69  S8 A8])
        (reg:DI 28 x28)) 47 {*movdi_aarch64}
     (expr_list:REG_DEAD (reg:DI 28 x28)
        (expr_list:REG_CFA_OFFSET (set (mem/c:DI (plus:DI (reg/f:DI 31 sp)
                        (const_int 696 [0x2b8])) [69  S8 A8])
                (reg:DI 28 x28))
            (nil))))

is transformed into:

(insn/f:TI 7430 7429 7842 4 (set (mem/c:DI (reg:DI 8 x8) [69  S8 A8])
        (reg:DI 28 x28)) 47 {*movdi_aarch64}
     (expr_list:REG_DEAD (reg:DI 28 x28)
        (expr_list:REG_CFA_OFFSET (set (mem/c:DI (plus:DI (reg/f:DI 31 sp)
                        (const_int 696 [0x2b8])) [69  S8 A8])
                (reg:DI 28 x28))
            (nil))))

Reply via email to