summaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/LowerInvoke.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2008-04-07 13:41:19 +0000
committerDuncan Sands <baldrick@free.fr>2008-04-07 13:41:19 +0000
commita122043c2c0d33828cb2e897b43b5d858a74db4e (patch)
tree7225c676555f074c42d9e157064c286153229725 /lib/Transforms/Utils/LowerInvoke.cpp
parent79ab3e801480e6412c064a3fb15a79a8cab13efc (diff)
downloadllvm-a122043c2c0d33828cb2e897b43b5d858a74db4e.tar.gz
llvm-a122043c2c0d33828cb2e897b43b5d858a74db4e.tar.bz2
llvm-a122043c2c0d33828cb2e897b43b5d858a74db4e.tar.xz
Use Intrinsic::getDeclaration to get hold of
intrinsics. Fix up the argument type (should be i8*, was an array*). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/LowerInvoke.cpp')
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp
index 7f85b10af4..884f4fce91 100644
--- a/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/lib/Transforms/Utils/LowerInvoke.cpp
@@ -39,6 +39,7 @@
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
+#include "llvm/Intrinsics.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -142,12 +143,8 @@ bool LowerInvoke::doInitialization(Module &M) {
Constant::getNullValue(PtrJBList),
"llvm.sjljeh.jblist", &M);
}
- SetJmpFn = M.getOrInsertFunction("llvm.setjmp", Type::Int32Ty,
- PointerType::getUnqual(JmpBufTy),
- (Type *)0);
- LongJmpFn = M.getOrInsertFunction("llvm.longjmp", Type::VoidTy,
- PointerType::getUnqual(JmpBufTy),
- Type::Int32Ty, (Type *)0);
+ SetJmpFn = Intrinsic::getDeclaration(&M, Intrinsic::setjmp);
+ LongJmpFn = Intrinsic::getDeclaration(&M, Intrinsic::longjmp);
}
// We need the 'write' and 'abort' functions for both models.
@@ -505,9 +502,11 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
Value *JmpBufPtr = GetElementPtrInst::Create(JmpBuf, Idx.begin(), Idx.end(),
"TheJmpBuf",
EntryBB->getTerminator());
+ JmpBufPtr = new BitCastInst(JmpBufPtr, PointerType::getUnqual(Type::Int8Ty),
+ "tmp", EntryBB->getTerminator());
Value *SJRet = CallInst::Create(SetJmpFn, JmpBufPtr, "sjret",
EntryBB->getTerminator());
-
+
// Compare the return value to zero.
Value *IsNormal = new ICmpInst(ICmpInst::ICMP_EQ, SJRet,
Constant::getNullValue(SJRet->getType()),
@@ -555,6 +554,8 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
Idx.push_back(ConstantInt::get(Type::Int32Ty, 0));
Idx[0] = GetElementPtrInst::Create(BufPtr, Idx.begin(), Idx.end(), "JmpBuf",
UnwindBlock);
+ Idx[0] = new BitCastInst(Idx[0], PointerType::getUnqual(Type::Int8Ty),
+ "tmp", UnwindBlock);
Idx[1] = ConstantInt::get(Type::Int32Ty, 1);
CallInst::Create(LongJmpFn, Idx.begin(), Idx.end(), "", UnwindBlock);
new UnreachableInst(UnwindBlock);