This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][OpenMP] Forbid usage of non-target functions in target regions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]