From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 95974158112 for ; Thu, 12 Jun 2025 05:46:54 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 756A9340AE2 for ; Thu, 12 Jun 2025 05:46:54 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 68E481104DB; Thu, 12 Jun 2025 05:46:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id 5A99C1104DB for ; Thu, 12 Jun 2025 05:46:53 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D352D340AB6 for ; Thu, 12 Jun 2025 05:46:52 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 501B5651 for ; Thu, 12 Jun 2025 05:46:51 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1749707195.60c5a7be8bfe811a312076812624f30b8ff10cce.sam@gentoo> Subject: [gentoo-commits] proj/gcc-patches:master commit in: 16.0.0/gentoo/ X-VCS-Repository: proj/gcc-patches X-VCS-Files: 16.0.0/gentoo/75_all_PR120629.patch X-VCS-Directories: 16.0.0/gentoo/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 60c5a7be8bfe811a312076812624f30b8ff10cce X-VCS-Branch: master Date: Thu, 12 Jun 2025 05:46:51 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 459bb0e3-19fc-4aa7-b772-2de9c6241be0 X-Archives-Hash: 5d76d5873292b9eb752faf12c261db37 commit: 60c5a7be8bfe811a312076812624f30b8ff10cce Author: Sam James gentoo org> AuthorDate: Thu Jun 12 05:46:35 2025 +0000 Commit: Sam James gentoo org> CommitDate: Thu Jun 12 05:46:35 2025 +0000 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=60c5a7be 16.0.0: add fix for profiledbootstrap Bug: https://gcc.gnu.org/PR120629 Signed-off-by: Sam James gentoo.org> 16.0.0/gentoo/75_all_PR120629.patch | 101 ++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/16.0.0/gentoo/75_all_PR120629.patch b/16.0.0/gentoo/75_all_PR120629.patch new file mode 100644 index 0000000..77b562a --- /dev/null +++ b/16.0.0/gentoo/75_all_PR120629.patch @@ -0,0 +1,101 @@ +https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120629#c22 + +2025-06-12 Jakub Jelinek + + PR middle-end/120629 + * cfgexpand.cc (expand_gimple_cond): If dest bb isn't BB_RTL, + has any PHI nodes and false_edge->dest_idx before redirection is + different from make_single_succ_edge result's dest_idx, swap the + latter with the former last pred edge and their dest_idx members. + + * g++.dg/opt/pr120629.C: New test. + +--- a/gcc/cfgexpand.cc 2025-06-11 19:28:52.462056696 +0200 ++++ g/gcc/cfgexpand.cc 2025-06-12 00:05:27.524152553 +0200 +@@ -3013,6 +3013,9 @@ expand_gimple_cond (basic_block bb, gcon + + new_bb = create_basic_block (NEXT_INSN (last), get_last_insn (), bb); + dest = false_edge->dest; ++ unsigned int dest_idx = 0; ++ if ((dest->flags & BB_RTL) == 0 && phi_nodes (dest)) ++ dest_idx = false_edge->dest_idx; + redirect_edge_succ (false_edge, new_bb); + false_edge->flags |= EDGE_FALLTHRU; + new_bb->count = false_edge->count (); +@@ -3021,7 +3024,19 @@ expand_gimple_cond (basic_block bb, gcon + if (loop->latch == bb + && loop->header == dest) + loop->latch = new_bb; +- make_single_succ_edge (new_bb, dest, 0); ++ edge e = make_single_succ_edge (new_bb, dest, 0); ++ if ((dest->flags & BB_RTL) == 0 ++ && phi_nodes (dest) ++ && e->dest_idx != dest_idx) ++ { ++ /* If there are any PHI nodes on dest, swap the new succ edge ++ with the one moved into false_edge's former position, so that ++ PHI arguments don't need adjustment. */ ++ edge e2 = EDGE_PRED (dest, dest_idx); ++ std::swap (e->dest_idx, e2->dest_idx); ++ std::swap (EDGE_PRED (dest, e->dest_idx), ++ EDGE_PRED (dest, e2->dest_idx)); ++ } + if (BARRIER_P (BB_END (new_bb))) + BB_END (new_bb) = PREV_INSN (BB_END (new_bb)); + update_bb_for_insn (new_bb); +--- a/gcc/testsuite/g++.dg/opt/pr120629.C 2025-06-12 00:13:02.928211946 +0200 ++++ g/gcc/testsuite/g++.dg/opt/pr120629.C 2025-06-12 00:14:26.008117524 +0200 +@@ -0,0 +1,53 @@ ++// PR middle-end/120629 ++// { dg-do run } ++// { dg-options "-O2 -fprofile-generate -fno-exceptions -fno-rtti" } ++// { dg-require-profiling "-fprofile-generate" } ++ ++__attribute__((noipa, noreturn, cold)) void ++foo (const char *, int, const char *) ++{ ++ __builtin_abort (); ++} ++ ++struct S ++{ ++ __attribute__((noipa)) void bar (void *); ++ static const int a = 8; ++ unsigned int b[a + 1]; ++}; ++ ++__attribute__((noipa)) unsigned long ++baz (void *) ++{ ++ static int x = 8; ++ return --x; ++} ++ ++__attribute__((noipa)) void ++S::bar (void *x) ++{ ++ unsigned int c; ++ int k = 0; ++ ++ do ++ { ++ ((void) (!(k <= a) ? foo ("foo", 42, __FUNCTION__), 0 : 0)); ++ c = b[k++] = baz (x); ++ } ++ while (c); ++ while (k <= a) ++ b[k++] = 0; ++} ++ ++int ++main () ++{ ++ struct T { S a; unsigned int b; } s = {}; ++ s.b = 0x1234; ++ s.a.bar (0); ++ for (int i = 0; i < 9; ++i) ++ if (s.a.b[i] != (i == 8 ? 0 : 7 - i)) ++ __builtin_abort (); ++ if (s.b != 0x1234) ++ __builtin_abort (); ++}