mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Waldemar Brodkorb <wbx@openadk.org>
To: musl@lists.openwall.com
Cc: Waldemar Brodkorb <wbx@openadk.org>
Subject: Re: [musl] loongarch64 atomics not working?
Date: Thu, 14 Mar 2024 06:44:31 +0100	[thread overview]
Message-ID: <ZfKOvxPBf9MosRmW@waldemar-brodkorb.de> (raw)
In-Reply-To: <20240313145215.GF4163@brightrain.aerifal.cx>

Hi,
Rich Felker wrote,

> > Yes I do. I found the reason why my mksh didn't worked.
> > I compiled everything with -Os and then I get the deadlock.
> > When I compile everything with -O2 musl mksh is working.
> > 
> > So it seems some gcc problem code compiled with -Os.
> 
> Let's look at the generated asm for the function using a_cas_p and see
> if this is a gcc bug or if the asm argument constraints as written
> allowed a transformation that's not actually valid.

Broken mksh with -Os:
 
000000012003b970 <cgt_init>:
   12003b970:   02ff8063        addi.d          $sp, $sp, -32
   12003b974:   29c02077        st.d            $s0, $sp, 8
   12003b978:   27000078        stptr.d         $s1, $sp, 0
   12003b97c:   00150097        move            $s0, $a0
   12003b980:   001500b8        move            $s1, $a1
   12003b984:   1a000084        pcalau12i       $a0, 4
   12003b988:   1a000085        pcalau12i       $a1, 4
   12003b98c:   29c04076        st.d            $fp, $sp, 16
   12003b990:   29c06061        st.d            $ra, $sp, 24
   12003b994:   02c08076        addi.d          $fp, $sp, 32
   12003b998:   02c060a5        addi.d          $a1, $a1, 24
   12003b99c:   02c0c084        addi.d          $a0, $a0, 48
   12003b9a0:   54021400        bl              532     # 12003bbb4 <__vdsosym>
   12003b9a4:   0015008e        move            $t2, $a0
   12003b9a8:   38720000        dbar            0x0
   12003b9ac:   1a00002d        pcalau12i       $t1, 1
   12003b9b0:   1a00032f        pcalau12i       $t3, 25
   12003b9b4:   02e5c1ad        addi.d          $t1, $t1, -1680
   12003b9b8:   02ca21ec        addi.d          $t0, $t3, 648
   12003b9bc:   2200018c        ll.d            $t0, $t0, 0
   12003b9c0:   5c00198d        bne             $t0, $t1, 24    # 12003b9d8 <cgt_init+0x68>
   12003b9c4:   001501cc        move            $t0, $t2
   12003b9c8:   02ca21f0        addi.d          $t4, $t3, 648
   12003b9cc:   2300020c        sc.d            $t0, $t4, 0
   12003b9d0:   0040818c        slli.w          $t0, $t0, 0x0
   12003b9d4:   43ffe59f        beqz            $t0, -28        # 12003b9b8 <cgt_init+0x48>
   12003b9d8:   38720000        dbar            0x0
   12003b9dc:   400025c0        beqz            $t2, 36 # 12003ba00 <cgt_init+0x90>
   12003b9e0:   28c04076        ld.d            $fp, $sp, 16
   12003b9e4:   28c06061        ld.d            $ra, $sp, 24
   12003b9e8:   00150305        move            $a1, $s1
   12003b9ec:   001502e4        move            $a0, $s0
   12003b9f0:   26000078        ldptr.d         $s1, $sp, 0
   12003b9f4:   28c02077        ld.d            $s0, $sp, 8
   12003b9f8:   02c08063        addi.d          $sp, $sp, 32
   12003b9fc:   4c0001c0        jr              $t2
   12003ba00:   28c06061        ld.d            $ra, $sp, 24
   12003ba04:   28c04076        ld.d            $fp, $sp, 16
   12003ba08:   28c02077        ld.d            $s0, $sp, 8
   12003ba0c:   26000078        ldptr.d         $s1, $sp, 0
   12003ba10:   02bf6804        li.w            $a0, -38
   12003ba14:   02c08063        addi.d          $sp, $sp, 32
   12003ba18:   4c000020        ret

