- std::pair<CallInst*, CallInst*> OldExnSel = I->first;
- CallInst *Exn = OldExnSel.first;
- CallInst *Sel = OldExnSel.second;
- SmallVector<std::pair<Value*, Value*>, 8> &LPExnSel = I->second;
- unsigned Size = LPExnSel.size();
- Value *LPExn = LPExnSel[0].first;
- Value *LPSel = LPExnSel[0].second;
-
- if (Size != 1) {
- BasicBlock *Parent = Exn->getParent();
- IRBuilder<> Builder(Context);
- Builder.SetInsertPoint(Parent, Parent->getFirstInsertionPt());
-
- PHINode *PN = Builder.CreatePHI(Exn->getType(), Size, "exn.phi");
- for (SmallVector<std::pair<Value*, Value*>, 8>::iterator
- II = LPExnSel.begin(), IE = LPExnSel.end(); II != IE; ++II)
- PN->addIncoming(II->first, cast<Instruction>(II->first)->getParent());
-
- LPExn = PN;
-
- Parent = Sel->getParent();
- Builder.SetInsertPoint(Parent, Parent->getFirstInsertionPt());
-
- PN = Builder.CreatePHI(Sel->getType(), Size, "sel.phi");
- for (SmallVector<std::pair<Value*, Value*>, 8>::iterator
- II = LPExnSel.begin(), IE = LPExnSel.end(); II != IE; ++II)
- PN->addIncoming(II->second, cast<Instruction>(II->second)->getParent());
-
- LPSel = PN;
- }
+ std::pair<Value*, Value*> EHIntrinsics = I->second;
+ CallInst *Exn = cast<CallInst>(EHIntrinsics.first);
+ CallInst *Sel = cast<CallInst>(EHIntrinsics.second);
+ BasicBlock *Parent = Exn->getParent();
+
+ std::pair<Value*,Value*> ExnSelSlots = FnToLPadSlotMap[Parent->getParent()];
+
+ IRBuilder<> Builder(Context);
+ Builder.SetInsertPoint(Parent, Parent->getFirstInsertionPt());
+ LoadInst *LPExn = Builder.CreateLoad(ExnSelSlots.first, "exn.load");
+ LoadInst *LPSel = Builder.CreateLoad(ExnSelSlots.second, "sel.load");