]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AVR: Disable tree-switch-conversion per default.
authorGeorg-Johann Lay <avr@gjlay.de>
Sat, 6 Sep 2025 11:38:48 +0000 (13:38 +0200)
committerGeorg-Johann Lay <avr@gjlay.de>
Wed, 10 Sep 2025 20:44:45 +0000 (22:44 +0200)
There are at least two cases where tree-switch-conversion leads
to unpleasant resource allocation:

PR49857
    The lookup table lives in RAM.  This is the case for all
    devices that locate .rodata in RAM, which is for almost
    all AVR devices.

PR81540
    Code is bloated for 64-bit inputs.

As far as PR49857 is concerned, a target hook that may add an
address-space qualifier to the lookup table is the obvious
solution, though a respective patch has always been rejected by
global maintainers for non-technical reasons.

gcc/
PR target/81540
PR target/49857
* common/config/avr/avr-common.cc: Disable -ftree-switch-conversion.

(cherry picked from commit 912159d2b5429c3126756b56723dd4f32dd56bdd)

gcc/common/config/avr/avr-common.cc

index 2f874c5b81c7c822f3cb7a8c246905107577a518..cdbe58ad4a897422ec8291b15cb4b4f7eafea6ab 100644 (file)
 /* Implement TARGET_OPTION_OPTIMIZATION_TABLE.  */
 static const struct default_options avr_option_optimization_table[] =
   {
+    // The lookup table from tree-swicth-conversion.cc lives in .rodata
+    // and hence consumes RAM on almost all devices.  As PR49857 has
+    // been rejected several times for non-technical reasons, just
+    // disable -ftree-switch-conversion by default.  But even with PR49857
+    // in place there remains PR81540, which cannot be filtered out since
+    // the pass has no way to hook in.
+    { OPT_LEVELS_ALL, OPT_ftree_switch_conversion, NULL, 0 },
     // The only effect of -fcaller-saves might be that it triggers
     // a frame without need when it tries to be smart around calls.
     { OPT_LEVELS_ALL, OPT_fcaller_saves, NULL, 0 },