This is the mail archive of the gcc-bugs@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]

[Bug target/79939] New: [nvptx] gcc hangs in nvptx_assemble_value


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79939

            Bug ID: 79939
           Summary: [nvptx] gcc hangs in nvptx_assemble_value
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

gcc hangs when trying to compile pr59037.c: 
...
WARNING: program timed out.
FAIL: c-c++-common/pr59037.c  -Wc++-compat  (test for excess errors)
...

pr59037.c:
...
typedef int v4si __attribute__ ((vector_size (16)));

int
main (int argc, char** argv)
{
  v4si x = {0,1,2,3};
  x = (v4si) {(x)[3], (x)[2], (x)[1], (x)[0]};
  return x[4];
}
...

To reproduce (also at -O1, -O3):
...
$ gcc src/gcc-mainline/gcc/testsuite/c-c++-common/pr59037.c -O2
...

The compiler is stuck in the loop in nvptx_assemble_value with arguments:
...
nvptx_assemble_value (val=8589934595, size=8)
...

This happens with trunk, not with gomp-4_0-branch.

The code is like this:
...
static void
nvptx_assemble_value (unsigned HOST_WIDE_INT val, unsigned size)
{
  val &= ((unsigned  HOST_WIDE_INT)2 << (size * BITS_PER_UNIT - 1)) - 1;

  for (unsigned part = 0; size; size -= part)
    {
      val >>= part * BITS_PER_UNIT;
      part = init_frag.size - init_frag.offset;
      if (part > size)
        part = size;

      unsigned HOST_WIDE_INT partial
        = val << (init_frag.offset * BITS_PER_UNIT);
      init_frag.val |= partial & init_frag.mask;
      init_frag.offset += part;

      if (init_frag.offset == init_frag.size)
        output_init_frag (NULL);
    }
}
...

Both init_frag.size and init_frag.offset are 0, so part stays 0, so size stays
8, and the loop never terminates.

The only place where init_frag.size is set, is nvptx_assemble_decl_begin, but
that one is not called.

Backtrace when entering:
...
(gdb) bt
#0  nvptx_assemble_value (val=8589934595, size=8)
    at src/gcc-mainline/gcc/config/nvptx/nvptx.c:1765
#1  0x0000000000e647e9 in nvptx_assemble_integer (x=<optimized out>,
size=<optimized out>, 
    aligned_p=<optimized out>) at
src/gcc-mainline/gcc/config/nvptx/nvptx.c:1799
#2  0x0000000000e379eb in assemble_integer (x=0x7ffff7426220,
size=size@entry=8, align=align@entry=64, 
    force=force@entry=0) at src/gcc-mainline/gcc/varasm.c:2721
#3  0x0000000000e37a79 in assemble_integer (x=0x7ffff7423858, size=16,
align=<optimized out>, force=force@entry=1)
    at src/gcc-mainline/gcc/varasm.c:2746
#4  0x0000000000e37d66 in output_constant_pool_2 (mode=<optimized out>,
x=<optimized out>, align=<optimized out>)
    at src/gcc-mainline/gcc/varasm.c:3848
#5  0x0000000000e37ec7 in output_constant_pool_1
(desc=desc@entry=0x7ffff7326340, align=<optimized out>)
    at src/gcc-mainline/gcc/varasm.c:3936
#6  0x0000000000e4496b in output_constant_pool_contents (pool=<optimized out>)
    at src/gcc-mainline/gcc/varasm.c:4073
#7  0x0000000000b2080c in compile_file () at src/gcc-mainline/gcc/toplev.c:526
#8  0x00000000005a60e2 in do_compile () at src/gcc-mainline/gcc/toplev.c:1984
#9  toplev::main (this=0x7fffffffddb0, argc=21, argv=0x7fffffffdeb8)
    at src/gcc-mainline/gcc/toplev.c:2118
#10 0x00000000005a7e67 in main (argc=21, argv=0x7fffffffdeb8)
    at src/gcc-mainline/gcc/main.c:39
...

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