public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96706] New: [nvptx] compilation failure of pr89663-1.c
@ 2020-08-19 12:59 vries at gcc dot gnu.org
  2020-08-19 13:58 ` [Bug target/96706] " vries at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-19 12:59 UTC (permalink / raw)
  To: gcc-bugs

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>
...

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug target/96706] [nvptx] compilation failure of pr89663-1.c
  2020-08-19 12:59 [Bug target/96706] New: [nvptx] compilation failure of pr89663-1.c vries at gcc dot gnu.org
@ 2020-08-19 13:58 ` vries at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: vries at gcc dot gnu.org @ 2020-08-19 13:58 UTC (permalink / raw)
  To: gcc-bugs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |nvptx

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative patch:
...
diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 39d0275493a..7ad9ab326d0 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -895,12 +895,12 @@ write_fn_proto (std::stringstream &s, bool is_defn,
      NULL in DECL_ARGUMENTS, for builtin functions without another
        declaration.
      So we have to pick the best one we have.  */
-  tree args = TYPE_ARG_TYPES (fntype);
-  bool prototyped = true;
+  tree args = DECL_ARGUMENTS (decl);
+  bool prototyped = false;
   if (!args)
     {
-      args = DECL_ARGUMENTS (decl);
-      prototyped = false;
+      args = TYPE_ARG_TYPES (fntype);
+      prototyped = true;
     }

   for (; args; args = TREE_CHAIN (args), not_atomic_weak_arg--)
@@ -1304,12 +1304,12 @@ nvptx_declare_function_name (FILE *file, const char
*name, const_tree decl)
     argno = write_arg_type (s, 0, argno, ptr_type_node, true);

   /* Declare and initialize incoming arguments.  */
-  tree args = TYPE_ARG_TYPES (fntype);
-  bool prototyped = true;
+  tree args = DECL_ARGUMENTS (decl);
+  bool prototyped = false;
   if (!args)
     {
-      args = DECL_ARGUMENTS (decl);
-      prototyped = false;
+      args = TYPE_ARG_TYPES (fntype);
+      prototyped = true;
     }

   for (; args != NULL_TREE; args = TREE_CHAIN (args))
...

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-19 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 12:59 [Bug target/96706] New: [nvptx] compilation failure of pr89663-1.c vries at gcc dot gnu.org
2020-08-19 13:58 ` [Bug target/96706] " vries at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).