Skip to content

Commit 03ffa79

Browse files
committed
X86: loosen an overly aggressive MachO assertion
We would assert that the FP setup CFI used esp/rsp always. This held up in practice when the code was generated from IR. However, with the integrated assembler, it is possible to have the input be user specified assembly. In such a case, we cannot assume that the function implementation has a compact unwind representation. Loosen the assertion into a check and bail if we cannot represent the frame pointer in the compact unwinding. Addresses PR30453! llvm-svn: 281986
1 parent c8e7c98 commit 03ffa79

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,12 @@ class DarwinX86AsmBackend : public X86AsmBackend {
546546
// .cfi_def_cfa_register %rbp
547547
//
548548
HasFP = true;
549-
assert(MRI.getLLVMRegNum(Inst.getRegister(), true) ==
550-
(Is64Bit ? X86::RBP : X86::EBP) && "Invalid frame pointer!");
549+
550+
// If the frame pointer is other than esp/rsp, we do not have a way to
551+
// generate a compact unwinding representation, so bail out.
552+
if (MRI.getLLVMRegNum(Inst.getRegister(), true) !=
553+
(Is64Bit ? X86::RBP : X86::EBP))
554+
return 0;
551555

552556
// Reset the counts.
553557
memset(SavedRegs, 0, sizeof(SavedRegs));

llvm/test/MC/X86/fp-setup-macho.s

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: llvm-mc -triple x86_64-apple-macho -filetype obj -o - %s | llvm-readobj -sections | FileCheck %s
2+
3+
_label:
4+
.cfi_startproc
5+
.cfi_def_cfa_register rsp
6+
.cfi_endproc
7+
8+
// CHECK: Section {
9+
// CHECK: Name: __eh_frame
10+
// CHECK: }
11+

0 commit comments

Comments
 (0)