public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
@ 2024-01-29 13:17 Nelson Chu
  2024-01-30 10:00 ` Andreas Schwab
  2024-02-19 14:34 ` Andreas Schwab
  0 siblings, 2 replies; 6+ messages in thread
From: Nelson Chu @ 2024-01-29 13:17 UTC (permalink / raw)
  To: binutils, kito.cheng, jim.wilson.gcc, palmer, andrew
  Cc: nelson.rivosinc.com, Nelson Chu

Refer to commit, dff565fcca8137954d6ad571ef39f6aec5c0429c.  Theoretically,
assembler don't need to generate the pc-relative relocation and the refered
local .L symbol when relaxation is disabled.  The above commit improved the
pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
relocations.

Passed the gcc/binutils regressions of riscv-gnu-toolchain.

gas/
	* config/tc-riscv.c (md_apply_fix): Raise fixP->fx_done for all
	branch and jump relocations when -mno-relax.
---
 gas/config/tc-riscv.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index a4161420128..cbead954f09 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -4390,6 +4390,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 	  bfd_vma target = S_GET_VALUE (fixP->fx_addsy) + *valP;
 	  bfd_vma delta = target - md_pcrel_from (fixP);
 	  bfd_putl32 (bfd_getl32 (buf) | ENCODE_JTYPE_IMM (delta), buf);
+	  if (!riscv_opts.relax && S_IS_LOCAL (fixP->fx_addsy))
+	    fixP->fx_done = 1;
 	}
       break;
 
@@ -4400,6 +4402,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 	  bfd_vma target = S_GET_VALUE (fixP->fx_addsy) + *valP;
 	  bfd_vma delta = target - md_pcrel_from (fixP);
 	  bfd_putl32 (bfd_getl32 (buf) | ENCODE_BTYPE_IMM (delta), buf);
+	  if (!riscv_opts.relax && S_IS_LOCAL (fixP->fx_addsy))
+	    fixP->fx_done = 1;
 	}
       break;
 
@@ -4410,6 +4414,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 	  bfd_vma target = S_GET_VALUE (fixP->fx_addsy) + *valP;
 	  bfd_vma delta = target - md_pcrel_from (fixP);
 	  bfd_putl16 (bfd_getl16 (buf) | ENCODE_CBTYPE_IMM (delta), buf);
+	  if (!riscv_opts.relax && S_IS_LOCAL (fixP->fx_addsy))
+	    fixP->fx_done = 1;
 	}
       break;
 
@@ -4420,6 +4426,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
 	  bfd_vma target = S_GET_VALUE (fixP->fx_addsy) + *valP;
 	  bfd_vma delta = target - md_pcrel_from (fixP);
 	  bfd_putl16 (bfd_getl16 (buf) | ENCODE_CJTYPE_IMM (delta), buf);
+	  if (!riscv_opts.relax && S_IS_LOCAL (fixP->fx_addsy))
+	    fixP->fx_done = 1;
 	}
       break;
 
-- 
2.39.3 (Apple Git-145)


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

