llvm.org GIT mirror llvm / 564bfad
Redirect DataLayout from TargetMachine to Module in SjLjEHPrepare Summary: This change is part of a series of commits dedicated to have a single DataLayout during compilation by using always the one owned by the module. Reviewers: echristo Subscribers: yaron.keren, rafael, llvm-commits Differential Revision: http://reviews.llvm.org/D11009 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241654 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 4 years ago
3 changed file(s) with 6 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
604604 /// createSjLjEHPreparePass - This pass adapts exception handling code to use
605605 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
606606 ///
607 FunctionPass *createSjLjEHPreparePass(const TargetMachine *TM);
607 FunctionPass *createSjLjEHPreparePass();
608608
609609 /// LocalStackSlotAllocation - This pass assigns local frame indices to stack
610610 /// slots relative to one another and allocates base registers to access them
423423 // removed from the parent invoke(s). This could happen when a landing
424424 // pad is shared by multiple invokes and is also a target of a normal
425425 // edge from elsewhere.
426 addPass(createSjLjEHPreparePass(TM));
426 addPass(createSjLjEHPreparePass());
427427 // FALLTHROUGH
428428 case ExceptionHandling::DwarfCFI:
429429 case ExceptionHandling::ARM:
4444
4545 namespace {
4646 class SjLjEHPrepare : public FunctionPass {
47 const TargetMachine *TM;
4847 Type *doubleUnderDataTy;
4948 Type *doubleUnderJBufTy;
5049 Type *FunctionContextTy;
6261
6362 public:
6463 static char ID; // Pass identification, replacement for typeid
65 explicit SjLjEHPrepare(const TargetMachine *TM) : FunctionPass(ID), TM(TM) {}
64 explicit SjLjEHPrepare() : FunctionPass(ID) {}
6665 bool doInitialization(Module &M) override;
6766 bool runOnFunction(Function &F) override;
6867
8483 char SjLjEHPrepare::ID = 0;
8584
8685 // Public Interface To the SjLjEHPrepare pass.
87 FunctionPass *llvm::createSjLjEHPreparePass(const TargetMachine *TM) {
88 return new SjLjEHPrepare(TM);
89 }
86 FunctionPass *llvm::createSjLjEHPreparePass() { return new SjLjEHPrepare(); }
9087 // doInitialization - Set up decalarations and types needed to process
9188 // exceptions.
9289 bool SjLjEHPrepare::doInitialization(Module &M) {
195192 // Create an alloca for the incoming jump buffer ptr and the new jump buffer
196193 // that needs to be restored on all exits from the function. This is an alloca
197194 // because the value needs to be added to the global context list.
198 const TargetLowering *TLI = TM->getSubtargetImpl(F)->getTargetLowering();
199 unsigned Align =
200 TLI->getDataLayout()->getPrefTypeAlignment(FunctionContextTy);
195 auto &DL = F.getParent()->getDataLayout();
196 unsigned Align = DL.getPrefTypeAlignment(FunctionContextTy);
201197 FuncCtx = new AllocaInst(FunctionContextTy, nullptr, Align, "fn_context",
202198 EntryBB->begin());
203199