@@ -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<tree> *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<tree_operand_hash, omp_mapping_group *> *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<tree_operand_hash, omp_mapping_group *> *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))
{