Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UnwindAssembly/x86] Add support for "lea imm(%ebp), %esp" pattern
Summary: 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. Reviewers: jasonmolenda, tberghammer Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D34750 llvm-svn: 306666
- Loading branch information
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters