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

            Bug ID: 117010
           Summary: [nvptx] Incorrect ptx code-gen for C++ code with
                    templates
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: prathamesh3492 at gcc dot gnu.org
  Target Milestone: ---

Hi,
For the test-case adapted from pr96390.C:

template<int Dim> struct V
{
  int version_called;  V ()
  {
    version_called = 1;
  }
};

void foo()
{
  V<0> v;
}

int
main ()
{
#pragma omp target
  {
    foo ();
  }
  return 0;
}

Compiling with -O0 -fopenmp -foffload=nvptx-none -foffload=-malias
-foffload=-mptx=6.3, results in following error:

ptxas ./a.xnvptx-none.mkoffload.o, line 45; error   : Call to '_ZN1VILi0EEC1Ev'
requires call prototype
ptxas ./a.xnvptx-none.mkoffload.o, line 45; error   : Unknown symbol
'_ZN1VILi0EEC1Ev'
ptxas fatal   : Ptx assembly aborted due to errors
nvptx-as: ptxas returned 255 exit status 

The reason this happens is because in PTX code-gen, we call _ZN1VILi0EEC1Ev
from _Z3foov, however  _ZN1VILi0EEC1Ev is not defined anywhere. Instead it
contains the following definition:

// BEGIN FUNCTION DECL: _ZN1VILi0EEC2Ev
.func _ZN1VILi0EEC2Ev (.param.u64 %in_ar0);

where _ZN1VILi0EEC1Ev is an (implicit) alias for _ZN1VILi0EEC2Ev in callgraph.

Thanks,
Prathamesh

Reply via email to