[RFC] Disabling ICF for interrupt functions
Alexander Monakov
amonakov@ispras.ru
Fri Jul 19 13:32:00 GMT 2019
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
More information about the Gcc
mailing list