Hi llvm-dev,
On a number of occations we've run into different versions of problems with our out-of-tree target when it comes to scheduling of stack pointer updates vs interrupts at unfortunate places.
Example:
If we allocate an object on the stack with alignment we get something like:
mv sp, r0
sub r0, 2, r0
and r0, 0xfffe, r0
mv r0, sp
and then there might follow an instruction storing to the allocated space:
store 42, r0
and further down a load from it
load r0, r1
The problem we've run into is that the store is scheduled before the update of sp:
mv sp, r0
sub r0, 2, r0
and r0, 0xfffe, r0
store 42, r0
mv r0, sp
This works well in most cases, but if we are unfortunate enough to trigger an interrupt after the store, but before the sp update, the interrupt code might overwrite the stuff that the store just wrote to the stack, so when we continue after the interrupt, the last load might read rubbish data.
The store is only depending on r0, but we would like to make sure that the actual move to sp is carried out before it too.
I've failed to see how other targets solve this kind of problem, I suppose we're not alone in facing this issue?
Regards,
Mikael