[llvm] r281986 - X86: loosen an overly aggressive MachO assertion

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 20 10:05:04 PDT 2016


Author: compnerd
Date: Tue Sep 20 12:05:04 2016
New Revision: 281986

URL: http://llvm.org/viewvc/llvm-project?rev=281986&view=rev
Log:
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!

Added:
    llvm/trunk/test/MC/X86/fp-setup-macho.s
Modified:
    llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp?rev=281986&r1=281985&r2=281986&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp Tue Sep 20 12:05:04 2016
@@ -546,8 +546,12 @@ protected:
         //     .cfi_def_cfa_register %rbp
         //
         HasFP = true;
-        assert(MRI.getLLVMRegNum(Inst.getRegister(), true) ==
-               (Is64Bit ? X86::RBP : X86::EBP) && "Invalid frame pointer!");
+
+        // If the frame pointer is other than esp/rsp, we do not have a way to
+        // generate a compact unwinding representation, so bail out.
+        if (MRI.getLLVMRegNum(Inst.getRegister(), true) !=
+            (Is64Bit ? X86::RBP : X86::EBP))
+          return 0;
 
         // Reset the counts.
         memset(SavedRegs, 0, sizeof(SavedRegs));

Added: llvm/trunk/test/MC/X86/fp-setup-macho.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/fp-setup-macho.s?rev=281986&view=auto
==============================================================================
--- llvm/trunk/test/MC/X86/fp-setup-macho.s (added)
+++ llvm/trunk/test/MC/X86/fp-setup-macho.s Tue Sep 20 12:05:04 2016
@@ -0,0 +1,11 @@
+// RUN: llvm-mc -triple x86_64-apple-macho -filetype obj -o - %s | llvm-readobj -sections | FileCheck %s
+
+_label:
+	.cfi_startproc
+	.cfi_def_cfa_register rsp
+	.cfi_endproc
+
+// CHECK: Section {
+// CHECK:   Name: __eh_frame
+// CHECK: }
+




More information about the llvm-commits mailing list