aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorAndrey Turetskiy <andrey.turetskiy@intel.com>2014-11-28 13:59:49 +0000
committerIlya Verbin <iverbin@gcc.gnu.org>2014-11-28 13:59:49 +0000
commit476ff787366cedb6f4123c0a5647522698570d5f (patch)
tree22ee2a0bf35a38fa8e4d06500af857978daffe56 /gcc/omp-low.c
parentf672337f6d90a131b716f1f42cb82b8fd0c43b78 (diff)
downloadgcc-476ff787366cedb6f4123c0a5647522698570d5f.zip
gcc-476ff787366cedb6f4123c0a5647522698570d5f.tar.gz
gcc-476ff787366cedb6f4123c0a5647522698570d5f.tar.bz2
omp-low.c (lower_omp_critical): Mark critical sections inside target functions as offloadable.
gcc/ * omp-low.c (lower_omp_critical): Mark critical sections inside target functions as offloadable. libgomp/ * testsuite/libgomp.c/target-critical-1.c: New test. Co-Authored-By: Ilya Verbin <ilya.verbin@intel.com> From-SVN: r218158
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 3924282..6c5774c 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -9366,16 +9366,6 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
DECL_ARTIFICIAL (decl) = 1;
DECL_IGNORED_P (decl) = 1;
- /* If '#pragma omp critical' is inside target region, the symbol must
- be marked for offloading. */
- omp_context *octx;
- for (octx = ctx->outer; octx; octx = octx->outer)
- if (is_targetreg_ctx (octx))
- {
- varpool_node::get_create (decl)->offloadable = 1;
- break;
- }
-
varpool_node::finalize_decl (decl);
critical_name_mutexes->put (name, decl);
@@ -9383,6 +9373,20 @@ lower_omp_critical (gimple_stmt_iterator *gsi_p, omp_context *ctx)
else
decl = *n;
+ /* If '#pragma omp critical' is inside target region or
+ inside function marked as offloadable, the symbol must be
+ marked as offloadable too. */
+ omp_context *octx;
+ if (cgraph_node::get (current_function_decl)->offloadable)
+ varpool_node::get_create (decl)->offloadable = 1;
+ else
+ for (octx = ctx->outer; octx; octx = octx->outer)
+ if (is_targetreg_ctx (octx))
+ {
+ varpool_node::get_create (decl)->offloadable = 1;
+ break;
+ }
+
lock = builtin_decl_explicit (BUILT_IN_GOMP_CRITICAL_NAME_START);
lock = build_call_expr_loc (loc, lock, 1, build_fold_addr_expr_loc (loc, decl));