aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Utils/LowerInvoke.cpp
diff options
context:
space:
mode:
authorDuraid Madina <duraid@octopus.com.au>2006-09-04 06:21:35 +0000
committerDuraid Madina <duraid@octopus.com.au>2006-09-04 06:21:35 +0000
commit2a0013f59fb3b23010c0509fab8bf509eb30fb36 (patch)
tree5eeee3804055cf753a41fd33334eae94b65d6e9b /lib/Transforms/Utils/LowerInvoke.cpp
parent362b3680c1d8f92609ee37c4a6943c7a45f287cb (diff)
downloadexternal_llvm-2a0013f59fb3b23010c0509fab8bf509eb30fb36.zip
external_llvm-2a0013f59fb3b23010c0509fab8bf509eb30fb36.tar.gz
external_llvm-2a0013f59fb3b23010c0509fab8bf509eb30fb36.tar.bz2
add setJumpBufSize() and setJumpBufAlignment() to target-lowering.
Call these from your backend to enjoy setjmp/longjmp goodness, see lib/Target/IA64/IA64ISelLowering.cpp for an example git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30095 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LowerInvoke.cpp')
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 8702810..73d703b 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -45,6 +45,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Target/TargetLowering.h"
#include <csetjmp>
using namespace llvm;
@@ -67,9 +68,12 @@ namespace {
const Type *JBLinkTy;
GlobalVariable *JBListHead;
Function *SetJmpFn, *LongJmpFn;
+
+ // We peek in TLI to grab the target's jmp_buf size and alignment
+ const TargetLowering *TLI;
+
public:
- LowerInvoke(unsigned Size = 200, unsigned Align = 0) : JumpBufSize(Size),
- JumpBufAlign(Align) {}
+ LowerInvoke(const TargetLowering *tli = NULL) : TLI(tli) { }
bool doInitialization(Module &M);
bool runOnFunction(Function &F);
@@ -89,9 +93,6 @@ namespace {
void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
AllocaInst *InvokeNum, SwitchInst *CatchSwitch);
bool insertExpensiveEHSupport(Function &F);
-
- unsigned JumpBufSize;
- unsigned JumpBufAlign;
};
RegisterPass<LowerInvoke>
@@ -101,9 +102,8 @@ namespace {
const PassInfo *llvm::LowerInvokePassID = X.getPassInfo();
// Public Interface To the LowerInvoke pass.
-FunctionPass *llvm::createLowerInvokePass(unsigned JumpBufSize,
- unsigned JumpBufAlign) {
- return new LowerInvoke(JumpBufSize, JumpBufAlign);
+FunctionPass *llvm::createLowerInvokePass(const TargetLowering *TLI) {
+ return new LowerInvoke(TLI);
}
// doInitialization - Make sure that there is a prototype for abort in the
@@ -113,7 +113,7 @@ bool LowerInvoke::doInitialization(Module &M) {
AbortMessage = 0;
if (ExpensiveEHSupport) {
// Insert a type for the linked list of jump buffers.
- const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JumpBufSize);
+ const Type *JmpBufTy = ArrayType::get(VoidPtrTy, TLI->getJumpBufSize());
{ // The type is recursive, so use a type holder.
std::vector<const Type*> Elements;
@@ -453,7 +453,7 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// that needs to be restored on all exits from the function. This is an
// alloca because the value needs to be live across invokes.
AllocaInst *JmpBuf =
- new AllocaInst(JBLinkTy, 0, JumpBufAlign, "jblink", F.begin()->begin());
+ new AllocaInst(JBLinkTy, 0, TLI->getJumpBufAlignment(), "jblink", F.begin()->begin());
std::vector<Value*> Idx;
Idx.push_back(Constant::getNullValue(Type::IntTy));