Re: [PATCH 1/2] genopinit: Distribute generated code across multiple files

Kyrylo Tkachov <[email protected]> Tue, 4 Aug 2026 16:57:44 +0000
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>

> On 4 Aug 2026, at 18:26, Jeffrey Law <[email protected]> wrote=
:
>=20
>=20
>=20
> On 7/23/2026 7:20 AM, [email protected] wrote:
>> From: Kyrylo Tkachov <[email protected]>
>>=20
>> insn-opinit.cc contains large generated initialization functions with
>> thousands of target-feature expressions.  The single file is among the
>> slowest objects in every AArch64 bootstrap stage.
>>=20
>> Teach genopinit to accept repeatable -O output options, following genemi=
t and
>> genrecog.  Reuse the existing --with-insnemit-partitions count, while
>> preserving the default init-opinit.c output and -cFILE interface when -O=
 is not
>> used.  Collect and validate all output names before opening them, reject=
ing
>> duplicates, resolvable aliases, header collisions, and incompatible -c a=
nd -O
>> options.
>>=20
>> Keep shared lookup code and all helper declarations in the first output,=
 then
>> place helper definitions in the shortest output.  One-file output retain=
s the
>> historical static helper names.  Split output uses generator-private ext=
ernal
>> names for cross-file references.
>>=20
>> With the default ten AArch64 partitions, the largest part compiles about=
 90%
>> faster than the original single object.
>>=20
>> Bootstrapped and tested on aarch64-none-linux-gnu and x86_64-linux.
>> Ok for trunk?
>> Thanks,
>> Kyrill
>>=20
>> gcc/ChangeLog:
>>=20
>> * Makefile.in (INSNOPINIT_SPLITS_SEQ, INSNOPINIT_SEQ_SRC)
>> (INSNOPINIT_SEQ_TMP, INSNOPINIT_SEQ_O): New variables.
>> (OBJS): Replace insn-opinit.o with $(INSNOPINIT_SEQ_O).
>> (MOSTLYCLEANFILES): Add $(INSNOPINIT_SEQ_SRC), retaining the legacy
>> unnumbered source for cleanup.
>> (s-opinit): Generate and move numbered insn-opinit-N.cc files.  Stop if
>> moving an output fails.
>> * configure.ac (--with-insnemit-partitions): Mention genopinit outputs.
>> * configure: Regenerate.
>> * genopinit.cc (source_file_option, output_file_names, output_files):
>> New variables.
>> (handle_arg): Record and validate repeatable -O output names.
>> (main): Validate all output modes before opening files.  Preserve static
>> helper linkage for one output and distribute private split helpers.
>>=20
>> Signed-off-by: Kyrylo Tkachov <[email protected]>
> It'll be interesting to see if this improves the RISC-V build times too. =
 Robin fixed the worst of the offenders a while back, but we've got daily b=
uild data and if there's a meaningful improvement we should be able to see =
it.
>=20
> The only concern is the INSNOPINIT_SPLITS_SEQ is slightly different than =
the other _SEQ variables.    The others use:
>=20
> MATCH_SPLITS_SEQ =3D $(wordlist 1,$(NUM_MATCH_SPLITS),$(one_to_9999))
> INSNEMIT_SPLITS_SEQ =3D $(wordlist 1,$(NUM_INSNEMIT_SPLITS),$(one_to_9999=
))
> INSNRECOG_SPLITS_SEQ =3D $(wordlist 1,$(NUM_INSNEMIT_SPLITS),$(one_to_999=
9))
>=20
> Is there a reason you didn't use that form?

No particular reason, they both work the same in practice, I can change to =
use that form.
Ok with that change if testing passes?
Thanks,
Kyrill

>=20
> jeff