Generate Callee Saved Register (CSR) related cfi directives like .cfi_restore.
authorWei Mi <wmi@google.com>
Thu, 13 Feb 2020 17:23:27 +0000 (09:23 -0800)
committerWei Mi <wmi@google.com>
Wed, 4 Mar 2020 19:18:37 +0000 (11:18 -0800)
commit3c96d01d2e3de63304ca3429d349ec62ae2adef3
tree4fa9375416141af02c84ad8c0d515f2b6039e3b9
parentee9a3eba769787bd87ac47945508751dafa5a46b
Generate Callee Saved Register (CSR) related cfi directives like .cfi_restore.

https://reviews.llvm.org/D42848 only handled CFA related cfi directives but
didn't handle CSR related cfi. The patch adds the CSR part. Basically it reuses
the framework created in D42848. For each basicblock, the patch tracks which
CSR set have been saved at its CFG predecessors's exits, and compare the CSR
set with the set at its previous basicblock's exit (The previous block is the
block laid before the current block). If the saved CSR set at its previous
basicblock's exit is larger, .cfi_restore will be inserted.

The patch also generates proper .cfi_restore in epilogue to make sure the
saved CSR set is consistent for the incoming edges of each block.

Differential Revision: https://reviews.llvm.org/D74303
llvm/lib/CodeGen/CFIInstrInserter.cpp
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/lib/Target/X86/X86FrameLowering.h
llvm/test/CodeGen/X86/cfi-epilogue-with-return.mir [new file with mode: 0644]
llvm/test/CodeGen/X86/cfi-epilogue-without-return.mir [new file with mode: 0644]
llvm/test/CodeGen/X86/cfi-inserter-callee-save-register.mir [new file with mode: 0644]
llvm/test/CodeGen/X86/cfi-inserter-verify-inconsistent-csr.mir [new file with mode: 0644]