mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-15 09:33:39 +00:00
Generic cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141050 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d974ea22a5
commit
da7e6a9c88
@ -638,7 +638,7 @@ bool SjLjEHPass::insertSjLjEHSupport(Function &F) {
|
|||||||
Type::getInt8PtrTy(F.getContext()), "",
|
Type::getInt8PtrTy(F.getContext()), "",
|
||||||
EntryBB->getTerminator());
|
EntryBB->getTerminator());
|
||||||
Value *DispatchVal = CallInst::Create(BuiltinSetjmpFn, SetjmpArg,
|
Value *DispatchVal = CallInst::Create(BuiltinSetjmpFn, SetjmpArg,
|
||||||
"dispatch",
|
"",
|
||||||
EntryBB->getTerminator());
|
EntryBB->getTerminator());
|
||||||
|
|
||||||
// Add a call to dispatch_setup after the setjmp call. This is expanded to any
|
// Add a call to dispatch_setup after the setjmp call. This is expanded to any
|
||||||
@ -780,9 +780,8 @@ setupFunctionContext(Function &F, ArrayRef<LandingPadInst*> LPads) {
|
|||||||
|
|
||||||
// LSDA address
|
// LSDA address
|
||||||
Idxs[1] = ConstantInt::get(Int32Ty, 4);
|
Idxs[1] = ConstantInt::get(Int32Ty, 4);
|
||||||
Value *LSDAFieldPtr =
|
Value *LSDAFieldPtr = GetElementPtrInst::Create(FuncCtx, Idxs, "lsda_gep",
|
||||||
GetElementPtrInst::Create(FuncCtx, Idxs, "lsda_gep",
|
EntryBB->getTerminator());
|
||||||
EntryBB->getTerminator());
|
|
||||||
Value *LSDA = CallInst::Create(LSDAAddrFn, "lsda_addr",
|
Value *LSDA = CallInst::Create(LSDAAddrFn, "lsda_addr",
|
||||||
EntryBB->getTerminator());
|
EntryBB->getTerminator());
|
||||||
new StoreInst(LSDA, LSDAFieldPtr, true, EntryBB->getTerminator());
|
new StoreInst(LSDA, LSDAFieldPtr, true, EntryBB->getTerminator());
|
||||||
@ -819,15 +818,13 @@ bool SjLjEHPass::setupEntryBlockAndCallSites(Function &F) {
|
|||||||
|
|
||||||
// Get a reference to the jump buffer.
|
// Get a reference to the jump buffer.
|
||||||
Idxs[1] = ConstantInt::get(Int32Ty, 5);
|
Idxs[1] = ConstantInt::get(Int32Ty, 5);
|
||||||
Value *JBufPtr =
|
Value *JBufPtr = GetElementPtrInst::Create(FuncCtx, Idxs, "jbuf_gep",
|
||||||
GetElementPtrInst::Create(FuncCtx, Idxs, "jbuf_gep",
|
EntryBB->getTerminator());
|
||||||
EntryBB->getTerminator());
|
|
||||||
|
|
||||||
// Save the frame pointer.
|
// Save the frame pointer.
|
||||||
Idxs[1] = ConstantInt::get(Int32Ty, 0);
|
Idxs[1] = ConstantInt::get(Int32Ty, 0);
|
||||||
Value *FramePtr =
|
Value *FramePtr = GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep",
|
||||||
GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep",
|
EntryBB->getTerminator());
|
||||||
EntryBB->getTerminator());
|
|
||||||
|
|
||||||
Value *Val = CallInst::Create(FrameAddrFn,
|
Value *Val = CallInst::Create(FrameAddrFn,
|
||||||
ConstantInt::get(Int32Ty, 0),
|
ConstantInt::get(Int32Ty, 0),
|
||||||
@ -837,26 +834,23 @@ bool SjLjEHPass::setupEntryBlockAndCallSites(Function &F) {
|
|||||||
|
|
||||||
// Save the stack pointer.
|
// Save the stack pointer.
|
||||||
Idxs[1] = ConstantInt::get(Int32Ty, 2);
|
Idxs[1] = ConstantInt::get(Int32Ty, 2);
|
||||||
Value *StackPtr =
|
Value *StackPtr = GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_sp_gep",
|
||||||
GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_sp_gep",
|
EntryBB->getTerminator());
|
||||||
EntryBB->getTerminator());
|
|
||||||
|
|
||||||
Val = CallInst::Create(StackAddrFn, "sp", EntryBB->getTerminator());
|
Val = CallInst::Create(StackAddrFn, "sp", EntryBB->getTerminator());
|
||||||
new StoreInst(Val, StackPtr, true, EntryBB->getTerminator());
|
new StoreInst(Val, StackPtr, true, EntryBB->getTerminator());
|
||||||
|
|
||||||
// Call the setjmp instrinsic. It fills in the rest of the jmpbuf.
|
// Call the setjmp instrinsic. It fills in the rest of the jmpbuf.
|
||||||
Value *SetjmpArg =
|
Value *SetjmpArg = CastInst::Create(Instruction::BitCast, JBufPtr,
|
||||||
CastInst::Create(Instruction::BitCast, JBufPtr,
|
Type::getInt8PtrTy(F.getContext()), "",
|
||||||
Type::getInt8PtrTy(F.getContext()), "",
|
EntryBB->getTerminator());
|
||||||
EntryBB->getTerminator());
|
|
||||||
CallInst::Create(BuiltinSetjmpFn, SetjmpArg, "", EntryBB->getTerminator());
|
CallInst::Create(BuiltinSetjmpFn, SetjmpArg, "", EntryBB->getTerminator());
|
||||||
|
|
||||||
// Store a pointer to the function context so that the back-end will know
|
// Store a pointer to the function context so that the back-end will know
|
||||||
// where to look for it.
|
// where to look for it.
|
||||||
Value *FuncCtxArg =
|
Value *FuncCtxArg = CastInst::Create(Instruction::BitCast, FuncCtx,
|
||||||
CastInst::Create(Instruction::BitCast, FuncCtx,
|
Type::getInt8PtrTy(F.getContext()), "",
|
||||||
Type::getInt8PtrTy(F.getContext()), "",
|
EntryBB->getTerminator());
|
||||||
EntryBB->getTerminator());
|
|
||||||
CallInst::Create(FuncCtxFn, FuncCtxArg, "", EntryBB->getTerminator());
|
CallInst::Create(FuncCtxFn, FuncCtxArg, "", EntryBB->getTerminator());
|
||||||
|
|
||||||
// At this point, we are all set up, update the invoke instructions to mark
|
// At this point, we are all set up, update the invoke instructions to mark
|
||||||
@ -877,7 +871,7 @@ bool SjLjEHPass::setupEntryBlockAndCallSites(Function &F) {
|
|||||||
// created for this function and any unexpected exceptions thrown will go
|
// created for this function and any unexpected exceptions thrown will go
|
||||||
// directly to the caller's context, which is what we want anyway, so no need
|
// directly to the caller's context, which is what we want anyway, so no need
|
||||||
// to do anything here.
|
// to do anything here.
|
||||||
for (Function::iterator BB = F.begin(), E = F.end(); ++BB != E;) {
|
for (Function::iterator BB = F.begin(), E = F.end(); ++BB != E;)
|
||||||
for (BasicBlock::iterator I = BB->begin(), end = BB->end(); I != end; ++I)
|
for (BasicBlock::iterator I = BB->begin(), end = BB->end(); I != end; ++I)
|
||||||
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
if (CallInst *CI = dyn_cast<CallInst>(I)) {
|
||||||
if (!CI->doesNotThrow())
|
if (!CI->doesNotThrow())
|
||||||
@ -885,7 +879,6 @@ bool SjLjEHPass::setupEntryBlockAndCallSites(Function &F) {
|
|||||||
} else if (ResumeInst *RI = dyn_cast<ResumeInst>(I)) {
|
} else if (ResumeInst *RI = dyn_cast<ResumeInst>(I)) {
|
||||||
insertCallSiteStore(RI, -1, CallSite);
|
insertCallSiteStore(RI, -1, CallSite);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Register the function context and make sure it's known to not throw
|
// Register the function context and make sure it's known to not throw
|
||||||
CallInst *Register = CallInst::Create(RegisterFn, FuncCtx, "",
|
CallInst *Register = CallInst::Create(RegisterFn, FuncCtx, "",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user