analyzer: fix feasibility false +ve on jumps through function ptrs [PR107582]
[platform/upstream/gcc.git] / gcc / omp-oacc-neuter-broadcast.cc
index 14695a9..b617779 100644 (file)
@@ -58,7 +58,7 @@
 
 /* Loop structure of the function.  The entire function is described as
    a NULL loop.  */
-/* Adapted from 'gcc/config/nvptx/nvptx.c:struct parallel'.  */
+/* Adapted from 'gcc/config/nvptx/nvptx.cc:struct parallel'.  */
 
 struct parallel_g
 {
@@ -186,7 +186,7 @@ omp_sese_active_worker_call (gcall *call)
    partitioning mode of the function as a whole.  Populate MAP with
    head and tail blocks.  We also clear the BB visited flag, which is
    used when finding partitions.  */
-/* Adapted from 'gcc/config/nvptx/nvptx.c:nvptx_split_blocks'.  */
+/* Adapted from 'gcc/config/nvptx/nvptx.cc:nvptx_split_blocks'.  */
 
 static void
 omp_sese_split_blocks (bb_stmt_map_t *map)
@@ -345,7 +345,7 @@ mask_name (unsigned mask)
 }
 
 /* Dump this parallel and all its inner parallels.  */
-/* Adapted from 'gcc/config/nvptx/nvptx.c:nvptx_dump_pars'.  */
+/* Adapted from 'gcc/config/nvptx/nvptx.cc:nvptx_dump_pars'.  */
 
 static void
 omp_sese_dump_pars (parallel_g *par, unsigned depth)
@@ -371,7 +371,7 @@ omp_sese_dump_pars (parallel_g *par, unsigned depth)
 /* If BLOCK contains a fork/join marker, process it to create or
    terminate a loop structure.  Add this block to the current loop,
    and then walk successor blocks.   */
-/* Adapted from 'gcc/config/nvptx/nvptx.c:nvptx_find_par'.  */
+/* Adapted from 'gcc/config/nvptx/nvptx.cc:nvptx_find_par'.  */
 
 static parallel_g *
 omp_sese_find_par (bb_stmt_map_t *map, parallel_g *par, basic_block block)
@@ -477,7 +477,7 @@ walk_successors:
    to head & tail markers, discovered when splitting blocks.  This
    speeds up the discovery.  We rely on the BB visited flag having
    been cleared when splitting blocks.  */
-/* Adapted from 'gcc/config/nvptx/nvptx.c:nvptx_discover_pars'.  */
+/* Adapted from 'gcc/config/nvptx/nvptx.cc:nvptx_discover_pars'.  */
 
 static parallel_g *
 omp_sese_discover_pars (bb_stmt_map_t *map)
@@ -538,7 +538,7 @@ typedef hash_map<tree, tree> field_map_t;
    to propagate, to the field in the record type that should be used for
    transmission and reception.  */
 
-typedef hash_map<tree, field_map_t *> record_field_map_t;
+typedef hash_map<tree, field_map_t> record_field_map_t;
 
 static void
 install_var_field (tree var, tree record_type, field_map_t *fields)
@@ -937,35 +937,13 @@ worker_single_simple (basic_block from, basic_block to,
     }
 }
 
-/* Build COMPONENT_REF and set TREE_THIS_VOLATILE and TREE_READONLY on it
-   as appropriate.  */
-/* Adapted from 'gcc/omp-low.c:omp_build_component_ref'.  */
-
-static tree
-oacc_build_component_ref (tree obj, tree field)
-{
-  tree field_type = TREE_TYPE (field);
-  tree obj_type = TREE_TYPE (obj);
-  if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (obj_type)))
-    field_type = build_qualified_type
-                       (field_type,
-                        KEEP_QUAL_ADDR_SPACE (TYPE_QUALS (obj_type)));
-
-  tree ret = build3 (COMPONENT_REF, field_type, obj, field, NULL);
-  if (TREE_THIS_VOLATILE (field))
-    TREE_THIS_VOLATILE (ret) |= 1;
-  if (TREE_READONLY (field))
-    TREE_READONLY (ret) |= 1;
-  return ret;
-}
-
 static tree
 build_receiver_ref (tree var, tree receiver_decl, field_map_t *fields)
 {
   tree x = build_simple_mem_ref (receiver_decl);
   tree field = *fields->get (var);
   TREE_THIS_NOTRAP (x) = 1;
-  x = oacc_build_component_ref (x, field);
+  x = omp_build_component_ref (x, field);
   return x;
 }
 
@@ -975,7 +953,7 @@ build_sender_ref (tree var, tree sender_decl, field_map_t *fields)
   if (POINTER_TYPE_P (TREE_TYPE (sender_decl)))
     sender_decl = build_simple_mem_ref (sender_decl);
   tree field = *fields->get (var);
-  return oacc_build_component_ref (sender_decl, field);
+  return omp_build_component_ref (sender_decl, field);
 }
 
 static int
@@ -1168,8 +1146,7 @@ worker_single_copy (basic_block from, basic_block to,
        gcc_assert (TREE_CODE (var) == VAR_DECL);
 
       /* If we had no record type, we will have no fields map.  */
-      field_map_t **fields_p = record_field_map->get (record_type);
-      field_map_t *fields = fields_p ? *fields_p : NULL;
+      field_map_t *fields = record_field_map->get (record_type);
 
       if (worker_partitioned_uses->contains (var)
          && fields
@@ -1684,10 +1661,9 @@ oacc_do_neutering (unsigned HOST_WIDE_INT bounds_lo,
 
          field_vec.qsort (sort_by_size_then_ssa_version_or_uid);
 
-         field_map_t *fields = new field_map_t;
-
          bool existed;
-         existed = record_field_map.put (record_type, fields);
+         field_map_t *fields
+           = &record_field_map.get_or_insert (record_type, &existed);
          gcc_checking_assert (!existed);
 
          /* Insert var fields in reverse order, so the last inserted element
@@ -1818,8 +1794,6 @@ oacc_do_neutering (unsigned HOST_WIDE_INT bounds_lo,
                        &partitioned_var_uses, &record_field_map,
                        &blk_offset_map, writes_gang_private);
 
-  for (auto it : record_field_map)
-    delete it.second;
   record_field_map.empty ();
 
   /* These are supposed to have been 'delete'd by 'neuter_worker_single'.  */
@@ -1971,7 +1945,7 @@ public:
   {}
 
   /* opt_pass methods: */
-  virtual bool gate (function *fun)
+  bool gate (function *fun) final override
   {
     if (!flag_openacc)
       return false;
@@ -1987,7 +1961,7 @@ public:
     return true;
   }
 
-  virtual unsigned int execute (function *)
+  unsigned int execute (function *) final override
     {
       return execute_omp_oacc_neuter_broadcast ();
     }