[llvm-commits] [llvm] r49336 - /llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
Duncan Sands
baldrick at free.fr
Mon Apr 7 06:41:19 PDT 2008
Author: baldrick
Date: Mon Apr 7 08:41:19 2008
New Revision: 49336
URL: http://llvm.org/viewvc/llvm-project?rev=49336&view=rev
Log:
Use Intrinsic::getDeclaration to get hold of
intrinsics. Fix up the argument type (should
be i8*, was an array*).
Modified:
llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=49336&r1=49335&r2=49336&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Mon Apr 7 08:41:19 2008
@@ -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 @@
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 @@
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 @@
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);
More information about the llvm-commits
mailing list