public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3)
@ 2022-03-16 15:05 vries at gcc dot gnu.org
  2022-03-16 15:40 ` [Bug target/104957] " vries at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-16 15:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 104957
           Summary: [nvptx] Use .alias directive (available starting ptx
                    isa version 6.3)
           Product: gcc
           Version: 12.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: ---

[ There is a number of nvptx PRs open about alias support.  The focus of this
PR is $subject, rather than supporting some specific source construct. ]

So, we have an .alias directive in ptx, can we use it for something?

Ideally, we'd use the .alias directive for all our needs, but it's too limited
for that.

OTOH, currently we just error out on any .alias usage in the source code, so we
could try to add an implementation that only errors out for things it doesn't
support.

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

* [Bug target/104957] [nvptx] Use .alias directive (available starting ptx isa version 6.3)
  2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
@ 2022-03-16 15:40 ` vries at gcc dot gnu.org
  2022-03-16 15:49 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-16 15:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 52636
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52636&action=edit
Tentative patch

Patch that I'm currently working on.

Adds -malias, off by default.

It's off by default because when doing a build with libgomp and malias on by
default, libgomp uses .alias a few times, and that ends up in a linker error
"Internal error: reference to deleted section" with OvO test-cases (haven't
tried others)

This may be a driver error, or incorrect usage of the .alias directive.  The
answer might be found by playing around with .alias in cuda examples.

Things I tried manually in the ptx were:
- resolving the .alias: this worked
- enforcing order: function definition, alias declaration, alias definition
  to precisely match example in ptx manual: didn't work.

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

* [Bug target/104957] [nvptx] Use .alias directive (available starting ptx isa version 6.3)
  2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
  2022-03-16 15:40 ` [Bug target/104957] " vries at gcc dot gnu.org
@ 2022-03-16 15:49 ` vries at gcc dot gnu.org
  2022-03-16 21:35 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-16 15:49 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
So, what do we get after specifying -malias -mptx=6.3?

Alias attribute only for functions, not variables.

No support for weak alias (allowing this does compile, but we run into
execution fails in gcc.dg/globalalias.c and gcc.dg/pr77587.c).

No support for aliases of weak functions.  We can't detect this in the
compiler, so we'll run into linker error "error: Function test with .weak scope
cannot be aliased".

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

* [Bug target/104957] [nvptx] Use .alias directive (available starting ptx isa version 6.3)
  2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
  2022-03-16 15:40 ` [Bug target/104957] " vries at gcc dot gnu.org
  2022-03-16 15:49 ` vries at gcc dot gnu.org
@ 2022-03-16 21:35 ` vries at gcc dot gnu.org
  2022-03-18 10:11 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-16 21:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
The OvO testsuite, when run at -O2 passes, because it inlines all .alias
instances.

But at -O0, it doesn't.  With -foffload=-malias that's fixed.

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

* [Bug target/104957] [nvptx] Use .alias directive (available starting ptx isa version 6.3)
  2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-03-16 21:35 ` vries at gcc dot gnu.org
@ 2022-03-18 10:11 ` vries at gcc dot gnu.org
  2022-03-22 13:40 ` cvs-commit at gcc dot gnu.org
  2022-03-22 13:46 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-18 10:11 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

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

* [Bug target/104957] [nvptx] Use .alias directive (available starting ptx isa version 6.3)
  2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-03-18 10:11 ` vries at gcc dot gnu.org
@ 2022-03-22 13:40 ` cvs-commit at gcc dot gnu.org
  2022-03-22 13:46 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-22 13:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom de Vries <vries@gcc.gnu.org>:

https://gcc.gnu.org/g:f8b15e177155960017ac0c5daef8780d1127f91c

commit r12-7766-gf8b15e177155960017ac0c5daef8780d1127f91c
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Mar 11 13:41:01 2022 +0100

    [nvptx] Use .alias directive for mptx >= 6.3

    Starting with ptx isa version 6.3, a ptx directive .alias is available.
    Use this directive to support symbol aliases, as far as possible.

    The alias support is off by default.  It can be turned on using a switch
    -malias.

    Furthermore, for pre-sm_75, it's not effective unless the ptx version is
    bumped to 6.3 or higher using -mptx (given that the default for pre-sm_75
is
    6.0).

    The alias support has the following limitations.

    Only function aliases are supported.

    Weak aliases are not supported.  That is, if I disable the check in
    nvptx_asm_output_def_from_decls that disallows this, a weak alias is
emitted
    and parsed by the driver.  But the test gcc.dg/globalalias.c starts
