diff mbox

[gomp4] Mark __OPENMP_TARGET__ as addressable (was: Offloading patches (2/3): Add tables generation)

Message ID 87vbtgy59s.fsf@schwinge.name
State New
Headers show

Commit Message

Thomas Schwinge May 8, 2014, 9:43 a.m. UTC
Hi!

On Tue, 17 Dec 2013 15:39:57 +0400, "Michael V. Zolotukhin" <michael.v.zolotukhin@gmail.com> wrote:
> in this patch we
> start to pass '__OPENMP_TARGET__' symbol to GOMP_target calls.

> --- a/gcc/omp-low.c
> +++ b/gcc/omp-low.c
> @@ -8371,19 +8372,22 @@ expand_omp_target (struct omp_region *region)
>      }
>  
>    gimple g;
> -  /* FIXME: This will be address of
> -     extern char __OPENMP_TARGET__[] __attribute__((visibility ("hidden")))
> -     symbol, as soon as the linker plugin is able to create it for us.  */
> -  tree openmp_target = build_zero_cst (ptr_type_node);
> +  tree openmp_target
> +    = build_decl (UNKNOWN_LOCATION, VAR_DECL,
> +		  get_identifier ("__OPENMP_TARGET__"), ptr_type_node);
> +  TREE_PUBLIC (openmp_target) = 1;
> +  DECL_EXTERNAL (openmp_target) = 1;
>    if (kind == GF_OMP_TARGET_KIND_REGION)
>      {
>        tree fnaddr = build_fold_addr_expr (child_fn);
> -      g = gimple_build_call (builtin_decl_explicit (start_ix), 7,
> -			     device, fnaddr, openmp_target, t1, t2, t3, t4);
> +      g = gimple_build_call (builtin_decl_explicit (start_ix), 7, device,
> +			     fnaddr, build_fold_addr_expr (openmp_target),
> +			     t1, t2, t3, t4);

In the trunk into gomp-4_0-branch merge that I'm currently preparing, all
offloading usage results in an ICE like:

    spawn [...]/build/gcc/xgcc -B[...]/build/gcc/ [...]/source/libgomp/testsuite/libgomp.c/target-1.c -B[...]/build/x86_64-unknown-linux-gnu/./libgomp/ -B[...]/build/x86_64-unknown-linux-gnu/./libgomp/.libs -I[...]/build/x86_64-unknown-linux-gnu/./libgomp -I[...]/source/libgomp/testsuite/.. -fmessage-length=0 -fno-diagnostics-show-caret -fdiagnostics-color=never -fopenmp -O2 -L[...]/build/x86_64-unknown-linux-gnu/./libgomp/.libs -lm -o ./target-1.exe
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c: In function 'fn2':
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:46:3: error: address taken, but ADDRESSABLE bit not set
    __OPENMP_TARGET__
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:35:11: note: in statement
    __builtin_GOMP_target_data (-1, &__OPENMP_TARGET__, 1, &.omp_data_arr.12, &.omp_data_sizes.13, &.omp_data_kinds.14);
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:46:3: error: address taken, but ADDRESSABLE bit not set
    __OPENMP_TARGET__
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:37:13: note: in statement
    __builtin_GOMP_target (-1, fn2._omp_fn.0, &__OPENMP_TARGET__, 6, &.omp_data_arr.6, &.omp_data_sizes.7, &.omp_data_kinds.8);
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:46:3: error: address taken, but ADDRESSABLE bit not set
    __OPENMP_TARGET__
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:44:13: note: in statement
    __builtin_GOMP_target_update (-1, &__OPENMP_TARGET__, 2, &.omp_data_arr.9, &.omp_data_sizes.10, &.omp_data_kinds.11);
    [...]/source/libgomp/testsuite/libgomp.c/target-1.c:46:3: internal compiler error: verify_gimple failed
    0xa149ec verify_gimple_in_cfg(function*, bool)
            ../../source/gcc/tree-cfg.c:4954
    0x93a407 execute_function_todo
            ../../source/gcc/passes.c:1777
    0x93ad63 execute_todo
            ../../source/gcc/passes.c:1834

In r210207, I committed the following patch; should we also be setting
any additional flags, such as DECL_ARTIFICIAL?

commit aaf964a67612f5aa50b405d2aa7998ed3b5d5ac6
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu May 8 09:41:33 2014 +0000

    Mark __OPENMP_TARGET__ as addressable.
    
    	gcc/
    	* omp-low.c (get_offload_symbol_decl): Mark __OPENMP_TARGET__ as
    	addressable.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@210207 138bc75d-0d04-0410-961f-82ee72b054a4



Grüße,
 Thomas
diff mbox

Patch

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 1bd1f51..b1e73c0 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,3 +1,8 @@ 
+2014-05-08  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* omp-low.c (get_offload_symbol_decl): Mark __OPENMP_TARGET__ as
+	addressable.
+
 2014-04-04  Bernd Schmidt  <bernds@codesourcery.com>
 
 	* lto-wrapper.c (replace_special_characters): Remove functions and
diff --git gcc/omp-low.c gcc/omp-low.c
index de00516..5e90ce3 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -233,6 +233,7 @@  get_offload_symbol_decl (void)
       tree decl = build_decl (UNKNOWN_LOCATION, VAR_DECL,
 			      get_identifier ("__OPENMP_TARGET__"),
 			      ptr_type_node);
+      TREE_ADDRESSABLE (decl) = 1;
       TREE_PUBLIC (decl) = 1;
       DECL_EXTERNAL (decl) = 1;
       DECL_WEAK (decl) = 1;