aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LowerInvoke.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2005-11-05 09:21:28 +0000
committerNate Begeman <natebegeman@mac.com>2005-11-05 09:21:28 +0000
commit14b0529532904b9e5a1e34526b4a3209f3e5bc62 (patch)
tree43e99ef7bb1cdfbb2828eea5617026f6d426e787 /lib/Transforms/Utils/LowerInvoke.cpp
parentae4664a9f2da955c9d2a3f38b28f0a4395851ace (diff)
Add support alignment of allocation instructions.
Add support for specifying alignment and size of setjmp jmpbufs. No targets currently do anything with this information, nor is it presrved in the bytecode representation. That's coming up next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24196 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LowerInvoke.cpp')
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 7039a4b7e1..be706c3ef8 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -67,6 +67,8 @@ namespace {
GlobalVariable *JBListHead;
Function *SetJmpFn, *LongJmpFn;
public:
+ LowerInvoke(unsigned Size = 200, unsigned Align = 0) : JumpBufSize(Size),
+ JumpBufAlign(Align) {}
bool doInitialization(Module &M);
bool runOnFunction(Function &F);
@@ -78,6 +80,9 @@ namespace {
void rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
AllocaInst *InvokeNum, SwitchInst *CatchSwitch);
bool insertExpensiveEHSupport(Function &F);
+
+ unsigned JumpBufSize;
+ unsigned JumpBufAlign;
};
RegisterOpt<LowerInvoke>
@@ -87,7 +92,10 @@ namespace {
const PassInfo *llvm::LowerInvokePassID = X.getPassInfo();
// Public Interface To the LowerInvoke pass.
-FunctionPass *llvm::createLowerInvokePass() { return new LowerInvoke(); }
+FunctionPass *llvm::createLowerInvokePass(unsigned JumpBufSize,
+ unsigned JumpBufAlign) {
+ return new LowerInvoke(JumpBufSize, JumpBufAlign);
+}
// doInitialization - Make sure that there is a prototype for abort in the
// current module.
@@ -95,13 +103,8 @@ bool LowerInvoke::doInitialization(Module &M) {
const Type *VoidPtrTy = PointerType::get(Type::SByteTy);
AbortMessage = 0;
if (ExpensiveEHSupport) {
- // Insert a type for the linked list of jump buffers. Unfortunately, we
- // don't know the size of the target's setjmp buffer, so we make a guess.
- // If this guess turns out to be too small, bad stuff could happen.
- unsigned JmpBufSize = 200; // PPC has 192 words
- assert(sizeof(jmp_buf) <= JmpBufSize*sizeof(void*) &&
- "LowerInvoke doesn't know about targets with jmp_buf size > 200 words!");
- const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JmpBufSize);
+ // Insert a type for the linked list of jump buffers.
+ const Type *JmpBufTy = ArrayType::get(VoidPtrTy, JumpBufSize);
{ // The type is recursive, so use a type holder.
std::vector<const Type*> Elements;
@@ -441,7 +444,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, "jblink", F.begin()->begin());
+ new AllocaInst(JBLinkTy, 0, JumpBufAlign, "jblink", F.begin()->begin());
std::vector<Value*> Idx;
Idx.push_back(Constant::getNullValue(Type::IntTy));