From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5F1613846063; Fri, 10 Feb 2023 17:44:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F1613846063 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676051057; bh=046hE4I7XtAlI0LiKM3QuV2WnjlgUvPcslOi8OfW0Yo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ryDcITwRziQjX654FG3dnRlVoTUSXB0/geXoiWlgPkd7P0pmK8J04O82Hy9h6+ltB a6S4P6pUIQB2BbPAOUCWll2nSoy7ZxJ/8Cx3IWHnHiZV83F7wrNN1IdNPsEawmgHnn +cV3IiHtDP1ouvZ34eqXJEhAJqnuJKuep88IsXpM= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/106719] [10/11/12 Regression] '-fcompare-debug' failure w/ -O2 since r10-6038-ge5e07b68187b9a Date: Fri, 10 Feb 2023 17:44:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: compare-debug-failure X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106719 --- Comment #6 from CVS Commits --- The releases/gcc-12 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:ed8e7ece850bab599c15db3d43041b70d9e99237 commit r12-9124-ged8e7ece850bab599c15db3d43041b70d9e99237 Author: Jakub Jelinek 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 bloc= ks 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 =3D 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 d= ebug insn instead of before the non-debug insn, so that the deb= ug insns are not lost. */ if (debug_insn && code !=3D CODE_LABEL && code !=3D BARRIER) prev =3D 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_D= ATA 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= .=20 */ for (x =3D NEXT_INSN (flow_transfer_insn); x !=3D BB_HEAD (fallthru->dest); x =3D next) { next =3D 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_INS= Ns, such that the NOTEs come first (so that they stay in between basic bloc= ks 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 PR debug/106719 * cfgbuild.cc (find_bb_boundaries): If there are NOTEs in betwe= en 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)=