diff mbox

[gomp4,04/14] nvptx: fix output of _Bool global variables

Message ID 1445366076-16082-5-git-send-email-amonakov@ispras.ru
State New
Headers show

Commit Message

Alexander Monakov Oct. 20, 2015, 6:34 p.m. UTC
Due to special treatment of types, emitting variables of type _Bool in
global scope is impossible: extern references are emitted with .u8, but
definitions use .u64.  This patch fixes the issue by treating boolean type as
integer types.

	* config/nvptx/nvptx.c (init_output_initializer): Also accept
        BOOLEAN_TYPE.
---
 gcc/config/nvptx/nvptx.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Bernd Schmidt Oct. 20, 2015, 8:48 p.m. UTC | #1
On 10/20/2015 08:34 PM, Alexander Monakov wrote:
> Due to special treatment of types, emitting variables of type _Bool in
> global scope is impossible: extern references are emitted with .u8, but
> definitions use .u64.  This patch fixes the issue by treating boolean type as
> integer types.
>
> 	* config/nvptx/nvptx.c (init_output_initializer): Also accept
>          BOOLEAN_TYPE.

Interesting, what was the testcase? I didn't stumble over this one. In 
any case, I think this patch is ok for trunk.


Bernd
Alexander Monakov Oct. 20, 2015, 8:56 p.m. UTC | #2
On Tue, 20 Oct 2015, Bernd Schmidt wrote:

> On 10/20/2015 08:34 PM, Alexander Monakov wrote:
> > Due to special treatment of types, emitting variables of type _Bool in
> > global scope is impossible: extern references are emitted with .u8, but
> > definitions use .u64.  This patch fixes the issue by treating boolean type
> > as
> > integer types.
> >
> >  * config/nvptx/nvptx.c (init_output_initializer): Also accept
> >          BOOLEAN_TYPE.
> 
> Interesting, what was the testcase? I didn't stumble over this one. In any
> case, I think this patch is ok for trunk.

libgomp has 'bool gomp_cancel_var' in global scope, and since it is not
compiled with -ffunction-sections, GOMP_parallel pulls in
GOMP_cancel (same TU, parallel.c), which references the variable.  Anything
with "#pragma omp parallel" would fail to link.

Thanks.
Alexander
diff mbox

Patch

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 779b018..cfb5c4f 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -1863,6 +1863,7 @@  init_output_initializer (FILE *file, const char *name, const_tree type,
   int sz = int_size_in_bytes (type);
   if ((TREE_CODE (type) != INTEGER_TYPE
        && TREE_CODE (type) != ENUMERAL_TYPE
+       && TREE_CODE (type) != BOOLEAN_TYPE
        && TREE_CODE (type) != REAL_TYPE)
       || sz < 0
       || sz > HOST_BITS_PER_WIDE_INT)