diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-05 20:48:31 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-05-05 20:48:31 +0000 |
commit | ecf58b9e3c4f0d1e0abc7aa7ce95dd42c674acee (patch) | |
tree | 3d61c9e465212640f0f0c91ba7426ddc92deb497 | |
parent | 2d57a6470181e7cc6396caae69e045cd0549d10e (diff) |
Implement a really simple DwarfSjLjException.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130947 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfException.h | 19 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp | 46 |
4 files changed, 68 insertions, 0 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 63bfa2f258..dad581b2d2 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -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; diff --git a/lib/CodeGen/AsmPrinter/CMakeLists.txt b/lib/CodeGen/AsmPrinter/CMakeLists.txt index d2be5525d7..bf80f5f070 100644 --- a/lib/CodeGen/AsmPrinter/CMakeLists.txt +++ b/lib/CodeGen/AsmPrinter/CMakeLists.txt @@ -8,6 +8,7 @@ add_llvm_library(LLVMAsmPrinter DwarfCompileUnit.cpp DwarfDebug.cpp DwarfException.cpp + DwarfSjLjException.cpp DwarfTableException.cpp OcamlGCPrinter.cpp ) diff --git a/lib/CodeGen/AsmPrinter/DwarfException.h b/lib/CodeGen/AsmPrinter/DwarfException.h index f11164122c..d212a63916 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.h +++ b/lib/CodeGen/AsmPrinter/DwarfException.h @@ -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 index 0000000000..4718d7118b --- /dev/null +++ b/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp @@ -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(); +} |