| Message ID | 20260804003921.90054-1-kvivekananda@nvidia.com |
|---|---|
| State | Committed |
| Commit | 01cbfb28f7140f5a6089151b98bdf6a15532fda6 |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45C324BA2E13 for <patchwork@sourceware.org>; Tue, 4 Aug 2026 00:40:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45C324BA2E13 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=bvG1tUXm X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from PH8PR06CU001.outbound.protection.outlook.com (mail-westus3azon11012027.outbound.protection.outlook.com [40.107.209.27]) by sourceware.org (Postfix) with ESMTPS id 92B6F4BA23DE for <gcc-patches@gcc.gnu.org>; Tue, 4 Aug 2026 00:39:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 92B6F4BA23DE Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=nvidia.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 92B6F4BA23DE Authentication-Results: sourceware.org; arc=pass smtp.remote-ip=40.107.209.27 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1785803992; cv=pass; b=DnLZwIDWevk2HTH+oNWiYcnDnJJO2Gc4ZbKxWs1jIF/eot4ZKmaw5pJa6rrhG+vkJ5QlVeCsn3qHN0DyFwQM2t4HjtLa5KzkNzdYizwyAKbu0cTkOG+EK/a3XToFiP9iiqmdhYpa91Jo4Lje5ufgJfPDKcN9wU/y4IivA5NBcd0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1785803992; c=relaxed/simple; bh=ZrVJPhRIGpfbbtPtG4Fi9dtawh3yOcliUJDWmNJraRQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GEfwuwV3y38sh5Qc1Ze6d4c/n4aAUdbrvQ6VnH3TGVqngoSVqZXUDsnF2wSnHCSB5L+kCFQ+vRpEsRLov90gpSt5FdLF97a5qpByYAC2ravC/FrhLTJV8OKpx9NEfh6qvO7fg9tcLarQuk6ah8pp0cYOj7PwTtX1yqUfFM5489k= ARC-Authentication-Results: i=2; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=bvG1tUXm DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 92B6F4BA23DE ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uAT5Vt7LV0LqxIupXyuwd3U1YFCByXxnzQEwTyhKGenZ0WGCL3XareO+XuZxoaTMXPsbFiXVJPUYyP7jNS74nbWq96R5F3kdgJgLtx9bknNj+IPp9p1TJPblvjiPr7Ve3DuS64plg2ib+5BrpwARUY/YivItHywiNtwnjtn70hO9K8oYSgy4LIPQXXf4SELJyDUnjZzCIUD0BnWAcnw8lYv5HxWlDsqZmSXWkWpjaQmtEv7TpkTeSpfx3Zi8bgTlLmjzpnGNyxbcZhzfbpZEg/Bmzv47ncC+LDgZds0EC0o9HCSmzR1TKxRnMi3JhcAOMjeL6UqOPzzAVaEbWSAmRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q5epse1rCTAiNSLPeYTKdVt+393A0Ol/M8AJ3rKJrHk=; b=pJg08yCyZAw0PmpnKD7N49rGqE1ZQHkL+gtyFRMBLouGhXLjdS5lzUewcFjyl+Dg/Mx1J3jBsT17h9ySg0FKw3Cf7Ld0C9DP78c7osNsWF6+SM83zCId888OMyxbCvPgicRQ8hjmf7wUuQQYUr7akPQqxmJDZm9dWUZa6PA1yWiFHOndtCU2+VJr1q9tWC3hIGv+pZ5yrDoKhMIPQF6VF1D2bXTZYqa1H6JHD3Cf/gJ851x5CjIDxQfrLrW4TgGzAZZNmIhfXU0fhkzAMucggbt2+LX04sfWVfTOynBUEM//SPDg4NV4xSXppjDUPGxHw0vkUVyl7wgg0TlTMlBqCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q5epse1rCTAiNSLPeYTKdVt+393A0Ol/M8AJ3rKJrHk=; b=bvG1tUXmca/9Kqwk0WQCLAQ6N0xoCFVh2AfQv91VAdFI3h56SafjQr6KX4saad5Zk09OFsYe9c4pFouMwd3m1/x5vfDRQ4xqbEibs0eNaoRAZveHt7JstWgeZMrgEztKSOrj8BqwLP4rxcm4J5sX0fdtfCmbsMpBQZiY0h7qgu2VCuOcSsJs6b5I1lx0gYAgEkyrM9flqkOScPPqEOfSvLN1q9NFL/J0z/uI7vkWWGdtQEe6uWqGyiWGGy5mKGdh8B9T3avc4YJFCgBblXJFN7/Czh7IvVEgAQwiLLFjOQlVQKCPoQ0Do+njmrrgpVSEIOFGbUdUzo8Qzl4caty+Og== Received: from DS1P221CA0023.NAMP221.PROD.OUTLOOK.COM (2603:10b6:8:242::6) by PH0PR12MB8173.namprd12.prod.outlook.com (2603:10b6:510:296::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.270.18; Tue, 4 Aug 2026 00:39:48 +0000 Received: from DS3PEPF000099E0.namprd04.prod.outlook.com (2603:10b6:8:242:cafe::64) by DS1P221CA0023.outlook.office365.com (2603:10b6:8:242::6) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.292.15 via Frontend Transport; Tue, 4 Aug 2026 00:39:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by DS3PEPF000099E0.mail.protection.outlook.com (10.167.17.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.292.8 via Frontend Transport; Tue, 4 Aug 2026 00:39:47 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Mon, 3 Aug 2026 17:39:34 -0700 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Mon, 3 Aug 2026 17:39:32 -0700 From: Kugan Vivekanandarajah <kvivekananda@nvidia.com> To: <gcc-patches@gcc.gnu.org> CC: <honza.hubicka@gmail.com>, <kvivekananda@nvidia.com> Subject: [PATCH] [GCC] AutoFDO: Walk predecessor edges for PHI arguments Date: Tue, 4 Aug 2026 10:39:21 +1000 Message-ID: <20260804003921.90054-1-kvivekananda@nvidia.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E0:EE_|PH0PR12MB8173:EE_ X-MS-Office365-Filtering-Correlation-Id: dafc983f-bb74-4e55-a883-08def1c0e2f6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|82310400026|1800799024|36860700016|23010399003|11063799006|56012099006|10067099003|6133799003|18002099003; X-Microsoft-Antispam-Message-Info: av/7ZhYnRex5w+9rbEyflxS0SvurKYJhtjcfOUO4n+DHcj6YIXiGW0ZRmQ8F+LCI2pYoFId8im8eqFqTnpuA1EIPEbc+runptsW+PkOQAhEq2mcR9CEe0lyXYIBhie9ddLQl1arEXWlxEDvOonvzG3X51zXy6wapsGavazvI/9bopg/Bf4gRjk85Kq/BvV7uayRiW2DT2rIk7s/cxuV1ocVDzyK/5xG2pT29WzcnzJMHWD7xa5GY6rzgAR3Eg/v0PLErcqhjBEEwm2PpBwHaEdip2GdQa+3h/k6o00e8e7H0OkvA/7cXTezKEgFxCgw/woKNdOAhQKU40bWY36uRWP75rgSIKgaYGG+3YdStoME+9210oSeN8IJhX2sgIk3Kdvndx5HysQpK377mOE8arKT1Gb205US5c6qoHhSl4p6MwWOnmmWlOU6UhooMSS0ta30od7dQ+j8Hfep92B3GRJbUHwPk0nxRwLt+SoOiHciOMLYxmp+32B4efxDBWXM+kLwzvUARg504mb75aFQsnBUd4m84CmOKiPG334NeKDmubvtRp2m/Bo5QKb6thbpBFCL2OnqN7SdZagZxXZBroGb76Rx8K/BD5D3OCVWNTCVBCewsX9+mA3VVjI29GBBhwBogViortr/iePofG22goxBR3fndpJISrETThKlqUSxhx6CCZgvVw/pWuLIKl8J/fVIuyFi5vK5Rcbjha7H3iQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230040)(376014)(82310400026)(1800799024)(36860700016)(23010399003)(11063799006)(56012099006)(10067099003)(6133799003)(18002099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YOhbpXN8SclmX+gwDEHf5QgK+bkB6YjwcZoEbpgBluYvFraF4bfg68t1FzlW+b9neA0EdYtKI3hQaqI5dI3g+4chGtfsxW4HNN8as0+jkZDvu2CnClU1bJWZeiU+2PAd/T+ygIDILIs2lu+Af+6mI0zeye+O6xCAInSUSS0LhdmhRy3iyEkXFjVK4T3JaWCYlrICTxaiOglZFt2Wpxf528RnF6pIiyUbtQCNuaK4ILywGhrktzfO05CLVe5XYyqw3NQSDMwgRGR9qHWAT8yjEyi6w9LGi3XIgk4F+ZeAzLsAWpSHHsDuFDk+1+JJDKLJ0dlLBdxhFhmAYeXht2guduLv/PSLX+xCF4F5sg+7lZYYhg50mxLcfDQvDyM4rQZBnHVRnbSx+oXN/E8KJ6NN1QeYF8vRQW7z8L2LwYedG1qsJhsK2jMnv0o/8st2vBLO X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2026 00:39:47.6036 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: dafc983f-bb74-4e55-a883-08def1c0e2f6 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099E0.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB8173 X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, LOCAL_AUTHENTICATION_FAIL_SPF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
AutoFDO: Walk predecessor edges for PHI arguments
|
|
Checks
| Context | Check | Description |
|---|---|---|
| linaro-tcwg-bot/tcwg_gcc_build--master-arm | success | Build passed |
| linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap | success | Build passed |
| linaro-tcwg-bot/tcwg_gcc_check--master-arm | success | Test passed |
Commit Message
Kugan Vivekanandarajah
Aug. 4, 2026, 12:39 a.m. UTC
PHI arguments are indexed by incoming edges. function_instance::match
walked successor edges and could fail gimple_phi_arg_def_from_edge's
destination assertion during afdo_offline.
gcc/ChangeLog:
* auto-profile.cc (function_instance::match): Walk predecessor edges
for PHI arguments.
Regression tested on aarch64-linux-gnu with no new regressions
Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
---
gcc/auto-profile.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Tue, Aug 4, 2026 at 2:39 AM Kugan Vivekanandarajah < kvivekananda@nvidia.com> wrote: > PHI arguments are indexed by incoming edges. function_instance::match > walked successor edges and could fail gimple_phi_arg_def_from_edge's > destination assertion during afdo_offline. > > gcc/ChangeLog: > > * auto-profile.cc (function_instance::match): Walk predecessor > edges > for PHI arguments. > This is OK. It is really strange this does not trigger checking failure I see that inline location_t gimple_phi_arg_location_from_edge (gphi *phi, edge e) { return gimple_phi_arg (phi, e->dest_idx)->locus; Does not check that PHI BB and e->dest match (that looks like omission that would be useful to fix), but still we should eventually hit out of range access which is checked in gimple_phi_arg. Honza > > Regression tested on aarch64-linux-gnu with no new regressions > > Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com> > --- > gcc/auto-profile.cc | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc > index f4562d7f2f98..60f6b1ba480b 100644 > --- a/gcc/auto-profile.cc > +++ b/gcc/auto-profile.cc > @@ -1764,7 +1764,8 @@ function_instance::match (cgraph_node *node, > gcc_assert (!info); > dump_stmt (phi, info, NULL, stack); > counts.add (info); > - for (edge e : bb->succs) > + /* PHI arguments are indexed by incoming (predecessor) edges. */ > + for (edge e : bb->preds) > { > location_t phi_loc > = gimple_phi_arg_location_from_edge (phi, e); > -- > 2.34.1 > >
On Tue, Aug 4, 2026 at 8:44 AM Jan Hubička <honza.hubicka@gmail.com> wrote: > > > > On Tue, Aug 4, 2026 at 2:39 AM Kugan Vivekanandarajah <kvivekananda@nvidia.com> wrote: >> >> PHI arguments are indexed by incoming edges. function_instance::match >> walked successor edges and could fail gimple_phi_arg_def_from_edge's >> destination assertion during afdo_offline. >> >> gcc/ChangeLog: >> >> * auto-profile.cc (function_instance::match): Walk predecessor edges >> for PHI arguments. > > > This is OK. It is really strange this does not trigger checking failure > I see that > inline location_t > gimple_phi_arg_location_from_edge (gphi *phi, edge e) > { > return gimple_phi_arg (phi, e->dest_idx)->locus; > > Does not check that PHI BB and e->dest match (that looks like omission that would be useful to fix), but still we should eventually hit out of range access which is checked in gimple_phi_arg. I have put such checking in some of the accessors (because as you guess, it's "easy" to feed bogus edges into those). gimple_phi_arg_def_from_edge it seems. Similar checking assert would be nice to have in other edge based PHI accessors. Richard. > > Honza >> >> >> Regression tested on aarch64-linux-gnu with no new regressions >> >> Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com> >> --- >> gcc/auto-profile.cc | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc >> index f4562d7f2f98..60f6b1ba480b 100644 >> --- a/gcc/auto-profile.cc >> +++ b/gcc/auto-profile.cc >> @@ -1764,7 +1764,8 @@ function_instance::match (cgraph_node *node, >> gcc_assert (!info); >> dump_stmt (phi, info, NULL, stack); >> counts.add (info); >> - for (edge e : bb->succs) >> + /* PHI arguments are indexed by incoming (predecessor) edges. */ >> + for (edge e : bb->preds) >> { >> location_t phi_loc >> = gimple_phi_arg_location_from_edge (phi, e); >> -- >> 2.34.1 >>
diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index f4562d7f2f98..60f6b1ba480b 100644 --- a/gcc/auto-profile.cc +++ b/gcc/auto-profile.cc @@ -1764,7 +1764,8 @@ function_instance::match (cgraph_node *node, gcc_assert (!info); dump_stmt (phi, info, NULL, stack); counts.add (info); - for (edge e : bb->succs) + /* PHI arguments are indexed by incoming (predecessor) edges. */ + for (edge e : bb->preds) { location_t phi_loc = gimple_phi_arg_location_from_edge (phi, e);