]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Reduce rs_align_code memory for small alignments
authorAlan Modra <amodra@gmail.com>
Tue, 27 May 2025 01:10:59 +0000 (10:40 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 30 May 2025 00:46:19 +0000 (10:16 +0930)
commit5e5f37ed004c5be00e830a2a49f629fa4d252370
treefe0aa076e01419a6e0296f0d42cf3cdecee37cae
parentd4de8fe856337509ce9c13a490d1ac07aeb516f2
Reduce rs_align_code memory for small alignments

On x86, MAX_MEM_FOR_RS_ALIGN_CODE is 35, when the most common
alignment is 2**3 or 2**4, where the max memory required for the
alignment nops is 7 and 15 bytes respectively.  So there is some
memory wasted since commit 83d94ae428b1.  It's not a large amount,
especially considering that frag overhead on x86_46 is 144 bytes,
but even so I'd rather not be blamed for increasing gas memory usage.

So to reduce the memory we'd like to take the alignment into
consideration when initialising an rs_align_code frag.  The only
difficulty here is start_bundle making an rs_align_code frag with an
alignment of zero initially, then later increasing the alignment.  We
change that to use the bundle alignment when setting up the frag.  I
think that is sufficient as bundle_align_p2 can't change in the middle
of a start_bundle/finish_bundle sequence.

I haven't modified any targets other than x86 in this patch.  Most
won't benefit much due to using fairly small MAX_MEM_FOR_RS_ALIGN_CODE.

* read.c (start_bundle): Create rs_align_code frag with
bundle_align_p2 alignment, then set to zero alignment.
(finish_bundle): Adjust comment.
* frags.c (MAX_MEM_FOR_RS_ALIGN_CODE): Pass p2align and max
to macro.
* config/tc-i386.h (HANDLE_ALIGN): Assert that max_bytes is
sufficient for nop padding.
(max_mem_for_rs_align_code): New inline function.
(MAX_MEM_FOR_RS_ALIGN_CODE): Use it.
* config/tc-aarch64.h: Adjust MAX_MEM_FOR_RS_ALIGN_CODE.
* config/tc-alpha.h: Likewise.
* config/tc-arc.h: Likewise.
* config/tc-arm.h: Likewise.
* config/tc-epiphany.h: Likewise.
* config/tc-frv.h: Likewise.
* config/tc-ia64.h: Likewise.
* config/tc-kvx.h: Likewise.
* config/tc-loongarch.h: Likewise.
* config/tc-m32r.h: Likewise.
* config/tc-metag.h: Likewise.
* config/tc-mips.h: Likewise.
* config/tc-nds32.h: Likewise.
* config/tc-ppc.h: Likewise.
* config/tc-riscv.h: Likewise.
* config/tc-rl78.h: Likewise.
* config/tc-rx.h: Likewise.
* config/tc-score.h: Likewise.
* config/tc-sh.h: Likewise.
* config/tc-sparc.h: Likewise.
* config/tc-spu.h: Likewise.
* config/tc-tilegx.h: Likewise.
* config/tc-tilepro.h: Likewise.
* config/tc-visium.h: Likewise.
* config/tc-xtensa.h: Likewise.
28 files changed:
gas/config/tc-aarch64.h
gas/config/tc-alpha.h
gas/config/tc-arc.h
gas/config/tc-arm.h
gas/config/tc-epiphany.h
gas/config/tc-frv.h
gas/config/tc-i386.h
gas/config/tc-ia64.h
gas/config/tc-kvx.h
gas/config/tc-loongarch.h
gas/config/tc-m32r.h
gas/config/tc-metag.h
gas/config/tc-mips.h
gas/config/tc-nds32.h
gas/config/tc-ppc.h
gas/config/tc-riscv.h
gas/config/tc-rl78.h
gas/config/tc-rx.h
gas/config/tc-score.h
gas/config/tc-sh.h
gas/config/tc-sparc.h
gas/config/tc-spu.h
gas/config/tc-tilegx.h
gas/config/tc-tilepro.h
gas/config/tc-visium.h
gas/config/tc-xtensa.h
gas/frags.c
gas/read.c