This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Disabling ICF for interrupt functions
- From: Alexander Monakov <amonakov at ispras dot ru>
- To: Jozef Lawrynowicz <jozef dot l at mittosystems dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 19 Jul 2019 16:32:21 +0300 (MSK)
- Subject: Re: [RFC] Disabling ICF for interrupt functions
- References: <20190719134511.3d9101e5@jozef-kubuntu>
On Fri, 19 Jul 2019, Jozef Lawrynowicz wrote:
> 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.
But ICF by creating an alias would be fine, correct? As I understand, the
real issue here is that gcc does not know how to correctly emit a call to
"interrupt" functions (because they have unusual ABI and exist basically to
have their address stored somewhere).
So I think the solution shouldn't be in disabling ICF altogether, but rather
in adding a way to recognize that a function has quasi-unknown ABI and thus
not directly callable (so any other optimization can see that it may not emit
a call to this function), then teaching ICF to check that when deciding to
fold by creating a wrapper.
(would it be possible to tell ICF that addresses of interrupt functions are
not significant so it can fold them by creating aliases?)
Alexander