Bug 25539 - fix-loongson3-llsc cannot produce `sync` when there are multi label at the same address
Summary: fix-loongson3-llsc cannot produce `sync` when there are multi label at the sa...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.35
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-13 03:11 UTC by YunQiang Su
Modified: 2020-02-28 10:00 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
look back for all labels with the same value and compare them with the target (1.24 KB, patch)
2020-02-13 03:11 UTC, YunQiang Su
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description YunQiang Su 2020-02-13 03:11:50 UTC
Created attachment 12292 [details]
look back for all labels with the same value and compare them with the target

.set    noat
        sync
1:
        lld     $5,0($2)
        bne     $5,$0,2f
        move    $1,$3
        scd     $1,0($2)
        nop
        sync
2:
.LVL1085 = .
        .set    at
        lw      $2,8($fp)

In this example, since `bne` between lld/scd may jump to lw,
so if fix-loongson3-llsc option is enabled, a `sync` need to be insert before lw.

`bne` can only determine that it will jump to `2:`, but 
    S_GET_NAME( ... lw ...)
will give the name of lable `.LVL1085 = .`.
It will make no `sync` insert here.


In this patch, we can look back for all labels with the same value (S_GET_VALUE),
and compare them with the target.
Comment 1 Sourceware Commits 2020-02-28 09:37:59 UTC
The master branch has been updated by Chenghua Xu <paulhua@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=dec7b24be89fe0496f9442232bcbfcb16e030742

commit dec7b24be89fe0496f9442232bcbfcb16e030742
Author: YunQiang Su <syq@debian.org>
Date:   Fri Feb 28 15:58:13 2020 +0800

    MIPS/fix_loongson3_llsc: fix when target has multi labels
    
    When there is multi-labels on the same insn, the current code
    will take care about the last one. it may cause that no sync
    is added at the target.
    
    Here we scan all labels with same value of
       S_GET_VALUE(label_list->label)
    by label_list->next.
    
    2020-02-28  YunQiang Su  <syq@debian.org>
    
        PR gas/25539
        * config/tc-mips.c (fix_loongson3_llsc): Compare label value
        to handle multi-labels.
        (has_label_name): New.