On little endian targets prior to Power9, we spill vector registers using a
swapping store (i.e. stdxvd2x saves the vector with the two doublewords in
big endian order regardless of endianness). This is generally not a problem
since we restore them using the corresponding swapping load (lxvd2x). However
if the restore is done by the unwinder, the vector register contains data in
the incorrect order.
This patch fixes that by using Altivec loads/stores for vector saves and
restores in PEI (which keep the order correct) under those specific conditions:
- Little endian target
- EH aware function
- Subtarget prior to Power9 (which has non-swapping loads/stores)
nit:
This condition here in spillCalleeSavedRegisters needs to be identical to the one in restoreCalleeSavedRegisters. To avoid possible future bugs I would create a function to test for this and call it in both places. That would avoid a situation where someone adds a condition here and forgets to add it to restoreCalleeSavedRegisters.
Something like?