This makes sure to release moved & remapped SSA names during OMP
outlining which happens before going into SSA but with SSA names
created by gimplification around.

Boostrap & regtest running on x86_64-unknown-linux-gnu.

2022-01-03  Richard Biener  <rguent...@suse.de>

        PR middle-end/103851
        * tree-cfg.c (move_sese_region_to_fn): Always release SSA names.

        * g++.dg/gomp/pr103851.C: New testcase.
---
 gcc/testsuite/g++.dg/gomp/pr103851.C | 15 +++++++++++++++
 gcc/tree-cfg.c                       | 20 ++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/gomp/pr103851.C

diff --git a/gcc/testsuite/g++.dg/gomp/pr103851.C 
b/gcc/testsuite/g++.dg/gomp/pr103851.C
new file mode 100644
index 00000000000..257e4059d59
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr103851.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-options "-fopenmp -ftrivial-auto-var-init=pattern" }
+
+struct _Deque_base {
+    long _M_map_size;
+    int *_M_start;
+    int *_M_finish;
+};
+void morphologicalFilter1D()
+{
+#pragma omp parallel
+  {
+    struct _Deque_base vals[4];
+  }
+}
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index c436e590025..bb3779367fe 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7947,18 +7947,14 @@ move_sese_region_to_fn (struct function *dest_cfun, 
basic_block entry_bb,
   if (eh_map)
     delete eh_map;
 
-  if (gimple_in_ssa_p (cfun))
-    {
-      /* We need to release ssa-names in a defined order, so first find them,
-        and then iterate in ascending version order.  */
-      bitmap release_names = BITMAP_ALLOC (NULL);
-      vars_map.traverse<void *, gather_ssa_name_hash_map_from> (release_names);
-      bitmap_iterator bi;
-      unsigned i;
-      EXECUTE_IF_SET_IN_BITMAP (release_names, 0, i, bi)
-       release_ssa_name (ssa_name (i));
-      BITMAP_FREE (release_names);
-    }
+  /* We need to release ssa-names in a defined order, so first find them,
+     and then iterate in ascending version order.  */
+  bitmap release_names = BITMAP_ALLOC (NULL);
+  vars_map.traverse<void *, gather_ssa_name_hash_map_from> (release_names);
+  bitmap_iterator bi;
+  EXECUTE_IF_SET_IN_BITMAP (release_names, 0, i, bi)
+    release_ssa_name (ssa_name (i));
+  BITMAP_FREE (release_names);
 
   /* Rewire the entry and exit blocks.  The successor to the entry
      block turns into the successor of DEST_FN's ENTRY_BLOCK_PTR in
-- 
2.31.1

Reply via email to