This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[RFC] Disabling ICF for interrupt functions
- From: Jozef Lawrynowicz <jozef dot l at mittosystems dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 19 Jul 2019 13:45:11 +0100
- Subject: [RFC] Disabling ICF for interrupt functions
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