]> git.ipfire.org Git - thirdparty/gcc.git/commit
[debug] Fix pre_dec handling in vartrack
authorTom de Vries <tdevries@suse.de>
Mon, 16 Jul 2018 09:18:51 +0000 (09:18 +0000)
committerTom de Vries <vries@gcc.gnu.org>
Mon, 16 Jul 2018 09:18:51 +0000 (09:18 +0000)
commit8c0e07e3842dd90c09fd3f4b5fe17362c5ab4077
treec623200c666ebbf79d9e42f357704c66ba1bf055
parent1d896f48fa2f796ba13773ab735ef40fa3afb257
[debug] Fix pre_dec handling in vartrack

When compiling test-case gcc.target/i386/vartrack-1.c with -O1 -g, register bx
is pushed in the prologue and popped in the epilogue:
...
(insn/f 26 3 27 2
  (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
       (reg:DI 3 bx))
   "vartrack-1.c":10 61 {*pushdi2_rex64}
   (expr_list:REG_DEAD (reg:DI 3 bx) (nil)))
  ...
(insn/f 29 28 30 2
  (set (reg:DI 3 bx)
       (mem:DI (post_inc:DI (reg/f:DI 7 sp)) [0  S8 A8]))
   "vartrack-1.c":15 71 {*popdi1}
   (expr_list:REG_CFA_ADJUST_CFA
     (set (reg/f:DI 7 sp)
          (plus:DI (reg/f:DI 7 sp)
                   (const_int 8 [0x8]))) (nil)))
...

However, when we adjust those insns in vartrack to eliminate the pre_dec and
post_inc, the frame location for the push is at argp - 24, while the one for the
pop is at argp - 16:
...
(insn/f 26 3 27 2
  (parallel [
    (set (mem:DI (plus:DI (reg/f:DI 16 argp)
                          (const_int -24 [0xffffffffffffffe8])) [0  S8 A8])
         (reg:DI 3 bx))
    (set (reg/f:DI 7 sp)
         (plus:DI (reg/f:DI 16 argp)
                  (const_int -24 [0xffffffffffffffe8])))
  ])
  "vartrack-1.c":10 61 {*pushdi2_rex64}
  (expr_list:REG_DEAD (reg:DI 3 bx) (nil)))
  ...
(insn/f 29 28 30 2
  (parallel [
    (set (reg:DI 3 bx)
         (mem:DI (plus:DI (reg/f:DI 16 argp)
                          (const_int -16 [0xfffffffffffffff0])) [0  S8 A8]))
    (set (reg/f:DI 7 sp)
         (plus:DI (reg/f:DI 16 argp)
                  (const_int -8 [0xfffffffffffffff8])))
  ])
  "vartrack-1.c":15 71 {*popdi1}
  (expr_list:REG_CFA_ADJUST_CFA
    (set (reg/f:DI 7 sp)
         (plus:DI (reg/f:DI 7 sp)
                  (const_int 8 [0x8]))) (nil)))
...

This patch fixes that by moving the stack_adjust modification after
adjust_insn in vt_initialize.

Bootstrapped and reg-tested on x86_64.

2018-07-16  Tom de Vries  <tdevries@suse.de>

PR debug/86455
* var-tracking.c (vt_initialize): Fix pre_dec handling.

* gcc.target/i386/vartrack-1.c: New test.

From-SVN: r262687
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/vartrack-1.c [new file with mode: 0644]
gcc/var-tracking.c