public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels
@ 2024-09-12 11:51 schwab@linux-m68k.org
  2024-09-12 11:53 ` [Bug target/116693] " schwab@linux-m68k.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2024-09-12 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 116693
           Summary: [RISC-V] @tlsdesc<mode> generates duplicate assembler
                    labels
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Keywords: assemble-failure
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: schwab@linux-m68k.org
  Target Milestone: ---
            Target: riscv*-*-*

Current mesa fails to build with LTO because it emits duplicate assembler
labels.

src/gallium/targets/dri/libgallium-24.2.2.so.ltrans125.ltrans.s: Assembler
messages:
src/gallium/targets/dri/libgallium-24.2.2.so.ltrans125.ltrans.s:132389: Error:
symbol `.LT178' is already defined
src/gallium/targets/dri/libgallium-24.2.2.so.ltrans125.ltrans.s:135408: Error:
symbol `.LT226' is already defined
src/gallium/targets/dri/libgallium-24.2.2.so.ltrans125.ltrans.s:136590: Error:
symbol `.LT250' is already defined
make: *** [/tmp/ccU08NIk.mk:252:
src/gallium/targets/dri/libgallium-24.2.2.so.ltrans125.ltrans.o] Error 1

.LBB33241:
        .loc 87 51 35
        .LT178: auipc  
a0,%tlsdesc_hi(_ZGVZN4r60010MemoryPool8instanceEvE2me.lto_priv.0)
        ld      t0,%tlsdesc_load_lo(.LT178)(a0)
        addi    a0,a0,%tlsdesc_add_lo(.LT178)
        jalr    t0,t0,%tlsdesc_call(.LT178)

The problem is that the @tlsdesc<mode> insn uses a label number that is only
unique at the time of the generation, but when the insn is duplicated the label
number is not updated.

The pattern should use the %= format instead of maintaining the label number
explicitly.

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

* [Bug target/116693] [RISC-V] @tlsdesc<mode> generates duplicate assembler labels
  2024-09-12 11:51 [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels schwab@linux-m68k.org
@ 2024-09-12 11:53 ` schwab@linux-m68k.org
  2024-09-12 18:11 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2024-09-12 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Schwab <schwab@linux-m68k.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.3

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

* [Bug target/116693] [RISC-V] @tlsdesc<mode> generates duplicate assembler labels
  2024-09-12 11:51 [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels schwab@linux-m68k.org
  2024-09-12 11:53 ` [Bug target/116693] " schwab@linux-m68k.org
@ 2024-09-12 18:11 ` pinskia at gcc dot gnu.org
  2024-09-12 18:17 ` palmer at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-09-12 18:11 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2024-09-12

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed. Either tlsdesc should be marked as cannot copy (via
TARGET_CANNOT_COPY_INSN_P hook which on riscv uses get_attr_cannot_copy) or use
%= .


This is the simple cannot copy patch:
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 9f94b5aa023..906c826d402 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2341,6 +2341,7 @@ (define_insn "@tlsdesc<mode>"
   }
   [(set_attr "type" "multi")
    (set_attr "length" "16")
+   (set_attr "cannot_copy" "yes")
    (set_attr "mode" "<MODE>")])

 (define_insn "auipc<mode>"

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

* [Bug target/116693] [RISC-V] @tlsdesc<mode> generates duplicate assembler labels
  2024-09-12 11:51 [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels schwab@linux-m68k.org
  2024-09-12 11:53 ` [Bug target/116693] " schwab@linux-m68k.org
  2024-09-12 18:11 ` pinskia at gcc dot gnu.org
@ 2024-09-12 18:17 ` palmer at gcc dot gnu.org
  2024-09-16  9:23 ` cvs-commit at gcc dot gnu.org
  2024-09-22 17:13 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: palmer at gcc dot gnu.org @ 2024-09-12 18:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Palmer Dabbelt <palmer at gcc dot gnu.org> ---
I think something like this

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 9f94b5aa023..c64c881d152 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2334,10 +2334,10 @@ (define_insn "@tlsdesc<mode>"
    (clobber (reg:P T0_REGNUM))]
   "TARGET_TLSDESC"
   {
-    return ".LT%1: auipc\ta0,%%tlsdesc_hi(%0)\;"
-           "<load>\tt0,%%tlsdesc_load_lo(.LT%1)(a0)\;"
-           "addi\ta0,a0,%%tlsdesc_add_lo(.LT%1)\;"
-           "jalr\tt0,t0,%%tlsdesc_call(.LT%1)";
+    return ".LT%=: auipc\ta0,%%tlsdesc_hi(%0)\;"
+           "<load>\tt0,%%tlsdesc_load_lo(.LT%=)(a0)\;"
+           "addi\ta0,a0,%%tlsdesc_add_lo(.LT%=)\;"
+           "jalr\tt0,t0,%%tlsdesc_call(.LT%=)";
   }
   [(set_attr "type" "multi")
    (set_attr "length" "16")

would do it?  My setup looks broken locally for LTO, though, so I can't quite
reproduce it right now...

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

* [Bug target/116693] [RISC-V] @tlsdesc<mode> generates duplicate assembler labels
  2024-09-12 11:51 [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels schwab@linux-m68k.org
                   ` (2 preceding siblings ...)
  2024-09-12 18:17 ` palmer at gcc dot gnu.org
@ 2024-09-16  9:23 ` cvs-commit at gcc dot gnu.org
  2024-09-22 17:13 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-09-16  9:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andreas Schwab <schwab@gcc.gnu.org>:

https://gcc.gnu.org/g:952df9c50b30cc6f849c422b84592a81524f8ef7

commit r15-3663-g952df9c50b30cc6f849c422b84592a81524f8ef7
Author: Andreas Schwab <schwab@suse.de>
Date:   Thu Sep 12 13:55:09 2024 +0200

    riscv: Fix duplicate assmbler label in @tlsdesc<mode> insn

    Use %= instead of maintaining a sequence number manually, so that it
    doesn't result in a duplicate assembler label when the insn is duplicated.

            PR target/116693
            * config/riscv/riscv.cc (riscv_legitimize_tls_address): Don't pass
            seqno to gen_tlsdesc and remove it.
            * config/riscv/riscv.md (@tlsdesc<mode>): Remove operand 1.  Use
            %= instead of %1 in template.

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

* [Bug target/116693] [RISC-V] @tlsdesc<mode> generates duplicate assembler labels
  2024-09-12 11:51 [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels schwab@linux-m68k.org
                   ` (3 preceding siblings ...)
  2024-09-16  9:23 ` cvs-commit at gcc dot gnu.org
@ 2024-09-22 17:13 ` law at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: law at gcc dot gnu.org @ 2024-09-22 17:13 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Jeffrey A. Law <law at gcc dot gnu.org> ---
Fixed on the trunk.

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

end of thread, other threads:[~2024-09-22 17:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-12 11:51 [Bug target/116693] New: [RISC-V] @tlsdesc<mode> generates duplicate assembler labels schwab@linux-m68k.org
2024-09-12 11:53 ` [Bug target/116693] " schwab@linux-m68k.org
2024-09-12 18:11 ` pinskia at gcc dot gnu.org
2024-09-12 18:17 ` palmer at gcc dot gnu.org
2024-09-16  9:23 ` cvs-commit at gcc dot gnu.org
2024-09-22 17:13 ` law 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).