On 11/4/26 9:20 PM, Kito Cheng wrote:
This patch adds the framework to fix errata for specific cores.
- riscv-errata.def lists the errata. Each one has a -mfix-NAME option.
- RISCV_CORE_ERRATUM in riscv-cores.def lists the errata of a core.
- --with-errata=LIST turns on workarounds by default.
A workaround is on if -mfix-NAME is given. If neither -mfix-NAME nor
-mno-fix-NAME is given, it is on if the -mcpu core has the erratum or the
erratum is in --with-errata. -mtune has no effect.
Functions with different errata are not inlined into each other.
gcc/ChangeLog:
* config.gcc (riscv*-*-*): Handle --with-errata.
* config/riscv/riscv-cores.def (RISCV_CORE_ERRATUM): New.
* config/riscv/riscv-errata.def: New file.
* config/riscv/riscv-opts.h (enum riscv_erratum): New.
(RISCV_ERRATUM_MASK, RISCV_ERRATUM_P): New.
* config/riscv/riscv.cc (riscv_errata): New variable.
(riscv_cpu_errata): New function.
(riscv_default_errata): New function.
(riscv_resolve_errata): New function.
(riscv_can_inline_p): Do not inline functions with different errata.
(riscv_override_options_internal): Set riscv_errata.
* config/riscv/riscv.h (riscv_errata): Declare.
* doc/install.texi (--with-errata): Document.
Sashiko noted that if you use -mcpu=native and happen to be on a design
with an errata in this table that workaround won't take effect. The
claim is opts->x_riscv_cpu_string will be NULL in that case.
Sashiko also complained about an LTO issue.
https://gcc.sashiko.dev/#/patchset/20261105042032.1545001-1-kito.cheng%40sifive.com
So the series is OK once you review those findings from Sashiko and take
the action you think is most appropriate (which can include declaring
the Sashiko concerns false positives).
Jeff