[Lldb-commits] [PATCH] D34750: [UnwindAssembly/x86] Add support for "lea imm(%ebp), %esp" pattern
Pavel Labath via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Jun 28 07:09:34 PDT 2017
labath created this revision.
The instruction pattern:
and $-16, %esp
sub $imm, %esp
lea imm(%ebp), %esp
appears when the compiler is realigning the stack (for example in
main(), or almost everywhere with -mstackrealign switch). The "and"
instruction is very difficult to model, but that's not necessary, as
these frames are always %ebp-based (the compiler also needs a way to
restore the original %esp). Therefore the plans we were generating for
these function were almost correct already. The only place we were doing
it wrong were the last instructions of the epilogue (usually just
"ret"), where we had to revert to %esp-based unwinding, as the %ebp had
been popped already.
This was wrong because our "distance of esp from cfa" counter had picked
up the "sub" instruction (and incremented the counter) but it had not
seen that the register was reset by the "lea" instruction.
This patch fixes that shortcoming, and adds a test for handling
functions like this.
I have not been able to tickle the compiler into producing a 64-bit
function with this pattern, but I don't see a reason why it couldn't
produce it, if it chose to, so I add a x86_64 test as well.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6085 bytes
Desc: not available
More information about the lldb-commits