[X86][Darwin] Emit compact-unwind for register-sized stack adjustments
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Tue, 8 Jan 2019 13:53:15 +0000 (13:53 +0000)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Tue, 8 Jan 2019 13:53:15 +0000 (13:53 +0000)
commit7a6d7672c164ec466ad37bcf5928680e1ce49ce4
tree79e889f49de4462f7e9685470bae38b4d177ce07
parentf605e825219bd14d35a2fa4796137acfc20f4215
[X86][Darwin] Emit compact-unwind for register-sized stack adjustments

For stack frames on the size of a register in x86, a code size optimization
emits "push rax/eax" instead of "sub" for stack allocation. For example:

foo:
  .cfi_startproc
BB#0:
  pushq %rax
Ltmp0:
  .cfi_def_cfa_offset 16
  ...
  .cfi_endproc

However, we are falling back to DWARF in this case because we cannot
encode %rax as a saved register.

This requirement is wrong, since we don't care about the contents of
%rax, it is the equivalent of a sub.

In order to specify that we care about the contents of %rax, we would
need a .cfi_offset %rax, <offset>.

It's also overzealous in the case where there are pushes for callee saved
registers followed by a "push rax/eax" instead of "sub", in which case we should
also be able to encode the callee saved regs and everything else using compact
unwind.

Patch authored by Bruno Cardoso Lopes.

Differential Revision: https://reviews.llvm.org/D13793

llvm-svn: 350623
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
llvm/test/MC/X86/compact-unwind.s