[X86] Disable X86CallFrameOptimization on Darwin in presence of EH
authorFrederic Riss <friss@apple.com>
Thu, 8 Oct 2015 15:45:08 +0000 (15:45 +0000)
committerFrederic Riss <friss@apple.com>
Thu, 8 Oct 2015 15:45:08 +0000 (15:45 +0000)
We emit 1 compact unwind encoding per function, and this can’t represent
the varying stack pointer that will be generated by X86CallFrameOptimization.
Disable the optimization on Darwin.

(It might be possible to split the function into multiple ranges
and emit 1 compact unwind info per range. The compact unwind emission
code isn’t ready for that and this kind of info certainly isn’t
tested/used anywhere. It might be worth exploring this path if we want
to get the space savings at some point though)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249694 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86CallFrameOptimization.cpp
test/CodeGen/X86/push-cfi-obj.ll

index b1995694535265eb67027d40a0df3c8b6f501396..e3031b8946417744f75ffa3655c2d4164ad52ef7 100644 (file)
@@ -26,6 +26,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/IR/Function.h"
@@ -130,6 +131,11 @@ bool X86CallFrameOptimization::isLegal(MachineFunction &MF) {
   if (STI.is64Bit())
     return false;
 
+  // We can't encode multiple DW_CFA_GNU_args_size in the compact
+  // unwind encoding that Darwin uses.
+  if (STI.isTargetDarwin() && !MF.getMMI().getLandingPads().empty())
+    return false;
+
   // You would expect straight-line code between call-frame setup and
   // call-frame destroy. You would be wrong. There are circumstances (e.g.
   // CMOV_GR8 expansion of a select that feeds a function call!) where we can
index fcc18e28cf72069734253bc8b05a16d64918c713..43ab34e744bf9812fe2324106fe66f71ddd6e2a8 100644 (file)
@@ -1,4 +1,9 @@
 ; RUN: llc < %s -mtriple=i686-pc-linux -filetype=obj | llvm-readobj -s -sr -sd | FileCheck %s
+; RUN: llc < %s -mtriple=i686-darwin-macosx10.7 -filetype=obj | llvm-readobj -sections | FileCheck -check-prefix=DARWIN %s
+
+; On darwin, check that we manage to generate the compact unwind section
+; DARWIN: Name: __compact_unwind
+; DARWIN: Segment: __LD
 
 ; CHECK:         Index: 8
 ; CHECK-NEXT:    Name: .eh_frame (41)