Implement a really simple DwarfSjLjException.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 May 2011 20:48:31 +0000 (20:48 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 5 May 2011 20:48:31 +0000 (20:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130947 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/AsmPrinter/CMakeLists.txt
lib/CodeGen/AsmPrinter/DwarfException.h
lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp [new file with mode: 0644]

index 63bfa2f258f910693226c25d9c5794ea01a8ca13..dad581b2d294d99127833f4d4d414c5f7c4d2476 100644 (file)
@@ -193,6 +193,8 @@ bool AsmPrinter::doInitialization(Module &M) {
   case ExceptionHandling::None:
     return false;
   case ExceptionHandling::SjLj:
+    DE = new DwarfSjLjException(this);
+    return false;
   case ExceptionHandling::DwarfTable:
     DE = new DwarfTableException(this);
     return false;
index d2be5525d7d0e3d3aa278a3b7918635ce4f6c42a..bf80f5f070bb8997224b2d77c454249b7604b14c 100644 (file)
@@ -8,6 +8,7 @@ add_llvm_library(LLVMAsmPrinter
   DwarfCompileUnit.cpp
   DwarfDebug.cpp
   DwarfException.cpp
+  DwarfSjLjException.cpp
   DwarfTableException.cpp
   OcamlGCPrinter.cpp
   )
index f11164122cc4d02941796d3219e79ab237f7daf1..d212a63916e66c5ebaeafcb69c04e490c4d1954e 100644 (file)
@@ -238,6 +238,25 @@ public:
   virtual void EndFunction();
 };
 
+class DwarfSjLjException : public DwarfException {
+public:
+  //===--------------------------------------------------------------------===//
+  // Main entry points.
+  //
+  DwarfSjLjException(AsmPrinter *A);
+  virtual ~DwarfSjLjException();
+
+  /// EndModule - Emit all exception information that should come after the
+  /// content.
+  virtual void EndModule();
+
+  /// BeginFunction - Gather pre-function exception information.  Assumes being
+  /// emitted immediately after the function entry point.
+  virtual void BeginFunction(const MachineFunction *MF);
+
+  /// EndFunction - Gather and emit post-function exception information.
+  virtual void EndFunction();
+};
 
 class ARMException : public DwarfException {
   /// shouldEmitTable - Per-function flag to indicate if EH tables should
diff --git a/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp b/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp
new file mode 100644 (file)
index 0000000..4718d71
--- /dev/null
@@ -0,0 +1,46 @@
+//===-- CodeGen/AsmPrinter/DwarfTableException.cpp - Dwarf Exception Impl --==//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a simple implementation of DwarfException that just produces
+// the exception table for use with SjLj.
+//
+//===----------------------------------------------------------------------===//
+
+#include "DwarfException.h"
+#include "llvm/CodeGen/MachineLocation.h"
+#include "llvm/CodeGen/MachineModuleInfo.h"
+using namespace llvm;
+
+DwarfSjLjException::DwarfSjLjException(AsmPrinter *A) : DwarfException(A) {
+}
+
+DwarfSjLjException::~DwarfSjLjException() {}
+
+/// EndModule - Emit all exception information that should come after the
+/// content.
+void DwarfSjLjException::EndModule() {
+}
+
+/// BeginFunction - Gather pre-function exception information. Assumes it's
+/// being emitted immediately after the function entry point.
+void DwarfSjLjException::BeginFunction(const MachineFunction *MF) {
+}
+
+/// EndFunction - Gather and emit post-function exception information.
+///
+void DwarfSjLjException::EndFunction() {
+  // Record if this personality index uses a landing pad.
+  bool HasLandingPad = !MMI->getLandingPads().empty();
+
+  // Map all labels and get rid of any dead landing pads.
+  MMI->TidyLandingPads();
+
+  if (HasLandingPad)
+    EmitExceptionTable();
+}