public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: mengqinggang <mengqinggang@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, binutils@sourceware.org
Cc: xuchenghua@loongson.cn, liuzhensong@loongson.cn,
	chenglulu@loongson.cn, i.swmail@xen0n.name, maskray@google.com
Subject: Re: [PATCH v1 0/6] LoongArch linker relaxation support.
Date: Tue, 6 Dec 2022 09:58:20 +0800	[thread overview]
Message-ID: <4643a2ed-cd3b-3948-73cf-c22a6b56b3d3@loongson.cn> (raw)
In-Reply-To: <31f6c836d79a8569d95a36c6b6fcfafddbdf459e.camel@xry111.site>

We tried this method. We use R_LARCH_RELAX addend to distinguish two load
sequences. But there is a problem that has not been solved.
If there are two load sequences after a branch instruction like this:

   branch ------------
     | |
   pcalau12i pcalau12i
   ld.d ld.d

After scheduling, two pcalau12i may be reduced to one and put before
branch instruction like this:

pcalau12i
   branch -----------
     | |
    ld.d ld.d

For this case, if one branch make a relax, another branch will get a 
mistake.

But we will try to solve this question in relax v2 version.


在 2022/12/5 下午4:43, Xi Ruoyao 写道:
> On Mon, 2022-12-05 at 16:04 +0800, mengqinggang wrote:
>> Now, only the instrunctions expand from macro (la.local, la.got, etc.) at
>> assembly time can be relaxed, because gcc instruction scheduling causes relax
>> unable to handle some special cases. Gcc can add -mno-explicit-relocs option
>> to generate macro instrunction.
> Frankly, I don't like this.  Can the compiler explicitly emit some
> relocations to mark a instruction chain suitable for relaxation?  Some
> random thought:
>
> .reloc R_LARCH_RELOC_X 1
> pcalau12i $a0, %got_pc_hi20(sym_a)
> .reloc R_LARCH_RELOC_X 2
> pcalau12i $a1, %got_pc_hi20(sym_b)
> .reloc R_LARCH_RELOC_X 1
> ld.d $a0, $a0, %got_pc_lo12(sym_a)
> .reloc R_LARCH_RELOC_X 2
> ld.d $a1, $a1, %got_pc_lo12(sym_b)
> .reloc R_LARCH_RELOC_X 1
> ld.d $a0, $a0, 0
> .reloc R_LARCH_RELOC_X 2
> ld.d $a1, $a1, 0
>
> Here "R_LARCH_RELOC_X" is an imaginary relocation type.  We may be able
> to use the different values of the 32-bit addend to distinguish two load
> sequences interleaved after scheduling (I don't think there will be more
> than 2147483647 load sequences in an object file).
>
> This is just some random thoughts, I don't understand the linking
> process very well anyway.
>


      reply	other threads:[~2022-12-06  1:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05  8:04 mengqinggang
2022-12-05  8:04 ` [PATCH v1 1/6] LoongArch: include: Add support for linker relaxation mengqinggang
2022-12-05  8:24   ` Xi Ruoyao
2022-12-06  2:59     ` mengqinggang
2022-12-05  8:04 ` [PATCH v1 2/6] LoongArch: bfd: " mengqinggang
2022-12-05  8:04 ` [PATCH v1 3/6] LoongArch: opcodes: " mengqinggang
2022-12-05  9:43   ` Andreas Schwab
2022-12-05  8:04 ` [PATCH v1 4/6] LoongArch: binutils: " mengqinggang
2022-12-05  8:04 ` [PATCH v1 5/6] LoongArch: gas: " mengqinggang
2022-12-05  9:47   ` Andreas Schwab
2022-12-05  8:04 ` [PATCH v1 6/6] LoongArch: ld: " mengqinggang
2022-12-05  8:31   ` Xi Ruoyao
2022-12-05  8:43 ` [PATCH v1 0/6] LoongArch linker relaxation support Xi Ruoyao
2022-12-06  1:58   ` mengqinggang [this message]

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=4643a2ed-cd3b-3948-73cf-c22a6b56b3d3@loongson.cn \
    --to=mengqinggang@loongson.cn \
    --cc=binutils@sourceware.org \
    --cc=chenglulu@loongson.cn \
    --cc=i.swmail@xen0n.name \
    --cc=liuzhensong@loongson.cn \
    --cc=maskray@google.com \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /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.
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).