[PATCH] D66013: [X86] Emit correct unwind info for split-stack prologue

Cherry Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 9 07:20:31 PDT 2019


cherry created this revision.
cherry added a reviewer: thanm.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When -fsplit-stack is used, the function prologue contains two additional blocks: the first checks the stack bound, and the second calls __morestack. The second block may be laid out later in the function body, as it is an unlikely block. However, it is still the prologue, where we haven't pushed callee-save registers and the frame pointer (if used) yet. Currently we didn't take this into account when generating the unwind info. The CFIInstrInserter pass does take care of the return address correctly, but it does not handle the frame pointer and callee-save registers.

This change fixes this by generating .cfi_restore for saved registers to reset them as of the function entry. We also generate .cfi_remember_state and .cfi_restore_state before and after this block, so that the blocks before and after it are not affected no matter where this block is laid out. As it is specific to split-stack, we do it in X86FrameLowering, instead of teaching CFIInstrInserter about all the saved register stuff (which is generally not needed).

Added basic support of .cfi_remember_state and .cfi_restore_state support to CFIInstrInserter and AsmPrinter.


Repository:
  rL LLVM

https://reviews.llvm.org/D66013

Files:
  lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
  lib/CodeGen/CFIInstrInserter.cpp
  lib/Target/X86/X86FrameLowering.cpp
  test/CodeGen/X86/segmented-stacks.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66013.214377.patch
Type: text/x-patch
Size: 7107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190809/fc6e8ce5/attachment.bin>


More information about the llvm-commits mailing list