[Bug target/96706] New: [nvptx] compilation failure of pr89663-1.c

vries at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 19 12:59:05 GMT 2020


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

            Bug ID: 96706
           Summary: [nvptx] compilation failure of pr89663-1.c
           Product: gcc
           Version: 11.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: ---

Consider test-case pr89663-1.c, minimized from
gcc/testsuite/gcc.c-torture/compile/pr89663-1.c, and with added main:
...
long lrint ();

void
foo (long long *p)
{
  int n = 0;
  p[n++] = lrint (1);
}

long
lrint (a)
  int a;  
{
  return a + 1;
}

int
main (void)
{
  long long l;
  foo (&l);
  return l == 2;
}
...

With gcc on x86_64, we have:
...
$ gcc pr89663-1.c -fno-builtin
$ ./a.out; echo $?
1
...
and:
...
$ gcc pr89663-1.c
pr89663-1.c: In function ‘lrint’:
pr89663-1.c:12:7: warning: argument ‘a’ doesn’t match built-in prototype
   int a;
       ^
$ ./a.out; echo $?
1
...

With nvptx, we have:
...
$ /home/vries/nvptx/mainkernel-2/build-gcc/gcc/xgcc
-B/home/vries/nvptx/mainkernel-2/build-gcc/gcc/ -fdiagnostics-plain-output
--sysroot=/home/vries/nvptx/mainkernel-2/install/nvptx-none -w -O0 -isystem
/home/vries/nvptx/mainkernel-2/build-gcc/nvptx-none/./newlib/targ-include
-isystem /home/vries/nvptx/mainkernel-2/source-gcc/newlib/libc/include
-B/home/vries/nvptx/mainkernel-2/build-gcc/nvptx-none/./newlib/
-L/home/vries/nvptx/mainkernel-2/build-gcc/nvptx-none/./newlib -mmainkernel -lm
pr89663-1.c -fno-builtin
$ ~/nvptx/mainkernel-2/install/bin/nvptx-none-run a.out; echo $?
1
...
and:
...
$ /home/vries/nvptx/mainkernel-2/build-gcc/gcc/xgcc
-B/home/vries/nvptx/mainkernel-2/build-gcc/gcc/ -fdiagnostics-plain-output
--sysroot=/home/vries/nvptx/mainkernel-2/install/nvptx-none -w -O0 -isystem
/home/vries/nvptx/mainkernel-2/build-gcc/nvptx-none/./newlib/targ-include
-isystem /home/vries/nvptx/mainkernel-2/source-gcc/newlib/libc/include
-B/home/vries/nvptx/mainkernel-2/build-gcc/nvptx-none/./newlib/
-L/home/vries/nvptx/mainkernel-2/build-gcc/nvptx-none/./newlib -mmainkernel -lm
pr89663-1.c 
ptxas /tmp/ccbuZdU3.o, line 26; error   : Arguments mismatch for instruction
'mov'
ptxas /tmp/ccbuZdU3.o, line 71; error   : Type of argument does not match
formal parameter '%in_ar0'
ptxas /tmp/ccbuZdU3.o, line 71; error   : Alignment of argument does not match
formal parameter '%in_ar0'
ptxas fatal   : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status
...
because:
...
// BEGIN GLOBAL FUNCTION DECL: lrint                                            
.visible .func (.param.u64 %value_out) lrint (.param.f64 %in_ar0);              

// BEGIN GLOBAL FUNCTION DEF: lrint                                             
.visible .func (.param.u64 %value_out) lrint (.param.f64 %in_ar0)
{
        .reg.f64 %ar0;                                                          
        ld.param.f64 %ar0, [%in_ar0];                                           
        .reg.u32 %r25;                                                          
                mov.u32 %r25, %ar0;                                            
              ...

The problem is that we end up in nvptx_declare_function_name with a decl that
has as decl args:
...
    arguments <parm_decl 0x7ffff68fe080 a
        type <integer_type 0x7ffff68085e8 int sizes-gimplified public SI size
<integer_cst 0x7ffff67fb798 32> unit-size <integer_cst 0x7ffff67fb7b0 4>
...
but we to emit the declaration, we use the fntype, which has arg:
...
(gdb) call debug_tree (args)
 <tree_list 0x7ffff6804e60
    value <real_type 0x7ffff680f348 double DF
        size <integer_cst 0x7ffff67fb558 constant 64>
...


More information about the Gcc-bugs mailing list