public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
@ 2022-10-19  7:08 ` rguenth at gcc dot gnu.org
  2022-12-06 13:57 ` jakub at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-19  7:08 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug target/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
  2022-10-19  7:08 ` [Bug target/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a rguenth at gcc dot gnu.org
@ 2022-12-06 13:57 ` jakub at gcc dot gnu.org
  2022-12-07 20:40 ` [Bug debug/106719] " jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-12-06 13:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The problem happens during split3.
After the splitting but before find_many_sub_basic_blocks we have:
...
(jump_insn 10027 10026 10021 2 (set (pc)
        (if_then_else (ne (reg:SI 2 x2 [100])
                (const_int 0 [0]))
            (label_ref:DI 10022)
            (pc))) "pr106719.c":7:3 31 {*cbnesi1}
     (int_list:REG_BR_PROB 536868 (nil))
 -> 10022)

(note 10021 10027 10016 2 NOTE_INSN_EPILOGUE_BEG)

(insn 10016 10021 10017 2 (use (reg:DI 30 x30)) "pr106719.c":9:1 -1
     (nil))

(jump_insn 10017 10016 10018 2 (return) "pr106719.c":9:1 28 {*do_return}
     (nil)
 -> return)

(barrier 10018 10017 10012)

(note 10012 10018 10013 NOTE_INSN_DELETED)

(note 10013 10012 0 NOTE_INSN_DELETED)
at the end for -g0 (--param min-nondebug-insn-uid=10000), while for -g:
(jump_insn 10027 10026 4 2 (set (pc)
        (if_then_else (ne (reg:SI 2 x2 [100])
                (const_int 0 [0]))
            (label_ref:DI 10022)
            (pc))) "pr106719.c":7:3 31 {*cbnesi1}
     (int_list:REG_BR_PROB 536868 (nil))
 -> 10022)

(debug_insn 4 10027 5 2 (debug_marker) "pr106719.c":8:3 -1
     (nil))

(debug_insn 5 4 10021 2 (var_location:DI psi (const:DI (plus:DI (symbol_ref:DI
("easi") [flags 0xc0] <var_decl 0x7fffea393f30 easi>)
            (const_int 1 [0x1])))) "pr106719.c":8:7 -1
     (nil))

(note 10021 5 10016 2 NOTE_INSN_EPILOGUE_BEG)

(insn 10016 10021 10017 2 (use (reg:DI 30 x30)) "pr106719.c":9:1 -1
     (nil))

(jump_insn 10017 10016 10018 2 (return) "pr106719.c":9:1 28 {*do_return}
     (nil)
 -> return)

(barrier 10018 10017 10012)

(note 10012 10018 10013 NOTE_INSN_DELETED)

(note 10013 10012 0 NOTE_INSN_DELETED)
where jump_insn 10027 is the last one from splitting of
(insn:TI 10009 10008 4 2 (parallel [
            (set (mem/v:HI (reg/f:DI 0 x0 [94]) [-1  S2 A16])
                (unspec_volatile:HI [
                        (not:HI (and:HI (mem/v:HI (reg/f:DI 0 x0 [94]) [-1  S2
A16])
                                (reg:HI 1 x1 [orig:98 esi ] [98])))
                        (const_int 0 [0])
                    ] UNSPECV_ATOMIC_OP))
            (clobber (reg:CC 66 cc))
            (clobber (reg:HI 3 x3 [99]))
            (clobber (reg:SI 2 x2 [100]))
        ]) "pr106719.c":7:3 4459 {atomic_nandhi}
     (expr_list:REG_DEAD (reg:HI 1 x1 [orig:98 esi ] [98])
        (expr_list:REG_DEAD (reg/f:DI 0 x0 [94])
            (expr_list:REG_UNUSED (reg:CC 66 cc)
                (expr_list:REG_UNUSED (reg:HI 3 x3 [99])
                    (expr_list:REG_UNUSED (reg:SI 2 x2 [100])
                        (nil)))))))

So, I guess find_many_sub_basic_blocks doesn't ignore DEBUG_INSNs in decisions
where to split the basic blocks or something, because we get:
(jump_insn 10027 10026 10021 3 (set (pc)
        (if_then_else (ne (reg:SI 2 x2 [100])
                (const_int 0 [0]))
            (label_ref:DI 10022)
            (pc))) "pr106719.c":7:3 31 {*cbnesi1}
     (int_list:REG_BR_PROB 536868 (nil))
 -> 10022)

(note 10021 10027 10029 NOTE_INSN_EPILOGUE_BEG)

(note 10029 10021 10016 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
...
in the -g0 case and
(jump_insn 10027 10026 10029 3 (set (pc)
        (if_then_else (ne (reg:SI 2 x2 [100])
                (const_int 0 [0]))
            (label_ref:DI 10022)
            (pc))) "pr106719.c":7:3 31 {*cbnesi1}
     (int_list:REG_BR_PROB 536868 (nil))
 -> 10022)

(note 10029 10027 4 4 [bb 4] NOTE_INSN_BASIC_BLOCK)

(debug_insn 4 10029 5 4 (debug_marker) "pr106719.c":8:3 -1
     (nil))

(debug_insn 5 4 10021 4 (var_location:DI psi (const:DI (plus:DI (symbol_ref:DI
("easi") [flags 0xc0] <var_decl 0x7fffea393f30 easi>)
            (const_int 1 [0x1])))) "pr106719.c":8:7 -1
     (nil))

(note 10021 5 10016 4 NOTE_INSN_EPILOGUE_BEG)
with -g, i.e. appart from the DEBUG_INSNs NOTE_INSN_EPILOGUE_BEG and
NOTE_INSN_BASIC_BLOCK notes got swapped.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
  2022-10-19  7:08 ` [Bug target/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a rguenth at gcc dot gnu.org
  2022-12-06 13:57 ` jakub at gcc dot gnu.org
@ 2022-12-07 20:40 ` jakub at gcc dot gnu.org
  2022-12-08 13:58 ` cvs-commit at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-12-07 20:40 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 54039
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54039&action=edit
gcc13-pr106719.patch

Untested fix.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2022-12-07 20:40 ` [Bug debug/106719] " jakub at gcc dot gnu.org
@ 2022-12-08 13:58 ` cvs-commit at gcc dot gnu.org
  2022-12-08 13:59 ` [Bug debug/106719] [10/11/12 " jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-12-08 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:d9f9d5d30feb33c359955d7030cc6be50ef6dc0a

commit r13-4559-gd9f9d5d30feb33c359955d7030cc6be50ef6dc0a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 8 14:57:22 2022 +0100

    cfgbuild: Fix DEBUG_INSN handling in find_bb_boundaries [PR106719]

    The following testcase FAILs on aarch64-linux.  We have some atomic
    instruction followed by 2 DEBUG_INSNs (if -g only of course) followed
    by NOTE_INSN_EPILOGUE_BEG followed by some USE insn.
    Now, split3 pass replaces the atomic instruction with a code sequence
    which ends with a conditional jump and the split3 pass calls
    find_many_sub_basic_blocks.
    For -g0, find_bb_boundaries sees the flow_transfer_insn (the new
conditional
    jump), then NOTE_INSN_EPILOGUE_BEG which can live in between basic blocks
    and then the USE insn, so splits block after the NOTE_INSN_EPILOGUE_BEG
    and puts the NOTE in between the blocks.
    For -g, if sees a DEBUG_INSN after the flow_transfer_insn, so sets
    debug_insn to it, then walks over another DEBUG_INSN,
NOTE_INSN_EPILOGUE_BEG
    until it finally sees the USE insn, and triggers the:
              rtx_insn *prev = PREV_INSN (insn);

              /* If the first non-debug inside_basic_block_p insn after a
control
                 flow transfer is not a label, split the block before the debug
                 insn instead of before the non-debug insn, so that the debug
                 insns are not lost.  */
              if (debug_insn && code != CODE_LABEL && code != BARRIER)
                prev = PREV_INSN (debug_insn);
    code I've added for PR81325.  If there are only DEBUG_INSNs, that is
    the right thing to do, but if in between debug_insn and insn there are
    notes which can stay in between basic blocks or simnilarly JUMP_TABLE_DATA
    or their associated CODE_LABELs, it causes -fcompare-debug differences.

    The following patch fixes it by clearing debug_insn if JUMP_TABLE_DATA
    or associated CODE_LABEL is seen (I'm afraid there is no good answer
    what to do with DEBUG_INSNs before those; the code then removes them:
                  /* Clean up the bb field for the insns between the blocks. 
*/
                  for (x = NEXT_INSN (flow_transfer_insn);
                       x != BB_HEAD (fallthru->dest);
                       x = next)
                    {
                      next = NEXT_INSN (x);
                      /* Debug insns should not be in between basic blocks,
                         drop them on the floor.  */
                      if (DEBUG_INSN_P (x))
                        delete_insn (x);
                      else if (!BARRIER_P (x))
                        set_block_for_insn (x, NULL);
                    }
    but if there are NOTEs, the patch just reorders the NOTEs and DEBUG_INSNs,
    such that the NOTEs come first (so that they stay in between basic blocks
    like with -g0) and DEBUG_INSNs after those (so that bb is split before
    them, so they will be in the basic block after NOTE_INSN_BASIC_BLOCK).

    2022-12-08  Jakub Jelinek  <jakub@redhat.com>

            PR debug/106719
            * cfgbuild.cc (find_bb_boundaries): If there are NOTEs in between
            debug_insn (seen after flow_transfer_insn) and insn, move NOTEs
            before all the DEBUG_INSNs and split after NOTEs.  If there are
            other insns like jump table data, clear debug_insn.

            * gcc.dg/pr106719.c: New test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10/11/12 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2022-12-08 13:58 ` cvs-commit at gcc dot gnu.org
@ 2022-12-08 13:59 ` jakub at gcc dot gnu.org
  2023-02-10 17:44 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-12-08 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12/13 Regression]    |[10/11/12 Regression]
                   |'-fcompare-debug' failure   |'-fcompare-debug' failure
                   |w/ -O2 since                |w/ -O2 since
                   |r10-6038-ge5e07b68187b9a    |r10-6038-ge5e07b68187b9a

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed on the trunk so far.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10/11/12 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2022-12-08 13:59 ` [Bug debug/106719] [10/11/12 " jakub at gcc dot gnu.org
@ 2023-02-10 17:44 ` cvs-commit at gcc dot gnu.org
  2023-02-10 17:56 ` [Bug debug/106719] [10/11 " jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-02-10 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:ed8e7ece850bab599c15db3d43041b70d9e99237

commit r12-9124-ged8e7ece850bab599c15db3d43041b70d9e99237
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 8 14:57:22 2022 +0100

    cfgbuild: Fix DEBUG_INSN handling in find_bb_boundaries [PR106719]

    The following testcase FAILs on aarch64-linux.  We have some atomic
    instruction followed by 2 DEBUG_INSNs (if -g only of course) followed
    by NOTE_INSN_EPILOGUE_BEG followed by some USE insn.
    Now, split3 pass replaces the atomic instruction with a code sequence
    which ends with a conditional jump and the split3 pass calls
    find_many_sub_basic_blocks.
    For -g0, find_bb_boundaries sees the flow_transfer_insn (the new
conditional
    jump), then NOTE_INSN_EPILOGUE_BEG which can live in between basic blocks
    and then the USE insn, so splits block after the NOTE_INSN_EPILOGUE_BEG
    and puts the NOTE in between the blocks.
    For -g, if sees a DEBUG_INSN after the flow_transfer_insn, so sets
    debug_insn to it, then walks over another DEBUG_INSN,
NOTE_INSN_EPILOGUE_BEG
    until it finally sees the USE insn, and triggers the:
              rtx_insn *prev = PREV_INSN (insn);

              /* If the first non-debug inside_basic_block_p insn after a
control
                 flow transfer is not a label, split the block before the debug
                 insn instead of before the non-debug insn, so that the debug
                 insns are not lost.  */
              if (debug_insn && code != CODE_LABEL && code != BARRIER)
                prev = PREV_INSN (debug_insn);
    code I've added for PR81325.  If there are only DEBUG_INSNs, that is
    the right thing to do, but if in between debug_insn and insn there are
    notes which can stay in between basic blocks or simnilarly JUMP_TABLE_DATA
    or their associated CODE_LABELs, it causes -fcompare-debug differences.

    The following patch fixes it by clearing debug_insn if JUMP_TABLE_DATA
    or associated CODE_LABEL is seen (I'm afraid there is no good answer
    what to do with DEBUG_INSNs before those; the code then removes them:
                  /* Clean up the bb field for the insns between the blocks. 
*/
                  for (x = NEXT_INSN (flow_transfer_insn);
                       x != BB_HEAD (fallthru->dest);
                       x = next)
                    {
                      next = NEXT_INSN (x);
                      /* Debug insns should not be in between basic blocks,
                         drop them on the floor.  */
                      if (DEBUG_INSN_P (x))
                        delete_insn (x);
                      else if (!BARRIER_P (x))
                        set_block_for_insn (x, NULL);
                    }
    but if there are NOTEs, the patch just reorders the NOTEs and DEBUG_INSNs,
    such that the NOTEs come first (so that they stay in between basic blocks
    like with -g0) and DEBUG_INSNs after those (so that bb is split before
    them, so they will be in the basic block after NOTE_INSN_BASIC_BLOCK).

    2022-12-08  Jakub Jelinek  <jakub@redhat.com>

            PR debug/106719
            * cfgbuild.cc (find_bb_boundaries): If there are NOTEs in between
            debug_insn (seen after flow_transfer_insn) and insn, move NOTEs
            before all the DEBUG_INSNs and split after NOTEs.  If there are
            other insns like jump table data, clear debug_insn.

            * gcc.dg/pr106719.c: New test.

    (cherry picked from commit d9f9d5d30feb33c359955d7030cc6be50ef6dc0a)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10/11 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2023-02-10 17:44 ` cvs-commit at gcc dot gnu.org
@ 2023-02-10 17:56 ` jakub at gcc dot gnu.org
  2023-05-02 20:12 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-02-10 17:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11/12 Regression]       |[10/11 Regression]
                   |'-fcompare-debug' failure   |'-fcompare-debug' failure
                   |w/ -O2 since                |w/ -O2 since
                   |r10-6038-ge5e07b68187b9a    |r10-6038-ge5e07b68187b9a

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for gcc 12.3 too.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10/11 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2023-02-10 17:56 ` [Bug debug/106719] [10/11 " jakub at gcc dot gnu.org
@ 2023-05-02 20:12 ` cvs-commit at gcc dot gnu.org
  2023-05-03  9:27 ` [Bug debug/106719] [10 " jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-02 20:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:f187d4c17546df91c3b6b9c0912403d14c6eb3c8

commit r11-10686-gf187d4c17546df91c3b6b9c0912403d14c6eb3c8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 8 14:57:22 2022 +0100

    cfgbuild: Fix DEBUG_INSN handling in find_bb_boundaries [PR106719]

    The following testcase FAILs on aarch64-linux.  We have some atomic
    instruction followed by 2 DEBUG_INSNs (if -g only of course) followed
    by NOTE_INSN_EPILOGUE_BEG followed by some USE insn.
    Now, split3 pass replaces the atomic instruction with a code sequence
    which ends with a conditional jump and the split3 pass calls
    find_many_sub_basic_blocks.
    For -g0, find_bb_boundaries sees the flow_transfer_insn (the new
conditional
    jump), then NOTE_INSN_EPILOGUE_BEG which can live in between basic blocks
    and then the USE insn, so splits block after the NOTE_INSN_EPILOGUE_BEG
    and puts the NOTE in between the blocks.
    For -g, if sees a DEBUG_INSN after the flow_transfer_insn, so sets
    debug_insn to it, then walks over another DEBUG_INSN,
NOTE_INSN_EPILOGUE_BEG
    until it finally sees the USE insn, and triggers the:
              rtx_insn *prev = PREV_INSN (insn);

              /* If the first non-debug inside_basic_block_p insn after a
control
                 flow transfer is not a label, split the block before the debug
                 insn instead of before the non-debug insn, so that the debug
                 insns are not lost.  */
              if (debug_insn && code != CODE_LABEL && code != BARRIER)
                prev = PREV_INSN (debug_insn);
    code I've added for PR81325.  If there are only DEBUG_INSNs, that is
    the right thing to do, but if in between debug_insn and insn there are
    notes which can stay in between basic blocks or simnilarly JUMP_TABLE_DATA
    or their associated CODE_LABELs, it causes -fcompare-debug differences.

    The following patch fixes it by clearing debug_insn if JUMP_TABLE_DATA
    or associated CODE_LABEL is seen (I'm afraid there is no good answer
    what to do with DEBUG_INSNs before those; the code then removes them:
                  /* Clean up the bb field for the insns between the blocks. 
*/
                  for (x = NEXT_INSN (flow_transfer_insn);
                       x != BB_HEAD (fallthru->dest);
                       x = next)
                    {
                      next = NEXT_INSN (x);
                      /* Debug insns should not be in between basic blocks,
                         drop them on the floor.  */
                      if (DEBUG_INSN_P (x))
                        delete_insn (x);
                      else if (!BARRIER_P (x))
                        set_block_for_insn (x, NULL);
                    }
    but if there are NOTEs, the patch just reorders the NOTEs and DEBUG_INSNs,
    such that the NOTEs come first (so that they stay in between basic blocks
    like with -g0) and DEBUG_INSNs after those (so that bb is split before
    them, so they will be in the basic block after NOTE_INSN_BASIC_BLOCK).

    2022-12-08  Jakub Jelinek  <jakub@redhat.com>

            PR debug/106719
            * cfgbuild.c (find_bb_boundaries): If there are NOTEs in between
            debug_insn (seen after flow_transfer_insn) and insn, move NOTEs
            before all the DEBUG_INSNs and split after NOTEs.  If there are
            other insns like jump table data, clear debug_insn.

            * gcc.dg/pr106719.c: New test.

    (cherry picked from commit d9f9d5d30feb33c359955d7030cc6be50ef6dc0a)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2023-05-02 20:12 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03  9:27 ` jakub at gcc dot gnu.org
  2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org
  2023-05-04  7:19 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-03  9:27 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[10/11 Regression]          |[10 Regression]
                   |'-fcompare-debug' failure   |'-fcompare-debug' failure
                   |w/ -O2 since                |w/ -O2 since
                   |r10-6038-ge5e07b68187b9a    |r10-6038-ge5e07b68187b9a

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 11.4 as well.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2023-05-03  9:27 ` [Bug debug/106719] [10 " jakub at gcc dot gnu.org
@ 2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org
  2023-05-04  7:19 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-03 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:611df5a1400865cf8718c7c60029a03215bbae48

commit r10-11345-g611df5a1400865cf8718c7c60029a03215bbae48
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 8 14:57:22 2022 +0100

    cfgbuild: Fix DEBUG_INSN handling in find_bb_boundaries [PR106719]

    The following testcase FAILs on aarch64-linux.  We have some atomic
    instruction followed by 2 DEBUG_INSNs (if -g only of course) followed
    by NOTE_INSN_EPILOGUE_BEG followed by some USE insn.
    Now, split3 pass replaces the atomic instruction with a code sequence
    which ends with a conditional jump and the split3 pass calls
    find_many_sub_basic_blocks.
    For -g0, find_bb_boundaries sees the flow_transfer_insn (the new
conditional
    jump), then NOTE_INSN_EPILOGUE_BEG which can live in between basic blocks
    and then the USE insn, so splits block after the NOTE_INSN_EPILOGUE_BEG
    and puts the NOTE in between the blocks.
    For -g, if sees a DEBUG_INSN after the flow_transfer_insn, so sets
    debug_insn to it, then walks over another DEBUG_INSN,
NOTE_INSN_EPILOGUE_BEG
    until it finally sees the USE insn, and triggers the:
              rtx_insn *prev = PREV_INSN (insn);

              /* If the first non-debug inside_basic_block_p insn after a
control
                 flow transfer is not a label, split the block before the debug
                 insn instead of before the non-debug insn, so that the debug
                 insns are not lost.  */
              if (debug_insn && code != CODE_LABEL && code != BARRIER)
                prev = PREV_INSN (debug_insn);
    code I've added for PR81325.  If there are only DEBUG_INSNs, that is
    the right thing to do, but if in between debug_insn and insn there are
    notes which can stay in between basic blocks or simnilarly JUMP_TABLE_DATA
    or their associated CODE_LABELs, it causes -fcompare-debug differences.

    The following patch fixes it by clearing debug_insn if JUMP_TABLE_DATA
    or associated CODE_LABEL is seen (I'm afraid there is no good answer
    what to do with DEBUG_INSNs before those; the code then removes them:
                  /* Clean up the bb field for the insns between the blocks. 
*/
                  for (x = NEXT_INSN (flow_transfer_insn);
                       x != BB_HEAD (fallthru->dest);
                       x = next)
                    {
                      next = NEXT_INSN (x);
                      /* Debug insns should not be in between basic blocks,
                         drop them on the floor.  */
                      if (DEBUG_INSN_P (x))
                        delete_insn (x);
                      else if (!BARRIER_P (x))
                        set_block_for_insn (x, NULL);
                    }
    but if there are NOTEs, the patch just reorders the NOTEs and DEBUG_INSNs,
    such that the NOTEs come first (so that they stay in between basic blocks
    like with -g0) and DEBUG_INSNs after those (so that bb is split before
    them, so they will be in the basic block after NOTE_INSN_BASIC_BLOCK).

    2022-12-08  Jakub Jelinek  <jakub@redhat.com>

            PR debug/106719
            * cfgbuild.c (find_bb_boundaries): If there are NOTEs in between
            debug_insn (seen after flow_transfer_insn) and insn, move NOTEs
            before all the DEBUG_INSNs and split after NOTEs.  If there are
            other insns like jump table data, clear debug_insn.

            * gcc.dg/pr106719.c: New test.

    (cherry picked from commit d9f9d5d30feb33c359955d7030cc6be50ef6dc0a)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug debug/106719] [10 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a
       [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
                   ` (9 preceding siblings ...)
  2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org
@ 2023-05-04  7:19 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-04  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 10.5 too.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-04  7:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-106719-4@http.gcc.gnu.org/bugzilla/>
2022-10-19  7:08 ` [Bug target/106719] [10/11/12/13 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a rguenth at gcc dot gnu.org
2022-12-06 13:57 ` jakub at gcc dot gnu.org
2022-12-07 20:40 ` [Bug debug/106719] " jakub at gcc dot gnu.org
2022-12-08 13:58 ` cvs-commit at gcc dot gnu.org
2022-12-08 13:59 ` [Bug debug/106719] [10/11/12 " jakub at gcc dot gnu.org
2023-02-10 17:44 ` cvs-commit at gcc dot gnu.org
2023-02-10 17:56 ` [Bug debug/106719] [10/11 " jakub at gcc dot gnu.org
2023-05-02 20:12 ` cvs-commit at gcc dot gnu.org
2023-05-03  9:27 ` [Bug debug/106719] [10 " jakub at gcc dot gnu.org
2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org
2023-05-04  7:19 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).