[llvm] r249694 - [X86] Disable X86CallFrameOptimization on Darwin in presence of EH

Frederic Riss via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 8 08:45:09 PDT 2015


Author: friss
Date: Thu Oct  8 10:45:08 2015
New Revision: 249694

URL: http://llvm.org/viewvc/llvm-project?rev=249694&view=rev
Log:
[X86] Disable X86CallFrameOptimization on Darwin in presence of EH

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)

Modified:
    llvm/trunk/lib/Target/X86/X86CallFrameOptimization.cpp
    llvm/trunk/test/CodeGen/X86/push-cfi-obj.ll

Modified: llvm/trunk/lib/Target/X86/X86CallFrameOptimization.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CallFrameOptimization.cpp?rev=249694&r1=249693&r2=249694&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86CallFrameOptimization.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86CallFrameOptimization.cpp Thu Oct  8 10:45:08 2015
@@ -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(M
   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

Modified: llvm/trunk/test/CodeGen/X86/push-cfi-obj.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/push-cfi-obj.ll?rev=249694&r1=249693&r2=249694&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/push-cfi-obj.ll (original)
+++ llvm/trunk/test/CodeGen/X86/push-cfi-obj.ll Thu Oct  8 10:45:08 2015
@@ -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)




More information about the llvm-commits mailing list