SjLjEHPrepare.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. //===- SjLjEHPrepare.cpp - Eliminate Invoke & Unwind instructions ---------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This transformation is designed for use by code generators which use SjLj
  10. // based exception handling.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #include "llvm/ADT/SetVector.h"
  14. #include "llvm/ADT/SmallPtrSet.h"
  15. #include "llvm/ADT/SmallVector.h"
  16. #include "llvm/ADT/Statistic.h"
  17. #include "llvm/CodeGen/Passes.h"
  18. #include "llvm/IR/Constants.h"
  19. #include "llvm/IR/DataLayout.h"
  20. #include "llvm/IR/DerivedTypes.h"
  21. #include "llvm/IR/IRBuilder.h"
  22. #include "llvm/IR/Instructions.h"
  23. #include "llvm/IR/Intrinsics.h"
  24. #include "llvm/IR/Module.h"
  25. #include "llvm/InitializePasses.h"
  26. #include "llvm/Pass.h"
  27. #include "llvm/Support/Debug.h"
  28. #include "llvm/Support/raw_ostream.h"
  29. #include "llvm/Target/TargetMachine.h"
  30. #include "llvm/Transforms/Utils/Local.h"
  31. using namespace llvm;
  32. #define DEBUG_TYPE "sjljehprepare"
  33. STATISTIC(NumInvokes, "Number of invokes replaced");
  34. STATISTIC(NumSpilled, "Number of registers live across unwind edges");
  35. namespace {
  36. class SjLjEHPrepare : public FunctionPass {
  37. IntegerType *DataTy;
  38. Type *doubleUnderDataTy;
  39. Type *doubleUnderJBufTy;
  40. Type *FunctionContextTy;
  41. FunctionCallee RegisterFn;
  42. FunctionCallee UnregisterFn;
  43. Function *BuiltinSetupDispatchFn;
  44. Function *FrameAddrFn;
  45. Function *StackAddrFn;
  46. Function *StackRestoreFn;
  47. Function *LSDAAddrFn;
  48. Function *CallSiteFn;
  49. Function *FuncCtxFn;
  50. AllocaInst *FuncCtx;
  51. const TargetMachine *TM;
  52. public:
  53. static char ID; // Pass identification, replacement for typeid
  54. explicit SjLjEHPrepare(const TargetMachine *TM = nullptr)
  55. : FunctionPass(ID), TM(TM) {}
  56. bool doInitialization(Module &M) override;
  57. bool runOnFunction(Function &F) override;
  58. void getAnalysisUsage(AnalysisUsage &AU) const override {}
  59. StringRef getPassName() const override {
  60. return "SJLJ Exception Handling preparation";
  61. }
  62. private:
  63. bool setupEntryBlockAndCallSites(Function &F);
  64. void substituteLPadValues(LandingPadInst *LPI, Value *ExnVal, Value *SelVal);
  65. Value *setupFunctionContext(Function &F, ArrayRef<LandingPadInst *> LPads);
  66. void lowerIncomingArguments(Function &F);
  67. void lowerAcrossUnwindEdges(Function &F, ArrayRef<InvokeInst *> Invokes);
  68. void insertCallSiteStore(Instruction *I, int Number);
  69. };
  70. } // end anonymous namespace
  71. char SjLjEHPrepare::ID = 0;
  72. INITIALIZE_PASS(SjLjEHPrepare, DEBUG_TYPE, "Prepare SjLj exceptions",
  73. false, false)
  74. // Public Interface To the SjLjEHPrepare pass.
  75. FunctionPass *llvm::createSjLjEHPreparePass(const TargetMachine *TM) {
  76. return new SjLjEHPrepare(TM);
  77. }
  78. // doInitialization - Set up decalarations and types needed to process
  79. // exceptions.
  80. bool SjLjEHPrepare::doInitialization(Module &M) {
  81. // Build the function context structure.
  82. // builtin_setjmp uses a five word jbuf
  83. Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext());
  84. unsigned DataBits =
  85. TM ? TM->getSjLjDataSize() : TargetMachine::DefaultSjLjDataSize;
  86. DataTy = Type::getIntNTy(M.getContext(), DataBits);
  87. doubleUnderDataTy = ArrayType::get(DataTy, 4);
  88. doubleUnderJBufTy = ArrayType::get(VoidPtrTy, 5);
  89. FunctionContextTy = StructType::get(VoidPtrTy, // __prev
  90. DataTy, // call_site
  91. doubleUnderDataTy, // __data
  92. VoidPtrTy, // __personality
  93. VoidPtrTy, // __lsda
  94. doubleUnderJBufTy // __jbuf
  95. );
  96. return true;
  97. }
  98. /// insertCallSiteStore - Insert a store of the call-site value to the
  99. /// function context
  100. void SjLjEHPrepare::insertCallSiteStore(Instruction *I, int Number) {
  101. IRBuilder<> Builder(I);
  102. // Get a reference to the call_site field.
  103. Type *Int32Ty = Type::getInt32Ty(I->getContext());
  104. Value *Zero = ConstantInt::get(Int32Ty, 0);
  105. Value *One = ConstantInt::get(Int32Ty, 1);
  106. Value *Idxs[2] = { Zero, One };
  107. Value *CallSite =
  108. Builder.CreateGEP(FunctionContextTy, FuncCtx, Idxs, "call_site");
  109. // Insert a store of the call-site number
  110. ConstantInt *CallSiteNoC = ConstantInt::get(DataTy, Number);
  111. Builder.CreateStore(CallSiteNoC, CallSite, true /*volatile*/);
  112. }
  113. /// MarkBlocksLiveIn - Insert BB and all of its predecessors into LiveBBs until
  114. /// we reach blocks we've already seen.
  115. static void MarkBlocksLiveIn(BasicBlock *BB,
  116. SmallPtrSetImpl<BasicBlock *> &LiveBBs) {
  117. if (!LiveBBs.insert(BB).second)
  118. return; // already been here.
  119. df_iterator_default_set<BasicBlock*> Visited;
  120. for (BasicBlock *B : inverse_depth_first_ext(BB, Visited))
  121. LiveBBs.insert(B);
  122. }
  123. /// substituteLPadValues - Substitute the values returned by the landingpad
  124. /// instruction with those returned by the personality function.
  125. void SjLjEHPrepare::substituteLPadValues(LandingPadInst *LPI, Value *ExnVal,
  126. Value *SelVal) {
  127. SmallVector<Value *, 8> UseWorkList(LPI->users());
  128. while (!UseWorkList.empty()) {
  129. Value *Val = UseWorkList.pop_back_val();
  130. auto *EVI = dyn_cast<ExtractValueInst>(Val);
  131. if (!EVI)
  132. continue;
  133. if (EVI->getNumIndices() != 1)
  134. continue;
  135. if (*EVI->idx_begin() == 0)
  136. EVI->replaceAllUsesWith(ExnVal);
  137. else if (*EVI->idx_begin() == 1)
  138. EVI->replaceAllUsesWith(SelVal);
  139. if (EVI->use_empty())
  140. EVI->eraseFromParent();
  141. }
  142. if (LPI->use_empty())
  143. return;
  144. // There are still some uses of LPI. Construct an aggregate with the exception
  145. // values and replace the LPI with that aggregate.
  146. Type *LPadType = LPI->getType();
  147. Value *LPadVal = UndefValue::get(LPadType);
  148. auto *SelI = cast<Instruction>(SelVal);
  149. IRBuilder<> Builder(SelI->getParent(), std::next(SelI->getIterator()));
  150. LPadVal = Builder.CreateInsertValue(LPadVal, ExnVal, 0, "lpad.val");
  151. LPadVal = Builder.CreateInsertValue(LPadVal, SelVal, 1, "lpad.val");
  152. LPI->replaceAllUsesWith(LPadVal);
  153. }
  154. /// setupFunctionContext - Allocate the function context on the stack and fill
  155. /// it with all of the data that we know at this point.
  156. Value *SjLjEHPrepare::setupFunctionContext(Function &F,
  157. ArrayRef<LandingPadInst *> LPads) {
  158. BasicBlock *EntryBB = &F.front();
  159. // Create an alloca for the incoming jump buffer ptr and the new jump buffer
  160. // that needs to be restored on all exits from the function. This is an alloca
  161. // because the value needs to be added to the global context list.
  162. auto &DL = F.getParent()->getDataLayout();
  163. const Align Alignment(DL.getPrefTypeAlignment(FunctionContextTy));
  164. FuncCtx = new AllocaInst(FunctionContextTy, DL.getAllocaAddrSpace(), nullptr,
  165. Alignment, "fn_context", &EntryBB->front());
  166. // Fill in the function context structure.
  167. for (LandingPadInst *LPI : LPads) {
  168. IRBuilder<> Builder(LPI->getParent(),
  169. LPI->getParent()->getFirstInsertionPt());
  170. // Reference the __data field.
  171. Value *FCData =
  172. Builder.CreateConstGEP2_32(FunctionContextTy, FuncCtx, 0, 2, "__data");
  173. // The exception values come back in context->__data[0].
  174. Value *ExceptionAddr = Builder.CreateConstGEP2_32(doubleUnderDataTy, FCData,
  175. 0, 0, "exception_gep");
  176. Value *ExnVal = Builder.CreateLoad(DataTy, ExceptionAddr, true, "exn_val");
  177. ExnVal = Builder.CreateIntToPtr(ExnVal, Builder.getInt8PtrTy());
  178. Value *SelectorAddr = Builder.CreateConstGEP2_32(doubleUnderDataTy, FCData,
  179. 0, 1, "exn_selector_gep");
  180. Value *SelVal =
  181. Builder.CreateLoad(DataTy, SelectorAddr, true, "exn_selector_val");
  182. // SelVal must be Int32Ty, so trunc it
  183. SelVal = Builder.CreateTrunc(SelVal, Type::getInt32Ty(F.getContext()));
  184. substituteLPadValues(LPI, ExnVal, SelVal);
  185. }
  186. // Personality function
  187. IRBuilder<> Builder(EntryBB->getTerminator());
  188. Value *PersonalityFn = F.getPersonalityFn();
  189. Value *PersonalityFieldPtr = Builder.CreateConstGEP2_32(
  190. FunctionContextTy, FuncCtx, 0, 3, "pers_fn_gep");
  191. Builder.CreateStore(
  192. Builder.CreateBitCast(PersonalityFn, Builder.getInt8PtrTy()),
  193. PersonalityFieldPtr, /*isVolatile=*/true);
  194. // LSDA address
  195. Value *LSDA = Builder.CreateCall(LSDAAddrFn, {}, "lsda_addr");
  196. Value *LSDAFieldPtr =
  197. Builder.CreateConstGEP2_32(FunctionContextTy, FuncCtx, 0, 4, "lsda_gep");
  198. Builder.CreateStore(LSDA, LSDAFieldPtr, /*isVolatile=*/true);
  199. return FuncCtx;
  200. }
  201. /// lowerIncomingArguments - To avoid having to handle incoming arguments
  202. /// specially, we lower each arg to a copy instruction in the entry block. This
  203. /// ensures that the argument value itself cannot be live out of the entry
  204. /// block.
  205. void SjLjEHPrepare::lowerIncomingArguments(Function &F) {
  206. BasicBlock::iterator AfterAllocaInsPt = F.begin()->begin();
  207. while (isa<AllocaInst>(AfterAllocaInsPt) &&
  208. cast<AllocaInst>(AfterAllocaInsPt)->isStaticAlloca())
  209. ++AfterAllocaInsPt;
  210. assert(AfterAllocaInsPt != F.front().end());
  211. for (auto &AI : F.args()) {
  212. // Swift error really is a register that we model as memory -- instruction
  213. // selection will perform mem-to-reg for us and spill/reload appropriately
  214. // around calls that clobber it. There is no need to spill this
  215. // value to the stack and doing so would not be allowed.
  216. if (AI.isSwiftError())
  217. continue;
  218. Type *Ty = AI.getType();
  219. // Use 'select i8 true, %arg, undef' to simulate a 'no-op' instruction.
  220. Value *TrueValue = ConstantInt::getTrue(F.getContext());
  221. Value *UndefValue = UndefValue::get(Ty);
  222. Instruction *SI = SelectInst::Create(
  223. TrueValue, &AI, UndefValue, AI.getName() + ".tmp", &*AfterAllocaInsPt);
  224. AI.replaceAllUsesWith(SI);
  225. // Reset the operand, because it was clobbered by the RAUW above.
  226. SI->setOperand(1, &AI);
  227. }
  228. }
  229. /// lowerAcrossUnwindEdges - Find all variables which are alive across an unwind
  230. /// edge and spill them.
  231. void SjLjEHPrepare::lowerAcrossUnwindEdges(Function &F,
  232. ArrayRef<InvokeInst *> Invokes) {
  233. // Finally, scan the code looking for instructions with bad live ranges.
  234. for (BasicBlock &BB : F) {
  235. for (Instruction &Inst : BB) {
  236. // Ignore obvious cases we don't have to handle. In particular, most
  237. // instructions either have no uses or only have a single use inside the
  238. // current block. Ignore them quickly.
  239. if (Inst.use_empty())
  240. continue;
  241. if (Inst.hasOneUse() &&
  242. cast<Instruction>(Inst.user_back())->getParent() == &BB &&
  243. !isa<PHINode>(Inst.user_back()))
  244. continue;
  245. // If this is an alloca in the entry block, it's not a real register
  246. // value.
  247. if (auto *AI = dyn_cast<AllocaInst>(&Inst))
  248. if (AI->isStaticAlloca())
  249. continue;
  250. // Avoid iterator invalidation by copying users to a temporary vector.
  251. SmallVector<Instruction *, 16> Users;
  252. for (User *U : Inst.users()) {
  253. Instruction *UI = cast<Instruction>(U);
  254. if (UI->getParent() != &BB || isa<PHINode>(UI))
  255. Users.push_back(UI);
  256. }
  257. // Find all of the blocks that this value is live in.
  258. SmallPtrSet<BasicBlock *, 32> LiveBBs;
  259. LiveBBs.insert(&BB);
  260. while (!Users.empty()) {
  261. Instruction *U = Users.pop_back_val();
  262. if (!isa<PHINode>(U)) {
  263. MarkBlocksLiveIn(U->getParent(), LiveBBs);
  264. } else {
  265. // Uses for a PHI node occur in their predecessor block.
  266. PHINode *PN = cast<PHINode>(U);
  267. for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
  268. if (PN->getIncomingValue(i) == &Inst)
  269. MarkBlocksLiveIn(PN->getIncomingBlock(i), LiveBBs);
  270. }
  271. }
  272. // Now that we know all of the blocks that this thing is live in, see if
  273. // it includes any of the unwind locations.
  274. bool NeedsSpill = false;
  275. for (InvokeInst *Invoke : Invokes) {
  276. BasicBlock *UnwindBlock = Invoke->getUnwindDest();
  277. if (UnwindBlock != &BB && LiveBBs.count(UnwindBlock)) {
  278. LLVM_DEBUG(dbgs() << "SJLJ Spill: " << Inst << " around "
  279. << UnwindBlock->getName() << "\n");
  280. NeedsSpill = true;
  281. break;
  282. }
  283. }
  284. // If we decided we need a spill, do it.
  285. // FIXME: Spilling this way is overkill, as it forces all uses of
  286. // the value to be reloaded from the stack slot, even those that aren't
  287. // in the unwind blocks. We should be more selective.
  288. if (NeedsSpill) {
  289. DemoteRegToStack(Inst, true);
  290. ++NumSpilled;
  291. }
  292. }
  293. }
  294. // Go through the landing pads and remove any PHIs there.
  295. for (InvokeInst *Invoke : Invokes) {
  296. BasicBlock *UnwindBlock = Invoke->getUnwindDest();
  297. LandingPadInst *LPI = UnwindBlock->getLandingPadInst();
  298. // Place PHIs into a set to avoid invalidating the iterator.
  299. SmallPtrSet<PHINode *, 8> PHIsToDemote;
  300. for (BasicBlock::iterator PN = UnwindBlock->begin(); isa<PHINode>(PN); ++PN)
  301. PHIsToDemote.insert(cast<PHINode>(PN));
  302. if (PHIsToDemote.empty())
  303. continue;
  304. // Demote the PHIs to the stack.
  305. for (PHINode *PN : PHIsToDemote)
  306. DemotePHIToStack(PN);
  307. // Move the landingpad instruction back to the top of the landing pad block.
  308. LPI->moveBefore(&UnwindBlock->front());
  309. }
  310. }
  311. /// setupEntryBlockAndCallSites - Setup the entry block by creating and filling
  312. /// the function context and marking the call sites with the appropriate
  313. /// values. These values are used by the DWARF EH emitter.
  314. bool SjLjEHPrepare::setupEntryBlockAndCallSites(Function &F) {
  315. SmallVector<ReturnInst *, 16> Returns;
  316. SmallVector<InvokeInst *, 16> Invokes;
  317. SmallSetVector<LandingPadInst *, 16> LPads;
  318. // Look through the terminators of the basic blocks to find invokes.
  319. for (BasicBlock &BB : F)
  320. if (auto *II = dyn_cast<InvokeInst>(BB.getTerminator())) {
  321. if (Function *Callee = II->getCalledFunction())
  322. if (Callee->getIntrinsicID() == Intrinsic::donothing) {
  323. // Remove the NOP invoke.
  324. BranchInst::Create(II->getNormalDest(), II);
  325. II->eraseFromParent();
  326. continue;
  327. }
  328. Invokes.push_back(II);
  329. LPads.insert(II->getUnwindDest()->getLandingPadInst());
  330. } else if (auto *RI = dyn_cast<ReturnInst>(BB.getTerminator())) {
  331. Returns.push_back(RI);
  332. }
  333. if (Invokes.empty())
  334. return false;
  335. NumInvokes += Invokes.size();
  336. lowerIncomingArguments(F);
  337. lowerAcrossUnwindEdges(F, Invokes);
  338. Value *FuncCtx =
  339. setupFunctionContext(F, makeArrayRef(LPads.begin(), LPads.end()));
  340. BasicBlock *EntryBB = &F.front();
  341. IRBuilder<> Builder(EntryBB->getTerminator());
  342. // Get a reference to the jump buffer.
  343. Value *JBufPtr =
  344. Builder.CreateConstGEP2_32(FunctionContextTy, FuncCtx, 0, 5, "jbuf_gep");
  345. // Save the frame pointer.
  346. Value *FramePtr = Builder.CreateConstGEP2_32(doubleUnderJBufTy, JBufPtr, 0, 0,
  347. "jbuf_fp_gep");
  348. Value *Val = Builder.CreateCall(FrameAddrFn, Builder.getInt32(0), "fp");
  349. Builder.CreateStore(Val, FramePtr, /*isVolatile=*/true);
  350. // Save the stack pointer.
  351. Value *StackPtr = Builder.CreateConstGEP2_32(doubleUnderJBufTy, JBufPtr, 0, 2,
  352. "jbuf_sp_gep");
  353. Val = Builder.CreateCall(StackAddrFn, {}, "sp");
  354. Builder.CreateStore(Val, StackPtr, /*isVolatile=*/true);
  355. // Call the setup_dispatch instrinsic. It fills in the rest of the jmpbuf.
  356. Builder.CreateCall(BuiltinSetupDispatchFn, {});
  357. // Store a pointer to the function context so that the back-end will know
  358. // where to look for it.
  359. Value *FuncCtxArg = Builder.CreateBitCast(FuncCtx, Builder.getInt8PtrTy());
  360. Builder.CreateCall(FuncCtxFn, FuncCtxArg);
  361. // At this point, we are all set up, update the invoke instructions to mark
  362. // their call_site values.
  363. for (unsigned I = 0, E = Invokes.size(); I != E; ++I) {
  364. insertCallSiteStore(Invokes[I], I + 1);
  365. ConstantInt *CallSiteNum =
  366. ConstantInt::get(Type::getInt32Ty(F.getContext()), I + 1);
  367. // Record the call site value for the back end so it stays associated with
  368. // the invoke.
  369. CallInst::Create(CallSiteFn, CallSiteNum, "", Invokes[I]);
  370. }
  371. // Mark call instructions that aren't nounwind as no-action (call_site ==
  372. // -1). Skip the entry block, as prior to then, no function context has been
  373. // created for this function and any unexpected exceptions thrown will go
  374. // directly to the caller's context, which is what we want anyway, so no need
  375. // to do anything here.
  376. for (BasicBlock &BB : F) {
  377. if (&BB == &F.front())
  378. continue;
  379. for (Instruction &I : BB)
  380. if (I.mayThrow())
  381. insertCallSiteStore(&I, -1);
  382. }
  383. // Register the function context and make sure it's known to not throw
  384. CallInst *Register =
  385. CallInst::Create(RegisterFn, FuncCtx, "", EntryBB->getTerminator());
  386. Register->setDoesNotThrow();
  387. // Following any allocas not in the entry block, update the saved SP in the
  388. // jmpbuf to the new value.
  389. for (BasicBlock &BB : F) {
  390. if (&BB == &F.front())
  391. continue;
  392. for (Instruction &I : BB) {
  393. if (auto *CI = dyn_cast<CallInst>(&I)) {
  394. if (CI->getCalledFunction() != StackRestoreFn)
  395. continue;
  396. } else if (!isa<AllocaInst>(&I)) {
  397. continue;
  398. }
  399. Instruction *StackAddr = CallInst::Create(StackAddrFn, "sp");
  400. StackAddr->insertAfter(&I);
  401. new StoreInst(StackAddr, StackPtr, true, StackAddr->getNextNode());
  402. }
  403. }
  404. // Finally, for any returns from this function, if this function contains an
  405. // invoke, add a call to unregister the function context.
  406. for (ReturnInst *Return : Returns) {
  407. Instruction *InsertPoint = Return;
  408. if (CallInst *CI = Return->getParent()->getTerminatingMustTailCall())
  409. InsertPoint = CI;
  410. CallInst::Create(UnregisterFn, FuncCtx, "", InsertPoint);
  411. }
  412. return true;
  413. }
  414. bool SjLjEHPrepare::runOnFunction(Function &F) {
  415. Module &M = *F.getParent();
  416. RegisterFn = M.getOrInsertFunction(
  417. "_Unwind_SjLj_Register", Type::getVoidTy(M.getContext()),
  418. PointerType::getUnqual(FunctionContextTy));
  419. UnregisterFn = M.getOrInsertFunction(
  420. "_Unwind_SjLj_Unregister", Type::getVoidTy(M.getContext()),
  421. PointerType::getUnqual(FunctionContextTy));
  422. FrameAddrFn = Intrinsic::getDeclaration(
  423. &M, Intrinsic::frameaddress,
  424. {Type::getInt8PtrTy(M.getContext(),
  425. M.getDataLayout().getAllocaAddrSpace())});
  426. StackAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::stacksave);
  427. StackRestoreFn = Intrinsic::getDeclaration(&M, Intrinsic::stackrestore);
  428. BuiltinSetupDispatchFn =
  429. Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_setup_dispatch);
  430. LSDAAddrFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_lsda);
  431. CallSiteFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_callsite);
  432. FuncCtxFn = Intrinsic::getDeclaration(&M, Intrinsic::eh_sjlj_functioncontext);
  433. bool Res = setupEntryBlockAndCallSites(F);
  434. return Res;
  435. }