[Bug target/106445] New: nvptx offloading: C++ constructor symbol alias getting lost

tschwinge at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Jul 26 08:38:07 GMT 2022


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

            Bug ID: 106445
           Summary: nvptx offloading: C++ constructor symbol alias getting
                    lost
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tschwinge at gcc dot gnu.org
                CC: vries at gcc dot gnu.org
  Target Milestone: ---
            Target: nvptx

I found this during my "GPU support for minimal C++ library" investigations,
PR101544.  You're not currently able to reproduce this, as it depends on a
number of WIP patches, but I'm filing it for later reference.  (Or, I suppose
could maybe come up with a non-C++ reproducer.)  I've not yet looked through
the existing nvptx symbol alias issues in detail.  I've also not yet tried
reproducing the issue without offloading, with a nvptx target toolchain.


Simple 'std::vector<int> v;' in OpenMP 'target', '-O0', host-side
'-fno-exceptions', '-foffload-options=nvptx-none=-malias\ -mptx=6.3' works for
GCN, but fails to compile for nvptx:

    ptxas ./a.xnvptx-none.mkoffload.o, line 243; error   : Label expected for
argument 0 of instruction 'call'
    ptxas ./a.xnvptx-none.mkoffload.o, line 243; error   : Function
'_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev' not declared in this scope

    $ c++filt _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev
    std::_Vector_base<int, std::allocator<int> >::_Vector_impl::_Vector_impl()

Looking for '_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev':

For all host/device '-fdump-tree-all-raw-asmname', we only ever see:

    gimple_call <_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev, NULL, _1>

Correspondingly, for all device '-fdump-rtl-all-raw-asmname':

    (call (mem:QI (symbol_ref:DI
("_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev") [flags 0x3]  <function_decl
0x7f08a2fe0d00 __ct_comp >) [0 _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev S1
A8])

In 'a.xnvptx-none.mkoffload.s' only ever:

    call _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev, (%out_arg1);

In 'a.xamdgcn-amdhsa.mkoffload.1.s' however:

    s_add_u32       s2, s2,
_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev@rel32@lo+4
    s_addc_u32      s3, s3,
_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev@rel32@hi+4

..., but also:

    .set   
_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev

..., that is, a symbol alias (C++ constructors) -- that's missing for nvptx.

Looking for '_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev':

There is no (relevant) difference in device '-fdump-tree-all-raw-asmname'
'*.094t.fixup_cfg3' and still not '*.253t.optimized'.

There is no (relevant) difference in device '-fdump-rtl-all-raw-asmname'
'*.254r.expand' and still not (approximately) '*.333r.final'.

That is, '_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev' is still present in
nvptx '*.333r.final'.

In 'a.xamdgcn-amdhsa.mkoffload.1.s':

            .type   _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev,@function
    _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev:
    [...]
            .size   _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev,
.-_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
            .set   
_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev,_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev

In 'a.xnvptx-none.mkoffload.s':

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

    // BEGIN FUNCTION DEF: _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev
    .func _ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev (.param.u64 %in_ar0)
    {
    [...]
    }

..., but not followed by a '.alias'.


In case that's relevant (... for nvptx...): the difference for a very similar
'_ZNSt6vectorIiSaIiEEC1Ev' -> '_ZNSt6vectorIiSaIiEEC2Ev' symbol alias (which
does get defined for both GCN and nvptx) is that the use of
'_ZNSt6vectorIiSaIiEEC1Ev' appears after definition of
'_ZNSt6vectorIiSaIiEEC2Ev' and its '_ZNSt6vectorIiSaIiEEC1Ev' alias, but for
the '_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev' reported above, the use
appears before the '_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev' function and
'_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC1Ev' ->
'_ZNSt12_Vector_baseIiSaIiEE12_Vector_implC2Ev' symbol alias definitions (the
latter missing for nvptx).

---

Similar issue (but different constructor) for 'std::vector<int> v(100);'.


More information about the Gcc-bugs mailing list