* Re: [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
  2024-01-29 13:17 [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax Nelson Chu
@ 2024-01-30 10:00 ` Andreas Schwab
  2024-01-30 11:55   ` Nelson Chu
  2024-02-19 14:34 ` Andreas Schwab
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2024-01-30 10:00 UTC (permalink / raw)
  To: Nelson Chu
  Cc: binutils, kito.cheng, jim.wilson.gcc, palmer, andrew,
	nelson.rivosinc.com

On Jan 29 2024, Nelson Chu wrote:

> Refer to commit, dff565fcca8137954d6ad571ef39f6aec5c0429c.  Theoretically,
> assembler don't need to generate the pc-relative relocation and the refered
> local .L symbol when relaxation is disabled.  The above commit improved the
> pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
> relocations.
>
> Passed the gcc/binutils regressions of riscv-gnu-toolchain.
>
> gas/
> 	* config/tc-riscv.c (md_apply_fix): Raise fixP->fx_done for all
> 	branch and jump relocations when -mno-relax.

Is this related to PR30591?

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
  2024-01-30 10:00 ` Andreas Schwab
@ 2024-01-30 11:55   ` Nelson Chu
  0 siblings, 0 replies; 6+ messages in thread
From: Nelson Chu @ 2024-01-30 11:55 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: binutils, kito.cheng, jim.wilson.gcc, palmer, andrew,
	nelson.rivosinc.com

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

On Tue, Jan 30, 2024 at 6:00 PM Andreas Schwab <schwab@suse.de> wrote:

> On Jan 29 2024, Nelson Chu wrote:
>
> > Refer to commit, dff565fcca8137954d6ad571ef39f6aec5c0429c.
> Theoretically,
> > assembler don't need to generate the pc-relative relocation and the
> refered
> > local .L symbol when relaxation is disabled.  The above commit improved
> the
> > pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
> > relocations.
> >
> > Passed the gcc/binutils regressions of riscv-gnu-toolchain.
> >
> > gas/
> >       * config/tc-riscv.c (md_apply_fix): Raise fixP->fx_done for all
> >       branch and jump relocations when -mno-relax.
>
> Is this related to PR30591?
>

Yeah, it seems like the same stuff :)

Thanks
Nelson

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

* Re: [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
  2024-01-29 13:17 [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax Nelson Chu
  2024-01-30 10:00 ` Andreas Schwab
@ 2024-02-19 14:34 ` Andreas Schwab
  2024-02-20  0:19   ` Nelson Chu
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2024-02-19 14:34 UTC (permalink / raw)
  To: Nelson Chu
  Cc: binutils, kito.cheng, jim.wilson.gcc, palmer, andrew,
	nelson.rivosinc.com

On Jan 29 2024, Nelson Chu wrote:

> Refer to commit, dff565fcca8137954d6ad571ef39f6aec5c0429c.  Theoretically,
> assembler don't need to generate the pc-relative relocation and the refered
> local .L symbol when relaxation is disabled.  The above commit improved the
> pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
> relocations.

This reduces the number of relocations for .text in the amdgpu kernel
module from 217597 to 101552.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

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

* Re: [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
  2024-02-19 14:34 ` Andreas Schwab
@ 2024-02-20  0:19   ` Nelson Chu
  2024-02-21  7:04     ` Nelson Chu
  0 siblings, 1 reply; 6+ messages in thread
From: Nelson Chu @ 2024-02-20  0:19 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: binutils, kito.cheng, jim.wilson.gcc, palmer, andrew,
	nelson.rivosinc.com

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]

Thanks for the information!  I will commit it before this week ;)

Thanks
Nelson

On Mon, Feb 19, 2024 at 10:35 PM Andreas Schwab <schwab@suse.de> wrote:

> On Jan 29 2024, Nelson Chu wrote:
>
> > Refer to commit, dff565fcca8137954d6ad571ef39f6aec5c0429c.
> Theoretically,
> > assembler don't need to generate the pc-relative relocation and the
> refered
> > local .L symbol when relaxation is disabled.  The above commit improved
> the
> > pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
> > relocations.
>
> This reduces the number of relocations for .text in the amdgpu kernel
> module from 217597 to 101552.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
>

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

* Re: [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax.
  2024-02-20  0:19   ` Nelson Chu
@ 2024-02-21  7:04     ` Nelson Chu
  0 siblings, 0 replies; 6+ messages in thread
From: Nelson Chu @ 2024-02-21  7:04 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: binutils, kito.cheng, jim.wilson.gcc, palmer, andrew

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

Committed :-)

Nelson

On Tue, Feb 20, 2024 at 8:19 AM Nelson Chu <nelson@rivosinc.com> wrote:

> Thanks for the information!  I will commit it before this week ;)
>
> Thanks
> Nelson
>
> On Mon, Feb 19, 2024 at 10:35 PM Andreas Schwab <schwab@suse.de> wrote:
>
>> On Jan 29 2024, Nelson Chu wrote:
>>
>> > Refer to commit, dff565fcca8137954d6ad571ef39f6aec5c0429c.
>> Theoretically,
>> > assembler don't need to generate the pc-relative relocation and the
>> refered
>> > local .L symbol when relaxation is disabled.  The above commit improved
>> the
>> > pcrel_hi/pcrel_lo relocations, and this commit improves branch and jump
>> > relocations.
>>
>> This reduces the number of relocations for .text in the amdgpu kernel
>> module from 217597 to 101552.
>>
>> --
>> Andreas Schwab, SUSE Labs, schwab@suse.de
>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
>> "And now for something completely different."
>>
>

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

end of thread, other threads:[~2024-02-21  7:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29 13:17 [PATCH] RISC-V: Don't generate branch/jump relocation if symbol is local when no-relax Nelson Chu
2024-01-30 10:00 ` Andreas Schwab
2024-01-30 11:55   ` Nelson Chu
2024-02-19 14:34 ` Andreas Schwab
2024-02-20  0:19   ` Nelson Chu
2024-02-21  7:04     ` Nelson Chu

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).