i#1621 AArch64 CC opt: Make analyze_callee_save_reg more conservative. (#2497)
i#1621 AArch64 CC opt: Make analyze_callee_save_reg more conservative. (#2497)

The current behavior is to walk from the bottom instruction up to the
current top instruction to find instructions that pop registers. This
is too permissive and may remove instructions not used to save/restore
callee-saved registers, e.g. spills of local variables to the stack.

This patches switches to a more conservative approach which requires
callee-saved registers to be popped in reverse order they have been pushed.

Both LLVM and GCC commonly use this pattern to save/restore callee-saved
registers on AArch64, but they might use different patterns if that is
more efficient. I think we should use this conservative approach
for now, and maybe make it more permissive once we have clean call
inlining implemented on AArch64 and solid test coverage.

This patch has no effect unless opt_cleancall > 1. I will put up a
patch implementing clean call inlining for AArch64 soon and this patch
will include a test case for analyze_callee_save_reg.
AmesianX/dynamorio,AmesianX/dynamorio,AmesianX/dynamorio,AmesianX/dynamorio,AmesianX/dynamorio