re PR target/71910 (ICE on valid OpenMP code)
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Aug 2016 16:50:47 +0000 (18:50 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 16 Aug 2016 16:50:47 +0000 (18:50 +0200)
PR target/71910
* tree-cfg.c (execute_fixup_cfg): Add node variable, use it.  Before inlining,
add cgraph edge for the added __builtin_unreachable call.

* g++.dg/gomp/pr71910.C: New test.

From-SVN: r239508

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr71910.C [new file with mode: 0644]
gcc/tree-cfg.c

index e2bec5f87ae87ce0076fc8a1b55b59b19b764362..b99c745c795eedd0c1a57bfe0ef97cbb81b54936 100644 (file)
@@ -1,5 +1,9 @@
 2016-08-16  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/71910
+       * tree-cfg.c (execute_fixup_cfg): Add node variable, use it.  Before inlining,
+       add cgraph edge for the added __builtin_unreachable call.
+
        PR middle-end/67485
        * expmed.c (expand_mult_const): Change val_so_far's type to UHWI,
        only cast it to SHWI for the final comparison.
index f9668c9229f75c464bc2f8280bd14416f7b1cbf2..3bc6028fa411d8b0ee08aa50bbedb31ca6e9214f 100644 (file)
@@ -1,5 +1,8 @@
 2016-08-16  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/71910
+       * g++.dg/gomp/pr71910.C: New test.
+
        PR middle-end/67485
        * gcc.c-torture/compile/pr67485.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/gomp/pr71910.C b/gcc/testsuite/g++.dg/gomp/pr71910.C
new file mode 100644 (file)
index 0000000..0063be8
--- /dev/null
@@ -0,0 +1,13 @@
+// PR target/71910
+// { dg-do compile }
+// { dg-additional-options "-O2" }
+
+#include <vector>
+
+int
+main ()
+{
+  std::vector<double> vec(10);
+#pragma omp parallel
+  __builtin_exit (0);
+}
index 4036223e7e609ba2cb056e692ea36b0b590680ce..4e55a83d38accc6c64e65e828b4da7839d96b4e3 100644 (file)
@@ -8987,16 +8987,14 @@ execute_fixup_cfg (void)
   gcov_type count_scale;
   edge e;
   edge_iterator ei;
+  cgraph_node *node = cgraph_node::get (current_function_decl);
 
   count_scale
-      = GCOV_COMPUTE_SCALE (cgraph_node::get (current_function_decl)->count,
-                           ENTRY_BLOCK_PTR_FOR_FN (cfun)->count);
+    = GCOV_COMPUTE_SCALE (node->count, ENTRY_BLOCK_PTR_FOR_FN (cfun)->count);
 
-  ENTRY_BLOCK_PTR_FOR_FN (cfun)->count =
-                           cgraph_node::get (current_function_decl)->count;
-  EXIT_BLOCK_PTR_FOR_FN (cfun)->count =
-                           apply_scale (EXIT_BLOCK_PTR_FOR_FN (cfun)->count,
-                                       count_scale);
+  ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
+  EXIT_BLOCK_PTR_FOR_FN (cfun)->count
+    = apply_scale (EXIT_BLOCK_PTR_FOR_FN (cfun)->count, count_scale);
 
   FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR_FOR_FN (cfun)->succs)
     e->count = apply_scale (e->count, count_scale);
@@ -9089,10 +9087,19 @@ execute_fixup_cfg (void)
            {
              if (stmt && is_gimple_call (stmt))
                gimple_call_set_ctrl_altering (stmt, false);
-             stmt = gimple_build_call
-                 (builtin_decl_implicit (BUILT_IN_UNREACHABLE), 0);
+             tree fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
+             stmt = gimple_build_call (fndecl, 0);
              gimple_stmt_iterator gsi = gsi_last_bb (bb);
              gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
+             if (!cfun->after_inlining)
+               {
+                 gcall *call_stmt = dyn_cast <gcall *> (stmt);
+                 int freq
+                   = compute_call_stmt_bb_frequency (current_function_decl,
+                                                     bb);
+                 node->create_edge (cgraph_node::get_create (fndecl),
+                                    call_stmt, bb->count, freq);
+               }
            }
        }
     }