aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-11-19 14:44:13 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-11-19 14:44:13 +0100
commit4ccc4e30141613c4585a0497e050cb5deda06007 (patch)
tree7727a592dda3ece4affda62848329336a44d8219 /gcc
parente48e04f598c89a71a5aff3f02cb38b7bf06b5b2b (diff)
downloadgcc-4ccc4e30141613c4585a0497e050cb5deda06007.zip
gcc-4ccc4e30141613c4585a0497e050cb5deda06007.tar.gz
gcc-4ccc4e30141613c4585a0497e050cb5deda06007.tar.bz2
re PR debug/87039 (DW_OP_fbreg used without a frame base on a C++ code w/ -fopenmp)
PR debug/87039 * omp-expand.c: Don't include debug.h. (adjust_context_and_scope): Add REGION argument. Find DECL_CONTEXT from innermost outer parallel, task, teams or target that has a child_fn set, or, if there is no such outer region, use current_function_decl. Do the DECL_CONTEXT adjustment regardless of whether a suitable BLOCK is found or not. (expand_parallel_call, expand_teams_call): Don't call adjust_context_and_scope here. (grid_expand_target_grid_body): Revert 2017-01-25 changes. (expand_omp_taskreg, expand_omp_target): Likewise. Call adjust_context_and_scope. * dwarf2out.c (dwarf2out_early_global_decl): For decl_function_context recurse instead of calling dwarf2out_decl. * g++.dg/gomp/pr78363-4.C: New test. * g++.dg/gomp/pr78363-5.C: New test. * g++.dg/gomp/pr78363-6.C: New test. * g++.dg/gomp/pr78363-7.C: New test. From-SVN: r266272
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog17
-rw-r--r--gcc/dwarf2out.c2
-rw-r--r--gcc/omp-expand.c71
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr78363-4.C18
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr78363-5.C17
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr78363-6.C16
-rw-r--r--gcc/testsuite/g++.dg/gomp/pr78363-7.C15
8 files changed, 128 insertions, 36 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9cd89fb..dab8874 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,20 @@
+2018-11-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/87039
+ * omp-expand.c: Don't include debug.h.
+ (adjust_context_and_scope): Add REGION argument. Find DECL_CONTEXT
+ from innermost outer parallel, task, teams or target that has a
+ child_fn set, or, if there is no such outer region, use
+ current_function_decl. Do the DECL_CONTEXT adjustment regardless of
+ whether a suitable BLOCK is found or not.
+ (expand_parallel_call, expand_teams_call): Don't call
+ adjust_context_and_scope here.
+ (grid_expand_target_grid_body): Revert 2017-01-25 changes.
+ (expand_omp_taskreg, expand_omp_target): Likewise. Call
+ adjust_context_and_scope.
+ * dwarf2out.c (dwarf2out_early_global_decl): For
+ decl_function_context recurse instead of calling dwarf2out_decl.
+
2018-11-19 Richard Biener <rguenther@suse.de>
PR lto/87229
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index d2bea27..9933650 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -26403,7 +26403,7 @@ dwarf2out_early_global_decl (tree decl)
enough so that it lands in its own context. This avoids type
pruning issues later on. */
if (context_die == NULL || is_declaration_die (context_die))
- dwarf2out_decl (context);
+ dwarf2out_early_global_decl (context);
}
/* Emit an abstract origin of a function first. This happens
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 2361520..76c09c5 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -56,7 +56,6 @@ along with GCC; see the file COPYING3. If not see
#include "gomp-constants.h"
#include "gimple-pretty-print.h"
#include "hsa-common.h"
-#include "debug.h"
#include "stringpool.h"
#include "attribs.h"
@@ -517,27 +516,44 @@ parallel_needs_hsa_kernel_p (struct omp_region *region)
function will be emitted with the correct lexical scope. */
static void
-adjust_context_and_scope (tree entry_block, tree child_fndecl)
+adjust_context_and_scope (struct omp_region *region, tree entry_block,
+ tree child_fndecl)
{
+ tree parent_fndecl = NULL_TREE;
+ gimple *entry_stmt;
+ /* OMP expansion expands inner regions before outer ones, so if
+ we e.g. have explicit task region nested in parallel region, when
+ expanding the task region current_function_decl will be the original
+ source function, but we actually want to use as context the child
+ function of the parallel. */
+ for (region = region->outer;
+ region && parent_fndecl == NULL_TREE; region = region->outer)
+ switch (region->type)
+ {
+ case GIMPLE_OMP_PARALLEL:
+ case GIMPLE_OMP_TASK:
+ case GIMPLE_OMP_TEAMS:
+ entry_stmt = last_stmt (region->entry);
+ parent_fndecl = gimple_omp_taskreg_child_fn (entry_stmt);
+ break;
+ case GIMPLE_OMP_TARGET:
+ entry_stmt = last_stmt (region->entry);
+ parent_fndecl
+ = gimple_omp_target_child_fn (as_a <gomp_target *> (entry_stmt));
+ break;
+ default:
+ break;
+ }
+
+ if (parent_fndecl == NULL_TREE)
+ parent_fndecl = current_function_decl;
+ DECL_CONTEXT (child_fndecl) = parent_fndecl;
+
if (entry_block != NULL_TREE && TREE_CODE (entry_block) == BLOCK)
{
tree b = BLOCK_SUPERCONTEXT (entry_block);
-
if (TREE_CODE (b) == BLOCK)
{
- tree parent_fndecl;
-
- /* Follow supercontext chain until the parent fndecl
- is found. */
- for (parent_fndecl = BLOCK_SUPERCONTEXT (b);
- TREE_CODE (parent_fndecl) == BLOCK;
- parent_fndecl = BLOCK_SUPERCONTEXT (parent_fndecl))
- ;
-
- gcc_assert (TREE_CODE (parent_fndecl) == FUNCTION_DECL);
-
- DECL_CONTEXT (child_fndecl) = parent_fndecl;
-
DECL_CHAIN (child_fndecl) = BLOCK_VARS (b);
BLOCK_VARS (b) = child_fndecl;
}
@@ -723,8 +739,6 @@ expand_parallel_call (struct omp_region *region, basic_block bb,
tree child_fndecl = gimple_omp_parallel_child_fn (entry_stmt);
t2 = build_fold_addr_expr (child_fndecl);
- adjust_context_and_scope (gimple_block (entry_stmt), child_fndecl);
-
vec_alloc (args, 4 + vec_safe_length (ws_args));
args->quick_push (t2);
args->quick_push (t1);
@@ -952,8 +966,6 @@ expand_teams_call (basic_block bb, gomp_teams *entry_stmt)
tree child_fndecl = gimple_omp_teams_child_fn (entry_stmt);
tree t2 = build_fold_addr_expr (child_fndecl);
- adjust_context_and_scope (gimple_block (entry_stmt), child_fndecl);
-
vec<tree, va_gc> *args;
vec_alloc (args, 5);
args->quick_push (t2);
@@ -1412,11 +1424,6 @@ expand_omp_taskreg (struct omp_region *region)
else
block = gimple_block (entry_stmt);
- /* Make sure to generate early debug for the function before
- outlining anything. */
- if (! gimple_in_ssa_p (cfun))
- (*debug_hooks->early_global_decl) (cfun->decl);
-
new_bb = move_sese_region_to_fn (child_cfun, entry_bb, exit_bb, block);
if (exit_bb)
single_succ_edge (new_bb)->flags = EDGE_FALLTHRU;
@@ -1497,6 +1504,8 @@ expand_omp_taskreg (struct omp_region *region)
}
}
+ adjust_context_and_scope (region, gimple_block (entry_stmt), child_fn);
+
if (gimple_code (entry_stmt) == GIMPLE_OMP_PARALLEL)
expand_parallel_call (region, new_bb,
as_a <gomp_parallel *> (entry_stmt), ws_args);
@@ -7399,11 +7408,6 @@ expand_omp_target (struct omp_region *region)
gsi_remove (&gsi, true);
}
- /* Make sure to generate early debug for the function before
- outlining anything. */
- if (! gimple_in_ssa_p (cfun))
- (*debug_hooks->early_global_decl) (cfun->decl);
-
/* Move the offloading region into CHILD_CFUN. */
block = gimple_block (entry_stmt);
@@ -7480,6 +7484,8 @@ expand_omp_target (struct omp_region *region)
dump_function_header (dump_file, child_fn, dump_flags);
dump_function_to_file (child_fn, dump_file, dump_flags);
}
+
+ adjust_context_and_scope (region, gimple_block (entry_stmt), child_fn);
}
/* Emit a library call to launch the offloading region, or do data
@@ -7977,11 +7983,6 @@ grid_expand_target_grid_body (struct omp_region *target)
init_tree_ssa (cfun);
pop_cfun ();
- /* Make sure to generate early debug for the function before
- outlining anything. */
- if (! gimple_in_ssa_p (cfun))
- (*debug_hooks->early_global_decl) (cfun->decl);
-
tree old_parm_decl = DECL_ARGUMENTS (kern_fndecl);
gcc_assert (!DECL_CHAIN (old_parm_decl));
tree new_parm_decl = copy_node (DECL_ARGUMENTS (kern_fndecl));
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5fce6a8..30fbd32 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2018-11-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR debug/87039
+ * g++.dg/gomp/pr78363-4.C: New test.
+ * g++.dg/gomp/pr78363-5.C: New test.
+ * g++.dg/gomp/pr78363-6.C: New test.
+ * g++.dg/gomp/pr78363-7.C: New test.
+
2018-11-19 Richard Biener <rguenther@suse.de>
PR lto/87229
diff --git a/gcc/testsuite/g++.dg/gomp/pr78363-4.C b/gcc/testsuite/g++.dg/gomp/pr78363-4.C
new file mode 100644
index 0000000..54d0078
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr78363-4.C
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-g" }
+
+int main()
+{
+ int n = 0;
+
+#pragma omp parallel
+#pragma omp master
+#pragma omp parallel
+#pragma omp master
+#pragma omp parallel for reduction (+: n)
+ for (int i = [](){ return 3; }(); i < 10; ++i)
+ n++;
+
+ return n;
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr78363-5.C b/gcc/testsuite/g++.dg/gomp/pr78363-5.C
new file mode 100644
index 0000000..760cc4d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr78363-5.C
@@ -0,0 +1,17 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-g" }
+
+int main()
+{
+ int n = 0;
+#pragma omp task shared(n)
+#pragma omp target map(tofrom:n)
+#pragma omp for reduction (+: n)
+ for (int i = [](){ return 3; }(); i < 10; ++i)
+ n++;
+ if (n != 7)
+ __builtin_abort ();
+#pragma omp taskwait
+ return 0;
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr78363-6.C b/gcc/testsuite/g++.dg/gomp/pr78363-6.C
new file mode 100644
index 0000000..e49ef06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr78363-6.C
@@ -0,0 +1,16 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-g" }
+
+int main()
+{
+ int n = 0;
+#pragma omp parallel
+#pragma omp master
+#pragma omp task shared (n)
+ for (int i = [](){ return 3; }(); i < 10; ++i)
+ n = i;
+#pragma omp taskwait
+ if (n != 7)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/gomp/pr78363-7.C b/gcc/testsuite/g++.dg/gomp/pr78363-7.C
new file mode 100644
index 0000000..4a0caee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr78363-7.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-g" }
+
+int main()
+{
+ int n = 0;
+
+#pragma omp target map(tofrom: n)
+#pragma omp parallel for reduction (+: n)
+ for (int i = [](){ return 3; }(); i < 10; ++i)
+ n++;
+
+ return n;
+}