failing,
    with the behaviour matching the comment about "weird behavior of AIX's .set
    pseudo-op": a weak alias may resolve to different functions in different
    files.

    Aliases to weak symbols are not supported (see gcc.dg/localalias.c).  This
is
    currently not prohibited by the compiler, but with the driver link we run
    into: "error: Function test with .weak scope cannot be aliased".

    Aliases to aliases are not supported (see libgomp.c-c++-common/pr96390.c).
    This is currently not prohibited by the compiler, but with the driver link
we
    run into:  "Internal error: alias to unknown symbol" .

    Unreferenced aliases are not emitted (these can occur f.i. when inlining a
    call to an alias).  This avoids driver link error "Internal error:
reference
    to deleted section".

    When enabling malias by default, libgomp detects alias support and
    consequently libgomp.a will contains a few uses of .alias.  This however
    results in aforementioned "Internal error: reference to deleted section" in
    many test-cases.  Either there's some error with how .alias is used, or
    there's a driver bug.  While this issue is not resolved, we keep malias
    off-by-default.

    At some point we may add support in the nvptx-tools linker for symbol
    aliases, and define f.i. malias=ptx and malias=ld to choose between the two
in
    the compiler.

    An example of where this support is useful, is the OvO (OpenMP vs Offload)
    testsuite.  The testsuite passes already at -O2.  But at -O0, there are
errors
    in some c++ test-cases due to missing symbol alias support.  By compiling
with
    -malias, the whole testsuite passes also at -O0.

    This patch causes a regression:
    ...
    -PASS: gcc.dg/pr60797.c  (test for errors, line 4)
    +FAIL: gcc.dg/pr60797.c  (test for errors, line 4)
    ...
    The test-case is skipped for effective target alias, and both without and
with
    this patch the nvptx target is considered to not support it, so the
test-case is
    executed.  The test-case expects an error message along the lines of "alias
    definitions not supported in this configuration", but instead we run into:
    ...
    gcc.dg/pr60797.c:4:12: error: foo aliased to undefined symbol
    ...
    This is probably due to the fact that the nvptx backend now defines macros
    ASM_OUTPUT_DEF and ASM_OUTPUT_DEF_FROM_DECLS, so from the point of view of
the
    common part of the compiler, aliases are supported.

    gcc/ChangeLog:

    2022-03-18  Tom de Vries  <tdevries@suse.de>

            PR target/104957
            * config/nvptx/nvptx-protos.h (nvptx_asm_output_def_from_decls):
Declare.
            * config/nvptx/nvptx.cc (write_fn_proto_1): Don't add function
marker
            for alias.
            (SET_ASM_OP, NVPTX_ASM_OUTPUT_DEF): New macro def.
            (nvptx_asm_output_def_from_decls): New function.
            * config/nvptx/nvptx.h (ASM_OUTPUT_DEF): New macro def, define to
            gcc_unreachable ().
            (ASM_OUTPUT_DEF_FROM_DECLS): New macro def, define to
            nvptx_asm_output_def_from_decls.
            * config/nvptx/nvptx.opt (malias): New opt.

    gcc/testsuite/ChangeLog:

    2022-03-18  Tom de Vries  <tdevries@suse.de>

            PR target/104957
            * gcc.target/nvptx/alias-1.c: New test.
            * gcc.target/nvptx/alias-2.c: New test.
            * gcc.target/nvptx/alias-3.c: New test.
            * gcc.target/nvptx/alias-4.c: New test.
            * gcc.target/nvptx/nvptx.exp
            (check_effective_target_runtime_ptx_isa_version_6_3): New proc.

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

* [Bug target/104957] [nvptx] Use .alias directive (available starting ptx isa version 6.3)
  2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-03-22 13:40 ` cvs-commit at gcc dot gnu.org
@ 2022-03-22 13:46 ` vries at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: vries at gcc dot gnu.org @ 2022-03-22 13:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
Committed.

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

end of thread, other threads:[~2022-03-22 13:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 15:05 [Bug target/104957] New: [nvptx] Use .alias directive (available starting ptx isa version 6.3) vries at gcc dot gnu.org
2022-03-16 15:40 ` [Bug target/104957] " vries at gcc dot gnu.org
2022-03-16 15:49 ` vries at gcc dot gnu.org
2022-03-16 21:35 ` vries at gcc dot gnu.org
2022-03-18 10:11 ` vries at gcc dot gnu.org
2022-03-22 13:40 ` cvs-commit at gcc dot gnu.org
2022-03-22 13:46 ` 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).