[PATCH] Propagate -fno-unwind-tables to EHABI

Renato Golin renato.golin at linaro.org
Wed Mar 19 03:44:50 PDT 2014


  Changing semantics to match Logan's proposal. We'll have to re-visit the function attributes to make a better model here, as it's a bit muddled. But that's for another thread/patch.

Hi keith.walker.arm, asl, logan, rafael,

http://llvm-reviews.chandlerc.com/D3079

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D3079?vs=7834&id=7942#toc

Files:
  include/llvm/CodeGen/AsmPrinter.h
  lib/CodeGen/AsmPrinter/ARMException.cpp
  lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  lib/CodeGen/AsmPrinter/DwarfException.h
  lib/CodeGen/AsmPrinter/Win64Exception.cpp
  lib/Target/ARM/ARMAsmPrinter.cpp

Index: include/llvm/CodeGen/AsmPrinter.h
===================================================================
--- include/llvm/CodeGen/AsmPrinter.h
+++ include/llvm/CodeGen/AsmPrinter.h
@@ -219,7 +219,8 @@
     };
     CFIMoveType needsCFIMoves();
 
-    bool needsSEHMoves();
+    /// True if the function needs unwinding of Type provided
+    bool needsEHMoves(unsigned EHType);
 
     /// EmitConstantPool - Print to the current output stream assembly
     /// representations of the constants in the constant pool MCP. This is
Index: lib/CodeGen/AsmPrinter/ARMException.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/ARMException.cpp
+++ lib/CodeGen/AsmPrinter/ARMException.cpp
@@ -38,6 +38,7 @@
 
 ARMException::ARMException(AsmPrinter *A)
   : DwarfException(A),
+    shouldEmitEH(false),
     shouldEmitCFI(false) {}
 
 ARMException::~ARMException() {}
@@ -57,10 +58,16 @@
 /// beginFunction - Gather pre-function exception information. Assumes it's
 /// being emitted immediately after the function entry point.
 void ARMException::beginFunction(const MachineFunction *MF) {
-  getTargetStreamer().emitFnStart();
-  if (Asm->MF->getFunction()->needsUnwindTableEntry())
-    Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
-                                                  Asm->getFunctionNumber()));
+  // FIXME: Change Function::needsUnwindTableEntry() and update other targets
+  shouldEmitEH = Asm->needsEHMoves(ExceptionHandling::ARM) ||
+                 Asm->MF->getFunction()->doesNotThrow();
+
+  if (shouldEmitEH) {
+    getTargetStreamer().emitFnStart();
+    if (Asm->MF->getFunction()->needsUnwindTableEntry())
+      Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
+                                                    Asm->getFunctionNumber()));
+  }
   // See if we need call frame info.
   AsmPrinter::CFIMoveType MoveType = Asm->needsCFIMoves();
   assert(MoveType != AsmPrinter::CFI_M_EH &&
@@ -77,8 +84,11 @@
   if (shouldEmitCFI)
     Asm->OutStreamer.EmitCFIEndProc();
 
+  if (!shouldEmitEH)
+    return;
+
   ARMTargetStreamer &ATS = getTargetStreamer();
-  if (!Asm->MF->getFunction()->needsUnwindTableEntry())
+  if (Asm->MF->getFunction()->doesNotThrow())
     ATS.emitCantUnwind();
   else {
     Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -681,22 +681,21 @@
   return true;
 }
 
+bool AsmPrinter::needsEHMoves(unsigned EHType) {
+  return (MAI->getExceptionHandlingType() == EHType &&
+      MF->getFunction()->needsUnwindTableEntry());
+}
+
 AsmPrinter::CFIMoveType AsmPrinter::needsCFIMoves() {
-  if (MAI->getExceptionHandlingType() == ExceptionHandling::DwarfCFI &&
-      MF->getFunction()->needsUnwindTableEntry())
+  if (needsEHMoves(ExceptionHandling::DwarfCFI))
     return CFI_M_EH;
 
   if (MMI->hasDebugInfo())
     return CFI_M_Debug;
 
   return CFI_M_None;
 }
 
-bool AsmPrinter::needsSEHMoves() {
-  return MAI->getExceptionHandlingType() == ExceptionHandling::Win64 &&
-    MF->getFunction()->needsUnwindTableEntry();
-}
-
 void AsmPrinter::emitCFIInstruction(const MachineInstr &MI) {
   ExceptionHandling::ExceptionsType ExceptionHandlingType =
       MAI->getExceptionHandlingType();
Index: lib/CodeGen/AsmPrinter/DwarfException.h
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfException.h
+++ lib/CodeGen/AsmPrinter/DwarfException.h
@@ -183,6 +183,9 @@
   void EmitTypeInfos(unsigned TTypeEncoding) override;
   ARMTargetStreamer &getTargetStreamer();
 
+  /// shouldEmitEH - Per-function flag to indicate if frame EH info
+  /// should be emitted.
+  bool shouldEmitEH;
   /// shouldEmitCFI - Per-function flag to indicate if frame CFI info
   /// should be emitted.
   bool shouldEmitCFI;
Index: lib/CodeGen/AsmPrinter/Win64Exception.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/Win64Exception.cpp
+++ lib/CodeGen/AsmPrinter/Win64Exception.cpp
@@ -57,7 +57,7 @@
   // If any landing pads survive, we need an EH table.
   bool hasLandingPads = !MMI->getLandingPads().empty();
 
-  shouldEmitMoves = Asm->needsSEHMoves();
+  shouldEmitMoves = Asm->needsEHMoves(ExceptionHandling::Win64);
 
   const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
   unsigned PerEncoding = TLOF.getPersonalityEncoding();
Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp
+++ lib/Target/ARM/ARMAsmPrinter.cpp
@@ -907,6 +907,9 @@
   assert(MI->getFlag(MachineInstr::FrameSetup) &&
       "Only instruction which are involved into frame setup code are allowed");
 
+  if (!MF->getFunction()->needsUnwindTableEntry())
+    return;
+
   MCTargetStreamer &TS = *OutStreamer.getTargetStreamer();
   ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
   const MachineFunction &MF = *MI->getParent()->getParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3079.2.patch
Type: text/x-patch
Size: 5170 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140319/3edb0df3/attachment.bin>


More information about the llvm-commits mailing list