public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [RFC] Disabling ICF for interrupt functions
@ 2019-07-19 12:45 Jozef Lawrynowicz
  2019-07-19 13:32 ` Alexander Monakov
  2019-07-26 17:39 ` Richard Sandiford
  0 siblings, 2 replies; 8+ messages in thread
From: Jozef Lawrynowicz @ 2019-07-19 12:45 UTC (permalink / raw)
  To: gcc

For MSP430, the folding of identical functions marked with the "interrupt"
attribute by -fipa-icf-functions results in wrong code being generated.
Interrupts have different calling conventions than regular functions, so
inserting a CALL from one identical interrupt to another is not correct and
will result in stack corruption.

I imagine there are other targets that also have different calling conventions
for interrupt functions compared to regular functions, and so folding them
would be undesirable.

Therefore, I would appreciate some feedback as to whether it would be welcomed
to fix this in a generic way or if I should just keep it MSP430 specific.

1. MSP430 specific
Add the "no_icf" attribute to functions marked with the "interrupt" attribute
when processing them in the backend.

2. Target Hook
Add a DEFHOOKPOD (e.g. TARGET_NO_INTERRUPT_ICF) which controls whether ICF is
disabled for functions with the interrupt attribute (in gcc/ipa-icf.c, where
"no_icf" attribute is processed).

3. Always on
Same as 2. but without the hook implementation - just check for the interrupt
attribute and disable ICF if it is present.

I'm personally leaning towards option 2, target hook, since other targets may
benefit from this.

Thanks,
Jozef

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

end of thread, other threads:[~2019-07-31 12:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 12:45 [RFC] Disabling ICF for interrupt functions Jozef Lawrynowicz
2019-07-19 13:32 ` Alexander Monakov
2019-07-22 17:01   ` Jozef Lawrynowicz
2019-07-22 18:50     ` Alexander Monakov
2019-07-26 17:39 ` Richard Sandiford
2019-07-30 13:41   ` Jozef Lawrynowicz
2019-07-31  9:50     ` Richard Biener
2019-07-31 12:22       ` Jozef Lawrynowicz

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