This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][OpenMP] Forbid usage of non-target functions in target regions
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Ilya Verbin <iverbin at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org, Kirill Yukhin <kirill dot yukhin at gmail dot com>, Thomas Schwinge <thomas at codesourcery dot com>, Richard Biener <richard dot guenther at gmail dot com>
- Date: Fri, 9 Jan 2015 16:02:12 +0100
- Subject: Re: [PATCH][OpenMP] Forbid usage of non-target functions in target regions
- Authentication-results: sourceware.org; auth=none
- References: <20150109145702 dot GA45210 at msticlxl57 dot ims dot intel dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Jan 09, 2015 at 05:57:02PM +0300, Ilya Verbin wrote:
> Hi!
>
> If one (by mistake) calls a non-target function from the target region, the
> offload compiler crashes in input_overwrite_node. This is because
> compute_ltrans_boundary during streaming-out includes to SET the
> non-offloadable nodes, called from offloadable nodes.
> Probably it's possible to ignore such incorrect nodes (and edges) in
> streaming-out, but such a situation can not appear in a correct OpenMP 4.0
> program, therefore I've added a check to scan_omp_1_stmt.
Unlike variables, the spec last time I've checked isn't all that clear about
that.
> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -2818,6 +2818,19 @@ scan_omp_1_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p,
> default:
> break;
> }
> + else if (!DECL_EXTERNAL (fndecl)
> + && !cgraph_node::get_create (fndecl)->offloadable)
What about if fndecl is defined in the current TU, but as global symbol and can be
interposed (e.g. is in a shared library and not hidden in there), the local function
definition is without target attribute but the definition used at runtime is not?
> + {
> + omp_context *octx;
> + if (cgraph_node::get (current_function_decl)->offloadable)
> + remove = true;
> + for (octx = ctx; octx && !remove; octx = octx->outer)
> + if (is_targetreg_ctx (octx))
> + remove = true;
> + if (remove)
> + error_at (gimple_location (stmt), "function called from "
> + "target region, but not marked as 'declare target'");
%<declare target%> ?
Jakub