diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-02-19 03:13:40 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-02-19 03:13:40 +0000 |
commit | bd1b8c088963e7f7ea7417e8a4fe5cabdaf500ad (patch) | |
tree | 663732422dcb55b54e07eb13b0fa5010f1a24903 /llvm/lib/CodeGen | |
parent | ac07270828e6d34acbae9584789e8709a18b258a (diff) | |
download | bcm5719-llvm-bd1b8c088963e7f7ea7417e8a4fe5cabdaf500ad.tar.gz bcm5719-llvm-bd1b8c088963e7f7ea7417e8a4fe5cabdaf500ad.zip |
[SjLjEHPrepare] Don't grab pointers to functions in doInitialization
Certain optimization passes (like globaldce) can prune function
declaration that SjLjEHPrepare assumed would exit when it'd
runOnFunction.
This fixes PR26669.
llvm-svn: 261303
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SjLjEHPrepare.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/SjLjEHPrepare.cpp b/llvm/lib/CodeGen/SjLjEHPrepare.cpp index 144366185dc..f610e9c9914 100644 --- a/llvm/lib/CodeGen/SjLjEHPrepare.cpp +++ b/llvm/lib/CodeGen/SjLjEHPrepare.cpp @@ -55,7 +55,6 @@ class SjLjEHPrepare : public FunctionPass { Constant *StackAddrFn; Constant *StackRestoreFn; Constant *LSDAAddrFn; - Value *PersonalityFn; Constant *CallSiteFn; Constant *FuncCtxFn; AllocaInst *FuncCtx; @@ -103,21 +102,6 @@ bool SjLjEHPrepare::doInitialization(Module &M) { VoidPtrTy, // __lsda doubleUnderJBufTy, // __jbuf nullptr); - RegisterFn = M.getOrInsertFunction( - "_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()), - PointerType::getUnqual(FunctionContextTy), (Type *)nullptr); - UnregisterFn = M.getOrInsertFunction( - "_Unwind_SjLj_Unregister", Type::getVoidTy(M.getContext()), - PointerType::getUnqual(FunctionContextTy), (Type *)nullptr); - FrameAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::frameaddress); - StackAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::stacksave); - StackRestoreFn = Intrinsic::getDeclaration(&M, Intrinsic::stackrestore); - BuiltinSetupDispatchFn = - Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_setup_dispatch); - LSDAAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_lsda); - CallSiteFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_callsite); - FuncCtxFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_functioncontext); - PersonalityFn = nullptr; return true; } @@ -226,8 +210,7 @@ Value *SjLjEHPrepare::setupFunctionContext(Function &F, // Personality function IRBuilder<> Builder(EntryBB->getTerminator()); - if (!PersonalityFn) - PersonalityFn = F.getPersonalityFn(); + Value *PersonalityFn = F.getPersonalityFn(); Value *PersonalityFieldPtr = Builder.CreateConstGEP2_32( FunctionContextTy, FuncCtx, 0, 3, "pers_fn_gep"); Builder.CreateStore( @@ -490,6 +473,22 @@ bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) { } bool SjLjEHPrepare::runOnFunction(Function &F) { + Module &M = *F.getParent(); + RegisterFn = M.getOrInsertFunction( + "_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()), + PointerType::getUnqual(FunctionContextTy), (Type *)nullptr); + UnregisterFn = M.getOrInsertFunction( + "_Unwind_SjLj_Unregister", Type::getVoidTy(M.getContext()), + PointerType::getUnqual(FunctionContextTy), (Type *)nullptr); + FrameAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::frameaddress); + StackAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::stacksave); + StackRestoreFn = Intrinsic::getDeclaration(&M, Intrinsic::stackrestore); + BuiltinSetupDispatchFn = + Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_setup_dispatch); + LSDAAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_lsda); + CallSiteFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_callsite); + FuncCtxFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_functioncontext); + bool Res = setupEntryBlockAndCallSites(F); return Res; } |