Lines Matching full:cgf
218 const EHPersonality &EHPersonality::get(CodeGenFunction &CGF) {
219 return get(CGF.CGM, dyn_cast_or_null<FunctionDecl>(CGF.CurCodeDecl));
336 static llvm::Constant *getCatchAllValue(CodeGenFunction &CGF) {
338 return llvm::ConstantPointerNull::get(CGF.Int8PtrTy);
347 void Emit(CodeGenFunction &CGF, Flags flags) override {
348 CGF.EmitNounwindRuntimeCall(getFreeExceptionFn(CGF.CGM), exn);
466 static void emitFilterDispatchBlock(CodeGenFunction &CGF,
475 CGF.EmitBlockAfterUses(dispatchBlock);
481 llvm::Value *selector = CGF.getSelectorFromSlot();
482 llvm::BasicBlock *unexpectedBB = CGF.createBasicBlock("ehspec.unexpected");
484 llvm::Value *zero = CGF.Builder.getInt32(0);
486 CGF.Builder.CreateICmpSLT(selector, zero, "ehspec.fails");
487 CGF.Builder.CreateCondBr(failsFilter, unexpectedBB,
488 CGF.getEHResumeBlock(false));
490 CGF.EmitBlock(unexpectedBB);
497 llvm::Value *exn = CGF.getExceptionFromSlot();
498 CGF.EmitRuntimeCall(getUnexpectedFn(CGF.CGM), exn)
500 CGF.Builder.CreateUnreachable();
876 static void emitCatchPadBlock(CodeGenFunction &CGF, EHCatchScope &CatchScope) {
880 CGBuilderTy::InsertPoint SavedIP = CGF.Builder.saveIP();
881 CGF.EmitBlockAfterUses(DispatchBlock);
883 llvm::Value *ParentPad = CGF.CurrentFuncletPad;
885 ParentPad = llvm::ConstantTokenNone::get(CGF.getLLVMContext());
887 CGF.getEHDispatchBlock(CatchScope.getEnclosingEHScope());
891 CGF.Builder.CreateCatchSwitch(ParentPad, UnwindBB, NumHandlers);
899 TypeInfo.RTTI = llvm::Constant::getNullValue(CGF.VoidPtrTy);
901 CGF.Builder.SetInsertPoint(Handler.Block);
903 if (EHPersonality::get(CGF).isMSVCXXPersonality()) {
904 CGF.Builder.CreateCatchPad(
905 CatchSwitch, {TypeInfo.RTTI, CGF.Builder.getInt32(TypeInfo.Flags),
906 llvm::Constant::getNullValue(CGF.VoidPtrTy)});
908 CGF.Builder.CreateCatchPad(CatchSwitch, {TypeInfo.RTTI});
913 CGF.Builder.restoreIP(SavedIP);
918 static void emitCatchDispatchBlock(CodeGenFunction &CGF,
920 if (EHPersonality::get(CGF).usesFuncletPads())
921 return emitCatchPadBlock(CGF, catchScope);
934 CGBuilderTy::InsertPoint savedIP = CGF.Builder.saveIP();
935 CGF.EmitBlockAfterUses(dispatchBlock);
939 CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for);
942 llvm::Value *selector = CGF.getSelectorFromSlot();
953 typeValue = CGF.Builder.CreateBitCast(typeValue, CGF.Int8PtrTy);
962 nextBlock = CGF.getEHDispatchBlock(catchScope.getEnclosingEHScope());
973 nextBlock = CGF.createBasicBlock("catch.fallthrough");
979 CGF.Builder.CreateCall(llvm_eh_typeid_for, typeValue);
983 CGF.Builder.CreateICmpEQ(selector, typeIndex, "matches");
984 CGF.Builder.CreateCondBr(matchesTypeIndex, handler.Block, nextBlock);
988 CGF.Builder.restoreIP(savedIP);
992 CGF.EmitBlock(nextBlock);
1102 void Emit(CodeGenFunction &CGF, Flags flags) override {
1103 llvm::BasicBlock *EndCatchBB = CGF.createBasicBlock("finally.endcatch");
1105 CGF.createBasicBlock("finally.cleanup.cont");
1108 CGF.Builder.CreateFlagLoad(ForEHVar, "finally.endcatch");
1109 CGF.Builder.CreateCondBr(ShouldEndCatch, EndCatchBB, CleanupContBB);
1110 CGF.EmitBlock(EndCatchBB);
1111 CGF.EmitRuntimeCallOrInvoke(EndCatchFn); // catch-all, so might throw
1112 CGF.EmitBlock(CleanupContBB);
1129 void Emit(CodeGenFunction &CGF, Flags flags) override {
1132 CGF.EHStack.pushCleanup<CallEndCatchForFinally>(NormalAndEHCleanup,
1138 CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot(),
1142 CGF.EmitStmt(Body);
1146 if (CGF.HaveInsertPoint()) {
1147 llvm::BasicBlock *RethrowBB = CGF.createBasicBlock("finally.rethrow");
1148 llvm::BasicBlock *ContBB = CGF.createBasicBlock("finally.cont");
1151 CGF.Builder.CreateFlagLoad(ForEHVar, "finally.shouldthrow");
1152 CGF.Builder.CreateCondBr(ShouldRethrow, RethrowBB, ContBB);
1154 CGF.EmitBlock(RethrowBB);
1156 CGF.EmitRuntimeCallOrInvoke(RethrowFn,
1157 CGF.Builder.CreateAlignedLoad(SavedExnVar, CGF.getPointerAlign()));
1159 CGF.EmitRuntimeCallOrInvoke(RethrowFn);
1161 CGF.Builder.CreateUnreachable();
1163 CGF.EmitBlock(ContBB);
1166 CGF.Builder.CreateStore(SavedCleanupDest,
1167 CGF.getNormalCleanupDestSlot());
1174 CGBuilderTy::InsertPoint SavedIP = CGF.Builder.saveAndClearIP();
1175 CGF.PopCleanupBlock();
1176 CGF.Builder.restoreIP(SavedIP);
1181 CGF.EnsureInsertPoint();
1189 void CodeGenFunction::FinallyInfo::enter(CodeGenFunction &CGF,
1211 SavedExnVar = CGF.CreateTempAlloca(CGF.Int8PtrTy, "finally.exn");
1228 RethrowDest = CGF.getJumpDestInCurrentScope(CGF.getUnreachableBlock());
1231 ForEHVar = CGF.CreateTempAlloca(CGF.Builder.getInt1Ty(), "finally.for-eh");
1232 CGF.Builder.CreateFlagStore(false, ForEHVar);
1235 CGF.EHStack.pushCleanup<PerformFinally>(NormalCleanup, body,
1240 llvm::BasicBlock *catchBB = CGF.createBasicBlock("finally.catchall");
1241 EHCatchScope *catchScope = CGF.EHStack.pushCatch(1);
1245 void CodeGenFunction::FinallyInfo::exit(CodeGenFunction &CGF) {
1247 EHCatchScope &catchScope = cast<EHCatchScope>(*CGF.EHStack.begin());
1250 CGF.popCatchScope();
1256 CGBuilderTy::InsertPoint savedIP = CGF.Builder.saveAndClearIP();
1257 CGF.EmitBlock(catchBB);
1263 exn = CGF.getExceptionFromSlot();
1264 CGF.EmitNounwindRuntimeCall(BeginCatchFn, exn);
1269 if (!exn) exn = CGF.getExceptionFromSlot();
1270 CGF.Builder.CreateAlignedStore(exn, SavedExnVar, CGF.getPointerAlign());
1274 CGF.Builder.CreateFlagStore(true, ForEHVar);
1277 CGF.EmitBranchThroughCleanup(RethrowDest);
1279 CGF.Builder.restoreIP(savedIP);
1283 CGF.PopCleanupBlock();
1413 void Emit(CodeGenFunction &CGF, Flags F) override {
1414 ASTContext &Context = CGF.getContext();
1415 CodeGenModule &CGM = CGF.CGM;
1422 llvm::Value *FP = CGF.Builder.CreateCall(LocalAddrFn);
1424 llvm::ConstantInt::get(CGF.ConvertType(ArgTys[0]), F.isForEHCleanup());
1432 CGF.EmitCall(FnInfo, OutlinedFinally, ReturnValueSlot(), Args);