diff options
author | Jim Grosbach <grosbach@apple.com> | 2010-10-19 23:27:08 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2010-10-19 23:27:08 +0000 |
commit | bbdc5d2ef94c65d729b5144799af9d9bc0a643b7 (patch) | |
tree | e8c3b8099f699fb02e6151637e86de34ad6a02c0 /llvm/lib/CodeGen/SjLjEHPrepare.cpp | |
parent | 913c4fa15b6808b38453e90ea2269807a24defd6 (diff) | |
download | bcm5719-llvm-bbdc5d2ef94c65d729b5144799af9d9bc0a643b7.tar.gz bcm5719-llvm-bbdc5d2ef94c65d729b5144799af9d9bc0a643b7.zip |
Add a pre-dispatch SjLj EH hook on the unwind edge for targets to do any
setup they require. Use this for ARM/Darwin to rematerialize the base
pointer from the frame pointer when required. rdar://8564268
llvm-svn: 116879
Diffstat (limited to 'llvm/lib/CodeGen/SjLjEHPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SjLjEHPrepare.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp index b637980f885..1f6a5c4ea03 100644 --- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp +++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp @@ -53,6 +53,7 @@ namespace { Constant *SelectorFn; Constant *ExceptionFn; Constant *CallSiteFn; + Constant *DispatchSetupFn; Value *CallSite; public: @@ -116,6 +117,8 @@ bool SjLjEHPass::doInitialization(Module &M) { SelectorFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_selector); ExceptionFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_exception); CallSiteFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_callsite); + DispatchSetupFn + = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_dispatch_setup); PersonalityFn = 0; return true; @@ -438,9 +441,17 @@ bool SjLjEHPass::insertSjLjEHSupport(Function &F) { BasicBlock *DispatchBlock = BasicBlock::Create(F.getContext(), "eh.sjlj.setjmp.catch", &F); - // Insert a load in the Catch block, and a switch on its value. By default, - // we go to a block that just does an unwind (which is the correct action - // for a standard call). + // Add a call to dispatch_setup at the start of the dispatch block. This + // is expanded to any target-specific setup that needs to be done. + Value *SetupArg = + CastInst::Create(Instruction::BitCast, FunctionContext, + Type::getInt8PtrTy(F.getContext()), "", + DispatchBlock); + CallInst::Create(DispatchSetupFn, SetupArg, "", DispatchBlock); + + // Insert a load of the callsite in the dispatch block, and a switch on + // its value. By default, we go to a block that just does an unwind + // (which is the correct action for a standard call). BasicBlock *UnwindBlock = BasicBlock::Create(F.getContext(), "unwindbb", &F); Unwinds.push_back(new UnwindInst(F.getContext(), UnwindBlock)); |