In order to make sure the stack point is right through the EH region,
we also need to restore stack pointer from the frame pointer if we
don't preserve stack space within prologue/epilogue for outgoing variables,
normally it's just checking the variable sized object is present or not
is enough, but we also don't preserve that at prologue/epilogue when
have vector objects in stack.
Example to show what happened:
try { sp adjust for outgoing args. // 1. Sp changed. func_call // 2. Exception raised sp restore // Oh, not restored } catch { // 3. And now we are here. } // 4. Prepare to return!, restore return address from stack, but...sp is wrong. // 5. Screw up!
I assume that the exceptional path doesn't execute the add sp, sp, 32 after call _Z3fooiiiiiiiiiiPi@plt, instead we directly land to .LBB0_2: # %lpad. If this is th case, it does leaves the stack unaligned.
However, the expansion of !hasReservedCallFrame(MF) results in checking hasFP(MF) && hasRVVFrameObject(MF).
Isn't this an issue that happens irrespective of vectors and it is caused by having a fp? E.g. when using something like -fno-omit-frame-pointer.