The existing implementation of the personality for legacy IBM xlclang++ compiler generated code passes the address of exception object in r14 for the landing pad to retrieve with a call to __xlc_exception_handle(). This clobbers the content of r14 in user code (and potentially, when running cleanup actions, the address of another exception object being passed). This patch changes to use the stack slot reserved for compilers to pass the address. It has been confirmed that xlclang++-generated code does not use this slot. The following is the AIX stack frame layout.
Low Address 32-bit 64-bit SP----> +---------------------------------------+ | back chain to caller | 0 0 +---------------------------------------+ | saved CR | 4 8 (8-11) +---------------------------------------+ | saved LR | 8 16 +---------------------------------------+ | reserved for compilers | 12 24 <======= +---------------------------------------+ | reserved for binders | 16 32 +---------------------------------------+ | saved TOC pointer | 20 40 +---------------------------------------+ | Parameter save area (+padding*) (P) | 24 48 +---------------------------------------+ | Alloca space (A) | 24+P etc. +---------------------------------------+ | Local variable space (L) | 24+P+A +---------------------------------------+ | Float/int conversion temporary (X) | 24+P+A+L +---------------------------------------+ | Save area for AltiVec registers (W) | 24+P+A+L+X +---------------------------------------+ | AltiVec alignment padding (Y) | 24+P+A+L+X+W +---------------------------------------+ | Save area for VRSAVE register (Z) | 24+P+A+L+X+W+Y +---------------------------------------+ | Save area for GP registers (G) | 24+P+A+X+L+X+W+Y+Z +---------------------------------------+ | Save area for FP registers (F) | 24+P+A+X+L+X+W+Y+Z+G +---------------------------------------+ old SP->| back chain to caller's caller | +---------------------------------------+ | saved CR | 4 8 (8-11) +---------------------------------------+ | saved LR | 8 16 +---------------------------------------+ High Address
Suggestion: rename dummy to force_a_stackframe or similar. The comments are helpful but the name makes it really hard for anyone to erroneously remove it, noting that you also have tests that would fail if anyone did but the more layers of defense and readability the better.