From 1b747ad8a0694b86e8d98a8b9a05ddfe74ec0cd3 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Tue, 11 Aug 2009 00:09:57 +0000 Subject: SjLj based exception handling unwinding support. This patch is nasty, brutish and short. Well, it's kinda short. Definitely nasty and brutish. The front-end generates the register/unregister calls into the SjLj runtime, call-site indices and landing pad dispatch. The back end fills in the LSDA with the call-site information provided by the front end. Catch blocks are not yet implemented. Built on Darwin and verified no llvm-core "make check" regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78625 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineFunction.h | 45 ++++++++++++++++++++++++++++++++ include/llvm/CodeGen/SelectionDAGNodes.h | 4 +++ 2 files changed, 49 insertions(+) (limited to 'include/llvm/CodeGen') diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 57c946c789..f30cb821c1 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -18,6 +18,7 @@ #ifndef LLVM_CODEGEN_MACHINEFUNCTION_H #define LLVM_CODEGEN_MACHINEFUNCTION_H +#include #include "llvm/ADT/ilist.h" #include "llvm/Support/DebugLoc.h" #include "llvm/CodeGen/Dump.h" @@ -114,6 +115,15 @@ class MachineFunction { // The alignment of the function. unsigned Alignment; + // The currently active call_site value + unsigned CallSiteIndex; + + // The largest call_site value encountered + unsigned MaxCallSiteIndex; + + // Call sites mapped to corresponding landing pads + std::map LandingPadCallSiteIndexMap; + public: MachineFunction(Function *Fn, const TargetMachine &TM); ~MachineFunction(); @@ -159,6 +169,41 @@ public: /// void setAlignment(unsigned A) { Alignment = A; } + /// getCallSiteIndex() - Get the current call site index + /// + unsigned getCallSiteIndex() { return CallSiteIndex; } + + /// setCallSiteIndex() - Set the current call site index + /// + void setCallSiteIndex(unsigned Idx) { + CallSiteIndex = Idx; + if (CallSiteIndex > MaxCallSiteIndex) + MaxCallSiteIndex = CallSiteIndex; + } + + /// getMaxCallSiteIndex() - Get the largest call site index issued + /// + unsigned getMaxCallSiteIndex() { return MaxCallSiteIndex; } + + /// setCallSiteIndexLandingPad() - Map the call site to a landing pad + /// + void setLandingPadCallSiteIndex(MachineBasicBlock *LandingPad, + unsigned CallSite) { + LandingPadCallSiteIndexMap[LandingPad] = CallSite; + } + + /// getCallSiteIndexLandingPad() - Get landing pad for the call site index + /// + unsigned getLandingPadCallSiteIndex(MachineBasicBlock *LandingPad) { + return LandingPadCallSiteIndexMap[LandingPad]; + } + + /// getCallSiteCount() - Get the count of call site entries + /// + unsigned getCallSiteCount() { + return LandingPadCallSiteIndexMap.size(); + } + /// MachineFunctionInfo - Keep track of various per-function pieces of /// information for backends that would like to do so. /// diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index bbb1f3bd90..7229463d4e 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -121,6 +121,10 @@ namespace ISD { // address of the exception block on entry to an landing pad block. EXCEPTIONADDR, + // RESULT, OUTCHAIN = LSDAADDR(INCHAIN) - This node represents the + // address of the Language Specific Data Area for the enclosing function. + LSDAADDR, + // RESULT, OUTCHAIN = EHSELECTION(INCHAIN, EXCEPTION) - This node represents // the selection index of the exception thrown. EHSELECTION, -- cgit v1.2.3-70-g09d2