Shrink wrapping functions can improve performance for functions
when the stack is unused. However, all functions where value
live-ranges contain function calls are ineligible for shrink
- To avoid saving and restoring values across call-sites, LLVM
allocates values with live-ranges that cross call sites to
- If callee-saved registers are used, they must be
saved (usually in the function prolog)
- ShrinkWrapping scans from the beginning of the function prolog
to the first use of the stack. If a callee-saved register is
saved to the stack in the function prolog, ShrinkWrapping will
give up early.
To increase the applicability of ShrinkWrapping, this pass
identifies instances where a live-range straddling a call-site
prevents ShrinkWrapping, and splits the original function into a
stackless ShrinkWrappable stub that potentially makes a tail call
to the remainder of the function.
This transformation harms debuggability and consequently is not
suitable for lower -O levels.