From patchwork Thu Aug 3 20:44:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1816665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=erHUJCLO; dkim-atps=neutral Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RH16z6BfJz1yZl for ; Fri, 4 Aug 2023 06:44:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 286703858C27 for ; Thu, 3 Aug 2023 20:44:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 286703858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691095480; bh=wdEw5UQ5BLhZadMmdTt7i18PcSqTMyOBktxFc+36bWc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=erHUJCLOAK6RrMUkLUNtddXndFUp69ilKQqOJDtRJ4aEYqdOi7R8/f0Iu5NIf3TAL vCNlmMzMLE9JzEsl9PzatZj5Ei9sw6+hgGNPlH/VsAHpq8QYPyYf14gJr6wSdH4CYm rGJqtwaMhH9SfeE5QzvHWgIwao+U3XWzKuZIbxFI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 73C603858D38 for ; Thu, 3 Aug 2023 20:44:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73C603858D38 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 314352828D3; Thu, 3 Aug 2023 22:44:19 +0200 (CEST) Date: Thu, 3 Aug 2023 22:44:19 +0200 To: gcc-patches@gcc.gnu.org Subject: Fix profiledbootstrap Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Hi, Profiledbootstrap fails with ICE in update_loop_exit_probability_scale_dom_bbs called from loop unroling. The reason is that under relatively rare situations, we may run into case where loop has multiple exits and all are considered as likely but then we scale down the profile and one of the exits becomes unlikely. We pass around unadjusted_exit_count to scale exit probability correctly. In this case we may end up using uninitialized value and profile-count type intentionally bombs on that. Profiledbootstrapped x86_64-linux, comitted. gcc/ChangeLog: PR bootstrap/110857 * cfgloopmanip.cc (scale_loop_profile): (Un)initialize unadjusted_exit_count. diff --git a/gcc/cfgloopmanip.cc b/gcc/cfgloopmanip.cc index 86360b5f380..b237ad4e8ac 100644 --- a/gcc/cfgloopmanip.cc +++ b/gcc/cfgloopmanip.cc @@ -742,7 +742,7 @@ scale_loop_profile (class loop *loop, profile_probability p, /* In a consistent profile unadjusted_exit_count should be same as count_in, however to preserve as much of the original info, avoid recomputing it. */ - profile_count unadjusted_exit_count; + profile_count unadjusted_exit_count = profile_count::uninitialized (); if (exit_edge) unadjusted_exit_count = exit_edge->count (); scale_loop_frequencies (loop, scale_prob);