diff options
author | Jakub Jelinek <jakub@redhat.com> | 2017-08-10 02:33:20 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2017-08-10 02:33:20 +0200 |
commit | 50aa16c38821e9cba4fabf6ca4b601b34b84a9c8 (patch) | |
tree | 63f1d98ac39aa578be9ea5c5e5147588e4859ed5 /gcc | |
parent | 47ee1b7c10f2aa90645b0d2a94926fa2a674450c (diff) | |
download | gcc-50aa16c38821e9cba4fabf6ca4b601b34b84a9c8.zip gcc-50aa16c38821e9cba4fabf6ca4b601b34b84a9c8.tar.gz gcc-50aa16c38821e9cba4fabf6ca4b601b34b84a9c8.tar.bz2 |
re PR c/81687 (Compiler drops label in OpenMP region)
PR c/81687
* omp-low.c (omp_copy_decl): Don't remap FORCED_LABEL or DECL_NONLOCAL
LABEL_DECLs.
* tree-cfg.c (move_stmt_op): Don't adjust DECL_CONTEXT of FORCED_LABEL
or DECL_NONLOCAL labels.
(move_stmt_r) <case GIMPLE_LABEL>: Adjust DECL_CONTEXT of FORCED_LABEL
or DECL_NONLOCAL labels here.
* testsuite/libgomp.c/pr81687-1.c: New test.
* testsuite/libgomp.c/pr81687-2.c: New test.
From-SVN: r251019
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/omp-low.c | 2 | ||||
-rw-r--r-- | gcc/tree-cfg.c | 25 |
3 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 251b0f6..1b02925 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2017-08-09 Jakub Jelinek <jakub@redhat.com> + + PR c/81687 + * omp-low.c (omp_copy_decl): Don't remap FORCED_LABEL or DECL_NONLOCAL + LABEL_DECLs. + * tree-cfg.c (move_stmt_op): Don't adjust DECL_CONTEXT of FORCED_LABEL + or DECL_NONLOCAL labels. + (move_stmt_r) <case GIMPLE_LABEL>: Adjust DECL_CONTEXT of FORCED_LABEL + or DECL_NONLOCAL labels here. + 2017-08-09 Will Schmidt <will_schmidt@vnet.ibm.com> * config/rs6000/rs6000.c (rs6000_option_override_internal): Add blurb diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 3df6056..dffdb77 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -798,6 +798,8 @@ omp_copy_decl (tree var, copy_body_data *cb) if (TREE_CODE (var) == LABEL_DECL) { + if (FORCED_LABEL (var) || DECL_NONLOCAL (var)) + return var; new_var = create_artificial_label (DECL_SOURCE_LOCATION (var)); DECL_CONTEXT (new_var) = current_function_decl; insert_decl_map (&ctx->cb, var, new_var); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 733c92f..f26b12f 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6718,7 +6718,15 @@ move_stmt_op (tree *tp, int *walk_subtrees, void *data) *tp = t = out->to; } - DECL_CONTEXT (t) = p->to_context; + /* For FORCED_LABELs we can end up with references from other + functions if some SESE regions are outlined. It is UB to + jump in between them, but they could be used just for printing + addresses etc. In that case, DECL_CONTEXT on the label should + be the function containing the glabel stmt with that LABEL_DECL, + rather than whatever function a reference to the label was seen + last time. */ + if (!FORCED_LABEL (t) && !DECL_NONLOCAL (t)) + DECL_CONTEXT (t) = p->to_context; } else if (p->remap_decls_p) { @@ -6836,6 +6844,21 @@ move_stmt_r (gimple_stmt_iterator *gsi_p, bool *handled_ops_p, case GIMPLE_OMP_RETURN: case GIMPLE_OMP_CONTINUE: break; + + case GIMPLE_LABEL: + { + /* For FORCED_LABEL, move_stmt_op doesn't adjust DECL_CONTEXT, + so that such labels can be referenced from other regions. + Make sure to update it when seeing a GIMPLE_LABEL though, + that is the owner of the label. */ + walk_gimple_op (stmt, move_stmt_op, wi); + *handled_ops_p = true; + tree label = gimple_label_label (as_a <glabel *> (stmt)); + if (FORCED_LABEL (label) || DECL_NONLOCAL (label)) + DECL_CONTEXT (label) = p->to_context; + } + break; + default: if (is_gimple_omp (stmt)) { |