]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
avr: Fix ICE on optimize attribute.
authorSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Mon, 19 Jun 2023 06:29:12 +0000 (11:59 +0530)
committerSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Mon, 19 Jun 2023 06:29:12 +0000 (11:59 +0530)
This commit fixes an ICE when an optimize attribute changes the prevailing
optimization level.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105069 describes the
same ICE for the sh target, where the fix was to enable save/restore of
target specific options modified via TARGET_OPTIMIZATION_TABLE hook.

For the AVR target, mgas-isr-prologues and -mmain-is-OS_task are those
target specific options. As they enable generation of more optimal code,
this commit adds the Optimization option property to those option records,
and that fixes the ICE.

Regression run shows no regressions, and >100 new PASSes.

PR target/110086

gcc/ChangeLog:

* config/avr/avr.opt (mgas-isr-prologues, mmain-is-OS_task):
Add Optimization option property.

gcc/testsuite/ChangeLog:

* gcc.target/avr/pr110086.c: New test.

gcc/config/avr/avr.opt
gcc/testsuite/gcc.target/avr/pr110086.c [new file with mode: 0644]

index f62d7467eb7acf2b716c06a8b28df2f9d83c0872..5a0b46539aa9ad1e706aa498ce46fa5e6a74a4c4 100644 (file)
@@ -27,7 +27,7 @@ Target RejectNegative Joined Var(avr_mmcu) MissingArgError(missing device or arc
 -mmcu=MCU      Select the target MCU.
 
 mgas-isr-prologues
-Target Var(avr_gasisr_prologues) UInteger Init(0)
+Target Var(avr_gasisr_prologues) UInteger Init(0) Optimization 
 Allow usage of __gcc_isr pseudo instructions in ISR prologues and epilogues.
 
 mn-flash=
@@ -65,7 +65,7 @@ Target Joined RejectNegative UInteger Var(avr_branch_cost) Init(0)
 Set the branch costs for conditional branch instructions.  Reasonable values are small, non-negative integers.  The default branch cost is 0.
 
 mmain-is-OS_task
-Target Mask(MAIN_IS_OS_TASK)
+Target Mask(MAIN_IS_OS_TASK) Optimization
 Treat main as if it had attribute OS_task.
 
 morder1
diff --git a/gcc/testsuite/gcc.target/avr/pr110086.c b/gcc/testsuite/gcc.target/avr/pr110086.c
new file mode 100644 (file)
index 0000000..6b97620
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+void __attribute__((optimize("O0"))) foo() {
+}