Working mksh with -O2:
0000000120045f50 <cgt_init>:
   120045f50:   02ff8063        addi.d          $sp, $sp, -32
   120045f54:   29c02077        st.d            $s0, $sp, 8
   120045f58:   27000078        stptr.d         $s1, $sp, 0
   120045f5c:   00150097        move            $s0, $a0
   120045f60:   001500b8        move            $s1, $a1
   120045f64:   1a000084        pcalau12i       $a0, 4
   120045f68:   1a000085        pcalau12i       $a1, 4
   120045f6c:   29c04076        st.d            $fp, $sp, 16
   120045f70:   29c06061        st.d            $ra, $sp, 24
   120045f74:   02c08076        addi.d          $fp, $sp, 32
   120045f78:   02dbc0a5        addi.d          $a1, $a1, 1776
   120045f7c:   02dc2084        addi.d          $a0, $a0, 1800
   120045f80:   54024c00        bl              588     # 1200461cc <__vdsosym>
   120045f84:   0015008f        move            $t3, $a0
   120045f88:   38720000        dbar            0x0
   120045f8c:   1a000030        pcalau12i       $t4, 1
   120045f90:   1a00036d        pcalau12i       $t1, 27
   120045f94:   02fd4210        addi.d          $t4, $t4, -176
   120045f98:   50001400        b               20      # 120045fac <cgt_init+0x5c>
   120045f9c:   02ca21ae        addi.d          $t2, $t1, 648
   120045fa0:   230001cc        sc.d            $t0, $t2, 0
   120045fa4:   0040818c        slli.w          $t0, $t0, 0x0
   120045fa8:   44001580        bnez            $t0, 20 # 120045fbc <cgt_init+0x6c>
   120045fac:   02ca21ac        addi.d          $t0, $t1, 648
   120045fb0:   2200018e        ll.d            $t2, $t0, 0
   120045fb4:   001501ec        move            $t0, $t3
   120045fb8:   5bffe60e        beq             $t4, $t2, -28   # 120045f9c <cgt_init+0x4c>
   120045fbc:   38720000        dbar            0x0
   120045fc0:   400025e0        beqz            $t3, 36 # 120045fe4 <cgt_init+0x94>
   120045fc4:   28c04076        ld.d            $fp, $sp, 16
   120045fc8:   28c06061        ld.d            $ra, $sp, 24
   120045fcc:   00150305        move            $a1, $s1
   120045fd0:   001502e4        move            $a0, $s0
   120045fd4:   26000078        ldptr.d         $s1, $sp, 0
   120045fd8:   28c02077        ld.d            $s0, $sp, 8
   120045fdc:   02c08063        addi.d          $sp, $sp, 32
   120045fe0:   4c0001e0        jr              $t3
   120045fe4:   28c06061        ld.d            $ra, $sp, 24
   120045fe8:   28c04076        ld.d            $fp, $sp, 16
   120045fec:   28c02077        ld.d            $s0, $sp, 8
   120045ff0:   26000078        ldptr.d         $s1, $sp, 0
   120045ff4:   02bf6804        li.w            $a0, -38
   120045ff8:   02c08063        addi.d          $sp, $sp, 32
   120045ffc:   4c000020        ret

Does that help? Both binaries can be found on https://debug.openadk.org.

best regards
 Waldemar

  reply	other threads:[~2024-03-14  5:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  0:51 Rich Felker
2024-03-12  2:06 ` Hongliang Wang
2024-03-12  8:31   ` lixing
2024-03-12 16:18     ` Waldemar Brodkorb
2024-03-12 16:47       ` Thorsten Glaser
2024-03-12 17:18         ` Waldemar Brodkorb
2024-03-13  1:42           ` lixing
2024-03-13 14:45             ` Waldemar Brodkorb
2024-03-13 14:52               ` Rich Felker
2024-03-14  5:44                 ` Waldemar Brodkorb [this message]
2024-03-14  6:45                   ` lixing
2024-03-14 13:44                     ` Leah Neukirchen
2024-03-15  0:58                       ` lixing
2024-03-12  8:48   ` Jingyun Hua

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZfKOvxPBf9MosRmW@waldemar-brodkorb.de \
    --to=wbx@openadk.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).