public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR110086] avr: Fix ICE on optimize attribute
@ 2023-06-02  9:53 SenthilKumar.Selvaraj
  2023-06-05  5:57 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: SenthilKumar.Selvaraj @ 2023-06-02  9:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: chertykov

Hi,

This patch fixes an ICE when an optimize attribute changes the prevailing
optimization level.

I found https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105069 describing 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 patch adds the Optimization option property to those option records,
and that fixes the ICE.

Regression run shows no regressions, and >100 new PASSes.
Ok to commit to master?

Regards
Senthil


		PR 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.

diff --git gcc/config/avr/avr.opt gcc/config/avr/avr.opt
index f62d746..5a0b465 100644
--- gcc/config/avr/avr.opt
+++ gcc/config/avr/avr.opt
@@ -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 gcc/testsuite/gcc.target/avr/pr110086.c gcc/testsuite/gcc.target/avr/pr110086.c
new file mode 100644
index 0000000..6b97620
--- /dev/null
+++ gcc/testsuite/gcc.target/avr/pr110086.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+void __attribute__((optimize("O0"))) foo(void) {
+}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH, PR110086] avr: Fix ICE on optimize attribute
  2023-06-02  9:53 [PATCH, PR110086] avr: Fix ICE on optimize attribute SenthilKumar.Selvaraj
@ 2023-06-05  5:57 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2023-06-05  5:57 UTC (permalink / raw)
  To: SenthilKumar.Selvaraj; +Cc: gcc-patches, chertykov

On Fri, Jun 2, 2023 at 11:54 AM SenthilKumar.Selvaraj--- via
Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> This patch fixes an ICE when an optimize attribute changes the prevailing
> optimization level.
>
> I found https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105069 describing 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 patch adds the Optimization option property to those option records,
> and that fixes the ICE.
>
> Regression run shows no regressions, and >100 new PASSes.
> Ok to commit to master?

LGTM

Richard.

> Regards
> Senthil
>
>
>                 PR 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.
>
> diff --git gcc/config/avr/avr.opt gcc/config/avr/avr.opt
> index f62d746..5a0b465 100644
> --- gcc/config/avr/avr.opt
> +++ gcc/config/avr/avr.opt
> @@ -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 gcc/testsuite/gcc.target/avr/pr110086.c gcc/testsuite/gcc.target/avr/pr110086.c
> new file mode 100644
> index 0000000..6b97620
> --- /dev/null
> +++ gcc/testsuite/gcc.target/avr/pr110086.c
> @@ -0,0 +1,5 @@
> +/* { dg-do compile } */
> +/* { dg-options "-Os" } */
> +
> +void __attribute__((optimize("O0"))) foo(void) {
> +}

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-05  5:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-02  9:53 [PATCH, PR110086] avr: Fix ICE on optimize attribute SenthilKumar.Selvaraj
2023-06-05  5:57 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).