From patchwork Fri Oct 1 17:09:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 45705 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCDFE385701A for ; Fri, 1 Oct 2021 17:13:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 35EAD3857435 for ; Fri, 1 Oct 2021 17:09:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 35EAD3857435 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: l8whFU6vdXzL9Cp/NXWy80jylOJ3YxM5f/EkuNYBru3qaKkgHzd+iJZ/92JwSypCadGblXBJ3p wAY6Z87ETABOpTX9MWdWAREnWlbVOPjEf5z4bL4pZN+khOLkGO1gyPY2r59PX6M7I4WeUP15nd G9KhhflNEkUV5uC2tllIpgm7ZqLqAaz8ahC8AUfIoD+8JMnUm7DgKrXhNeR+uC2vQs9WUeELhM ykJeKdhx0chvnvFS60OKaNGEGN81Tx9Z2d100KI157dQ1pSD2NpIXrXUl6YhEVkGLqAcTMsXAE yPRojL0+bjPovzAtZ2ceBYbh X-IronPort-AV: E=Sophos;i="5.85,339,1624348800"; d="scan'208";a="66726637" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 01 Oct 2021 09:09:28 -0800 IronPort-SDR: yOC50vmAy2scmu/VuiTsYQOGVrNBm+0obwCOSFz45ruakqK/cjc09e8a/rsdynjkIKUKJSeJRm ibvoTSCIjj4bvxaxxm0vFe0qZ5BSWJNspeoA6HKynF/qUoE07UeBRwdWZ+Gpd6WYG1Dg2AFAoU hwCGMxruBNyrPCxYZC2mgly5+pzkZoureVfJNRiGu/2ZC2wugfvmzzm516UY030Txe03xY/Syh arLUf0/AoxEzskSFyTYOhMFi1LsrKknM2ytt+yh2P99waAoWOER5dbH31pLus266kbYMiGVfJ8 Wbs= From: Julian Brown To: Subject: [PATCH 09/11] Not for committing: noisy sibling-list handling output Date: Fri, 1 Oct 2021 10:09:07 -0700 Message-ID: <2584f870ad013b62b92563b0f8edf9fa4348ac86.1633106213.git.julian@codesourcery.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: Jakub Jelinek , Thomas Schwinge Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" As a possible aid to review, this is my "printf-style" debugging cruft for the sibling list handling hoist/rework. It's not meant for committing. --- gcc/gimplify.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 2ec83bf273b..ffb6eda5490 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -71,6 +71,7 @@ along with GCC; see the file COPYING3. If not see #include "tree-nested.h" //#define NOISY_TOPOSORT +//#define NOISY_SIBLING_LISTS /* Hash set of poisoned variables in a bind expr. */ static hash_set *asan_poisoned_variables = NULL; @@ -9895,6 +9896,11 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, bool openmp = !(region_type & ORT_ACC); tree *continue_at = NULL; +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "DECL starts out as:\n"); + debug_generic_expr (ocd); +#endif + while (TREE_CODE (ocd) == ARRAY_REF) ocd = TREE_OPERAND (ocd, 0); @@ -9903,6 +9909,11 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, tree base = extract_base_bit_offset (ocd, &cbitpos, &coffset); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "BASE after extraction is (%p):\n", (void *) base); + debug_generic_expr (base); +#endif + bool ptr = (OMP_CLAUSE_MAP_KIND (grp_end) == GOMP_MAP_ALWAYS_POINTER); bool attach_detach = ((OMP_CLAUSE_MAP_KIND (grp_end) == GOMP_MAP_ATTACH_DETACH) @@ -9917,6 +9928,25 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, if (openmp && attach_detach) return NULL; +#ifdef NOISY_SIBLING_LISTS + if (struct_map_to_clause) + { + fprintf (stderr, "s_m_t_c->get (base) = "); + debug_generic_expr (base); + tree *r = struct_map_to_clause->get (base); + fprintf (stderr, "returns: "); + if (r) + { + tree tmp = OMP_CLAUSE_CHAIN (*r); + OMP_CLAUSE_CHAIN (*r) = NULL_TREE; + debug_generic_expr (*r); + OMP_CLAUSE_CHAIN (*r) = tmp; + } + else + fprintf (stderr, "(nothing)\n"); + } +#endif + if (!struct_map_to_clause || struct_map_to_clause->get (base) == NULL) { tree l = build_omp_clause (OMP_CLAUSE_LOCATION (grp_end), OMP_CLAUSE_MAP); @@ -10026,6 +10056,11 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, { tree *osc = struct_map_to_clause->get (base); tree *sc = NULL, *scp = NULL; +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "looked up osc %p for decl (%p)\n", (void *) osc, + (void *) base); + debug_generic_expr (base); +#endif sc = &OMP_CLAUSE_CHAIN (*osc); /* The struct mapping might be immediately followed by a FIRSTPRIVATE_POINTER and/or FIRSTPRIVATE_REFERENCE -- if it's an @@ -10098,6 +10133,17 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, return NULL; } } +#ifdef NOISY_SIBLING_LISTS + if (known_eq (coffset, offset) && known_eq (cbitpos, bitpos)) + { + fprintf (stderr, "duplicate offset!\n"); + tree o1 = OMP_CLAUSE_DECL (*sc); + tree o2 = OMP_CLAUSE_DECL (grp_end); + debug_generic_expr (o1); + debug_generic_expr (o2); + } + else +#endif if (maybe_lt (coffset, offset) || (known_eq (coffset, offset) && maybe_lt (cbitpos, bitpos))) @@ -10174,6 +10220,13 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, = cl ? move_concat_nodes_after (cl, tail_chain, grp_start_p, grp_end, sc) : move_nodes_after (grp_start_p, grp_end, sc); +#ifdef NOISY_SIBLING_LISTS + if (continue_at) + { + fprintf (stderr, "continue at (1):\n"); + debug_generic_expr (*continue_at); + } +#endif } else if (*sc != grp_end) { @@ -10187,6 +10240,10 @@ build_struct_group (enum omp_region_type region_type, enum tree_code code, the correct position in the struct component list, which in this case is just SC. */ move_node_after (grp_end, grp_start_p, sc); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "continue at (2):\n"); + debug_generic_expr (*continue_at); +#endif } } return continue_at; @@ -10218,6 +10275,16 @@ omp_build_struct_sibling_lists (enum tree_code code, new_next = NULL; +#ifdef NOISY_SIBLING_LISTS + { + tree *tmp = grp->grp_start; + grp->grp_start = grp_start_p; + fprintf (stderr, "processing group %u:\n", i); + debug_mapping_group (grp); + grp->grp_start = tmp; + } +#endif + if (DECL_P (decl)) continue; @@ -10252,6 +10319,11 @@ omp_build_struct_sibling_lists (enum tree_code code, != GOMP_MAP_POINTER_TO_ZERO_LENGTH_ARRAY_SECTION)) decl = TREE_OPERAND (decl, 0); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "using base pointer/decl:\n"); + debug_generic_expr (decl); +#endif + STRIP_NOPS (decl); if (TREE_CODE (decl) != COMPONENT_REF) @@ -10260,6 +10332,15 @@ omp_build_struct_sibling_lists (enum tree_code code, omp_mapping_group **wholestruct = NULL; tree wsdecl = omp_containing_struct (OMP_CLAUSE_DECL (c)); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "whole-struct decl is (%s original)\n", + wsdecl == OMP_CLAUSE_DECL (c) ? "same as" : "different from"); + + debug_generic_expr (wsdecl); + fprintf (stderr, "orig was:\n"); + debug_generic_expr (OMP_CLAUSE_DECL (c)); +#endif + if (!(region_type & ORT_ACC) && wsdecl != OMP_CLAUSE_DECL (c)) { wholestruct = grpmap->get (wsdecl); @@ -10275,16 +10356,27 @@ omp_build_struct_sibling_lists (enum tree_code code, if (wholestruct) { +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "it looks like the whole struct is mapped by:\n"); + debug_mapping_group (*wholestruct); +#endif if (*grp_start_p == grp_end) { /* Remove the whole of this mapping -- redundant. */ +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "removing this group\n"); +#endif new_next = grp_start_p; *grp_start_p = OMP_CLAUSE_CHAIN (grp_end); } continue; } +#ifdef NOISY_SIBLING_LISTS + else + fprintf (stderr, "whole struct is not mapped\n"); +#endif if (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_TO_PSET && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH @@ -10360,6 +10452,11 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, int handled_depend_iterators = -1; int nowait = -1; +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "GIMPLIFY_SCAN_OMP_CLAUSES, list:\n"); + debug_generic_expr (*list_p); +#endif + ctx = new_omp_context (region_type); ctx->code = code; outer_ctx = ctx->outer_context; @@ -10399,7 +10496,14 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, hash_map *grpmap; grpmap = omp_index_mapping_groups (groups); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "BUILDING STRUCT SIBLING LISTS\n"); +#endif omp_build_struct_sibling_lists (code, region_type, groups, grpmap); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "result:\n"); + debug_generic_expr (*list_p); +#endif omp_mapping_group *outlist = NULL; @@ -10455,6 +10559,9 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, hash_map *grpmap; grpmap = omp_index_mapping_groups (groups); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "BUILDING STRUCT SIBLING LISTS\n"); +#endif omp_build_struct_sibling_lists (code, region_type, groups, grpmap); delete groups; @@ -10775,6 +10882,22 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, case OMP_CLAUSE_MAP: decl = OMP_CLAUSE_DECL (c); + +#ifdef NOISY_SIBLING_LISTS + { + fprintf (stderr, "gimplify_scan_omp_clauses processing: "); + debug_generic_expr (c); + if (DECL_P (decl)) + { + splay_tree_node n + = splay_tree_lookup (ctx->variables, (splay_tree_key) decl); + fprintf (stderr, "decl has node: %p\n", (void *) n); + if (n) + fprintf (stderr, "flags are: %x\n", n->value); + } + } +#endif + if (error_operand_p (decl)) remove = true; switch (code) @@ -10870,6 +10993,10 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_STRUCT) { tree base = strip_components_and_deref (decl); +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "struct, base="); + debug_generic_expr (base); +#endif if (DECL_P (base)) { decl = base; @@ -10951,6 +11078,10 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, if (TREE_CODE (cref) == COMPONENT_REF) { +#ifdef NOISY_SIBLING_LISTS + fprintf (stderr, "we see a component_ref for:\n"); + debug_generic_expr (c); +#endif tree base = cref; while (base && !DECL_P (base)) {