Lines Matching full:cgf
998 llvm::Value *EmitClassRefViaRuntime(CodeGenFunction &CGF,
1022 CodeGen::RValue EmitMessageSend(CodeGen::CodeGenFunction &CGF,
1098 llvm::Value *EmitClassRef(CodeGenFunction &CGF,
1101 llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF,
1104 llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override;
1180 llvm::Value *EmitSelector(CodeGenFunction &CGF, Selector Sel);
1181 Address EmitSelectorAddr(CodeGenFunction &CGF, Selector Sel);
1188 CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
1197 GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
1204 llvm::Value *GetClass(CodeGenFunction &CGF,
1207 llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) override;
1208 Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) override;
1212 llvm::Value *GetSelector(CodeGenFunction &CGF,
1223 llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
1236 void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
1238 void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
1240 void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const Stmt &S);
1241 void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S,
1243 llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
1245 void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
1247 void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
1250 void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
1253 void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
1255 void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
1259 LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy,
1262 llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
1356 CodeGen::RValue EmitVTableMessageSend(CodeGen::CodeGenFunction &CGF,
1373 llvm::Value *EmitClassRef(CodeGenFunction &CGF,
1376 llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF,
1380 llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override;
1384 llvm::Value *EmitSuperClassRef(CodeGenFunction &CGF,
1389 llvm::Value *EmitMetaClassRef(CodeGenFunction &CGF,
1401 llvm::Value *EmitSelector(CodeGenFunction &CGF, Selector Sel);
1402 Address EmitSelectorAddr(CodeGenFunction &CGF, Selector Sel);
1432 bool IsIvarOffsetKnownIdempotent(const CodeGen::CodeGenFunction &CGF,
1445 dyn_cast_or_null<ObjCMethodDecl>(CGF.CurFuncDecl))
1457 CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
1466 GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
1473 llvm::Value *GetClass(CodeGenFunction &CGF,
1476 llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) override
1477 { return EmitSelector(CGF, Sel); }
1478 Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) override
1479 { return EmitSelectorAddr(CGF, Sel); }
1483 llvm::Value *GetSelector(CodeGenFunction &CGF,
1485 { return EmitSelector(CGF, Method->getSelector()); }
1493 llvm::Value *GenerateProtocolRef(CodeGenFunction &CGF,
1530 void EmitTryStmt(CodeGen::CodeGenFunction &CGF,
1532 void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
1534 void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S,
1536 llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
1538 void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
1540 void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
1543 void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
1546 void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
1548 void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
1551 LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy,
1554 llvm::Value *EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
1566 void init(CodeGenFunction &CGF, llvm::Value *receiver) {
1568 NullBB = CGF.createBasicBlock("msgSend.null-receiver");
1569 llvm::BasicBlock *callBB = CGF.createBasicBlock("msgSend.call");
1575 llvm::Value *isNull = CGF.Builder.CreateIsNull(receiver);
1576 CGF.Builder.CreateCondBr(isNull, NullBB, callBB);
1579 CGF.EmitBlock(callBB);
1584 RValue complete(CodeGenFunction &CGF, RValue result, QualType resultType,
1595 llvm::BasicBlock *callBB = CGF.Builder.GetInsertBlock();
1597 contBB = CGF.createBasicBlock("msgSend.cont");
1598 CGF.Builder.CreateBr(contBB);
1602 CGF.EmitBlock(NullBB);
1614 CGF.EmitARCRelease(RV.getScalarVal(), ARCImpreciseLifetime);
1620 assert(CGF.Builder.GetInsertBlock() == NullBB);
1625 if (contBB) CGF.EmitBlock(contBB);
1632 llvm::Constant *null = CGF.CGM.EmitNullConstant(resultType);
1638 CGF.EmitBlock(contBB);
1639 llvm::PHINode *phi = CGF.Builder.CreatePHI(null->getType(), 2);
1651 CGF.EmitNullInitialization(result.getAggregateAddress(), resultType);
1652 if (contBB) CGF.EmitBlock(contBB);
1657 CGF.EmitBlock(contBB);
1665 llvm::PHINode *real = CGF.Builder.CreatePHI(scalarTy, 2);
1668 llvm::PHINode *imag = CGF.Builder.CreatePHI(scalarTy, 2);
1711 llvm::Value *CGObjCMac::GetClass(CodeGenFunction &CGF,
1713 return EmitClassRef(CGF, ID);
1717 llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, Selector Sel) {
1718 return EmitSelector(CGF, Sel);
1720 Address CGObjCMac::GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) {
1721 return EmitSelectorAddr(CGF, Sel);
1723 llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, const ObjCMethodDecl
1725 return EmitSelector(CGF, Method->getSelector());
1779 CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
1792 CGF.CreateTempAlloca(ObjCTypes.SuperTy, CGF.getPointerAlign(),
1795 CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);
1796 CGF.Builder.CreateStore(
1798 CGF.Builder.CreateStructGEP(ObjCSuper, 0, CharUnits::Zero()));
1810 Target = EmitClassRef(CGF, Class->getSuperClass());
1811 Target = CGF.Builder.CreateStructGEP(ObjCTypes.ClassTy, Target, 0);
1812 Target = CGF.Builder.CreateAlignedLoad(Target, CGF.getPointerAlign());
1816 CGF.Builder.CreateStructGEP(ObjCTypes.ClassTy, MetaClassPtr, 1);
1818 CGF.Builder.CreateAlignedLoad(SuperPtr, CGF.getPointerAlign());
1822 Target = EmitClassRef(CGF, Class->getSuperClass());
1825 ClassPtr = CGF.Builder.CreateStructGEP(ObjCTypes.ClassTy, ClassPtr, 1);
1826 Target = CGF.Builder.CreateAlignedLoad(ClassPtr, CGF.getPointerAlign());
1831 CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());
1832 Target = CGF.Builder.CreateBitCast(Target, ClassTy);
1833 CGF.Builder.CreateStore(Target,
1834 CGF.Builder.CreateStructGEP(ObjCSuper, 1, CGF.getPointerSize()));
1835 return EmitMessageSend(CGF, Return, ResultType,
1836 EmitSelector(CGF, Sel),
1842 CodeGen::RValue CGObjCMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
1850 return EmitMessageSend(CGF, Return, ResultType,
1851 EmitSelector(CGF, Sel),
1852 Receiver, CGF.getContext().getObjCIdType(),
1866 CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF,
1879 Arg0 = CGF.Builder.CreateBitCast(Arg0, ObjCTypes.ObjectPtrTy);
1881 ActualArgs.add(RValue::get(Sel), CGF.getContext().getObjCSelType());
1907 dyn_cast_or_null<ObjCMethodDecl>(CGF.CurCodeDecl)) {
1911 llvm::Value *SelfAddr = CGF.GetAddrOfLocalVar(Self).getPointer();
1923 if (ReceiverCanBeNull) nullReturn.init(CGF, Arg0);
1936 nullReturn.init(CGF, Arg0);
1947 nullReturn.init(CGF, Arg0);
1956 RValue rvalue = CGF.EmitCall(MSI.CallInfo, Fn, Return, ActualArgs,
1965 return nullReturn.complete(CGF, rvalue, ResultType, CallArgs,
2657 llvm::Value *CGObjCMac::GenerateProtocolRef(CodeGenFunction &CGF,
2687 CodeGenFunction &CGF,
2693 CGF.CGM.GetAddrOfConstantCString(ID->getObjCRuntimeNameAsString())
2695 ASTContext &ctx = CGF.CGM.getContext();
2697 CGF.Builder.CreateBitCast(className,
2698 CGF.ConvertType(
2700 llvm::CallInst *call = CGF.Builder.CreateCall(lookUpClassFn, className);
3692 void CGObjCMac::EmitTryStmt(CodeGenFunction &CGF, const ObjCAtTryStmt &S) {
3693 return EmitTryOrSynchronizedStmt(CGF, S);
3696 void CGObjCMac::EmitSynchronizedStmt(CodeGenFunction &CGF,
3698 return EmitTryOrSynchronizedStmt(CGF, S);
3716 void Emit(CodeGenFunction &CGF, Flags flags) override {
3720 CGF.createBasicBlock("finally.call_exit");
3722 CGF.createBasicBlock("finally.no_call_exit");
3723 CGF.Builder.CreateCondBr(CGF.Builder.CreateLoad(CallTryExitVar),
3726 CGF.EmitBlock(FinallyCallExit);
3727 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryExitFn(),
3730 CGF.EmitBlock(FinallyNoCallExit);
3741 CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot());
3743 CGF.EmitStmt(FinallyStmt->getFinallyBody());
3745 if (CGF.HaveInsertPoint()) {
3746 CGF.Builder.CreateStore(CurCleanupDest,
3747 CGF.getNormalCleanupDestSlot());
3750 CGF.EnsureInsertPoint();
3756 llvm::Value *SyncArg = CGF.Builder.CreateLoad(SyncArgSlot);
3757 CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncExitFn(), SyncArg);
3763 CodeGenFunction &CGF;
3776 FragileHazards(CodeGenFunction &CGF);
3788 FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) {
3795 I = CGF.CurFn->begin(), E = CGF.CurFn->end(); I != E; ++I)
3834 CGF.EmitNounwindRuntimeCall(WriteHazard, Locals);
3841 call->setCallingConv(CGF.getRuntimeCC());
3849 CGBuilderTy Builder(CGF, CGF.getLLVMContext());
3853 FI = CGF.CurFn->begin(), FE = CGF.CurFn->end(); FI != FE; ++FI) {
3895 addIfPresent(AllocasToIgnore, CGF.ReturnValue);
3896 addIfPresent(AllocasToIgnore, CGF.NormalCleanupDest);
3900 llvm::BasicBlock &Entry = CGF.CurFn->getEntryBlock();
3911 return llvm::FunctionType::get(CGF.VoidTy, tys, false);
4026 void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
4033 CGF.getJumpDestInCurrentScope("finally.end");
4038 CGF.getJumpDestInCurrentScope("finally.rethrow");
4048 CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr());
4049 SyncArg = CGF.Builder.CreateBitCast(SyncArg, ObjCTypes.ObjectPtrTy);
4050 CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncEnterFn(), SyncArg);
4052 SyncArgSlot = CGF.CreateTempAlloca(SyncArg->getType(),
4053 CGF.getPointerAlign(), "sync.arg");
4054 CGF.Builder.CreateStore(SyncArg, SyncArgSlot);
4059 Address ExceptionData = CGF.CreateTempAlloca(ObjCTypes.ExceptionDataTy,
4060 CGF.getPointerAlign(),
4067 FragileHazards Hazards(CGF);
4077 Address CallTryExitVar = CGF.CreateTempAlloca(CGF.Builder.getInt1Ty(),
4086 CGF.EHStack.pushCleanup<PerformFragileFinally>(NormalAndEHCleanup, &S,
4095 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryEnterFn(),
4099 llvm::Constant *Zero = llvm::ConstantInt::get(CGF.Builder.getInt32Ty(), 0);
4101 llvm::Value *SetJmpBuffer = CGF.Builder.CreateGEP(
4104 CGF.EmitNounwindRuntimeCall(
4110 llvm::BasicBlock *TryBlock = CGF.createBasicBlock("try");
4111 llvm::BasicBlock *TryHandler = CGF.createBasicBlock("try.handler");
4113 CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception");
4114 CGF.Builder.CreateCondBr(DidCatch, TryHandler, TryBlock);
4117 CGF.EmitBlock(TryBlock);
4118 CGF.Builder.CreateStore(CGF.Builder.getTrue(), CallTryExitVar);
4119 CGF.EmitStmt(isTry ? cast<ObjCAtTryStmt>(S).getTryBody()
4122 CGBuilderTy::InsertPoint TryFallthroughIP = CGF.Builder.saveAndClearIP();
4125 CGF.EmitBlock(TryHandler);
4134 CGF.Builder.CreateStore(CGF.Builder.getFalse(), CallTryExitVar);
4135 CGF.EmitBranchThroughCleanup(FinallyRethrow);
4142 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionExtractFn(),
4147 CGF.ObjCEHValueStack.push_back(Caught);
4158 PropagatingExnVar = CGF.CreateTempAlloca(Caught->getType(),
4159 CGF.getPointerAlign(),
4161 CGF.Builder.CreateStore(Caught, PropagatingExnVar);
4165 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryEnterFn(),
4169 CGF.EmitNounwindRuntimeCall(ObjCTypes.getSetJmpFn(),
4174 CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception");
4176 CatchBlock = CGF.createBasicBlock("catch");
4177 CatchHandler = CGF.createBasicBlock("catch_for_catch");
4178 CGF.Builder.CreateCondBr(Threw, CatchHandler, CatchBlock);
4180 CGF.EmitBlock(CatchBlock);
4183 CGF.Builder.CreateStore(CGF.Builder.getInt1(HasFinally), CallTryExitVar);
4211 CodeGenFunction::RunCleanupsScope CatchVarCleanups(CGF);
4214 CGF.EmitAutoVarDecl(*CatchParam);
4215 assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?");
4218 EmitInitOfCatchParam(CGF, Caught, CatchParam);
4221 CGF.EmitStmt(CatchStmt->getCatchBody());
4226 CGF.EmitBranchThroughCleanup(FinallyEnd);
4238 llvm::Value *Class = EmitClassRef(CGF, IDecl);
4242 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionMatchFn(),
4245 llvm::BasicBlock *MatchedBlock = CGF.createBasicBlock("match");
4246 llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch.next");
4248 CGF.Builder.CreateCondBr(CGF.Builder.CreateIsNotNull(Match, "matched"),
4252 CGF.EmitBlock(MatchedBlock);
4256 CodeGenFunction::RunCleanupsScope CatchVarCleanups(CGF);
4258 CGF.EmitAutoVarDecl(*CatchParam);
4259 assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?");
4263 CGF.Builder.CreateBitCast(Caught,
4264 CGF.ConvertType(CatchParam->getType()));
4265 EmitInitOfCatchParam(CGF, Tmp, CatchParam);
4267 CGF.EmitStmt(CatchStmt->getCatchBody());
4272 CGF.EmitBranchThroughCleanup(FinallyEnd);
4274 CGF.EmitBlock(NextCatchBlock);
4277 CGF.ObjCEHValueStack.pop_back();
4285 CGF.EmitBranchThroughCleanup(FinallyRethrow);
4289 CGF.EmitBlock(CatchHandler);
4300 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionExtractFn(),
4302 CGF.Builder.CreateStore(NewCaught, PropagatingExnVar);
4305 CGF.Builder.CreateStore(CGF.Builder.getFalse(), CallTryExitVar);
4306 CGF.EmitBranchThroughCleanup(FinallyRethrow);
4314 CGF.Builder.restoreIP(TryFallthroughIP);
4315 if (CGF.HaveInsertPoint())
4316 CGF.Builder.CreateStore(CGF.Builder.getTrue(), CallTryExitVar);
4317 CGF.PopCleanupBlock();
4318 CGF.EmitBlock(FinallyEnd.getBlock(), true);
4321 CGBuilderTy::InsertPoint SavedIP = CGF.Builder.saveAndClearIP();
4322 CGF.EmitBlock(FinallyRethrow.getBlock(), true);
4323 if (CGF.HaveInsertPoint()) {
4327 PropagatingExn = CGF.Builder.CreateLoad(PropagatingExnVar);
4332 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionExtractFn(),
4337 CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionThrowFn(),
4339 CGF.Builder.CreateUnreachable();
4342 CGF.Builder.restoreIP(SavedIP);
4345 void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
4351 llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr);
4353 CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy);
4355 assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) &&
4357 ExceptionAsObject = CGF.ObjCEHValueStack.back();
4360 CGF.EmitRuntimeCall(ObjCTypes.getExceptionThrowFn(), ExceptionAsObject)
4362 CGF.Builder.CreateUnreachable();
4366 CGF.Builder.ClearInsertionPoint();
4372 llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF,
4375 AddrWeakObj = CGF.Builder.CreateBitCast(AddrWeakObj,
4378 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcReadWeakFn(),
4380 read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy);
4387 void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
4393 src = (Size == 4) ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
4394 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongLongTy);
4395 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
4397 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
4398 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
4400 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(),
4407 void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
4414 src = (Size == 4) ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
4415 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongLongTy);
4416 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
4418 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
4419 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
4422 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(),
4425 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(),
4432 void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
4440 src = (Size == 4) ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
4441 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongLongTy);
4442 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
4444 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
4445 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
4447 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignIvarFn(), args);
4453 void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF,
4459 src = (Size == 4) ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
4460 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongLongTy);
4461 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
4463 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
4464 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
4466 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(),
4470 void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF,
4474 SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, ObjCTypes.Int8PtrTy);
4475 DestPtr = CGF.Builder.CreateBitCast(DestPtr, ObjCTypes.Int8PtrTy);
4477 CGF.EmitNounwindRuntimeCall(ObjCTypes.GcMemmoveCollectableFn(), args);
4482 LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,
4489 return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
4490 EmitIvarOffset(CGF, ID, Ivar));
4493 llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,
4652 llvm::Value *CGObjCMac::EmitClassRefFromId(CodeGenFunction &CGF,
4668 return CGF.Builder.CreateAlignedLoad(Entry, CGF.getPointerAlign());
4671 llvm::Value *CGObjCMac::EmitClassRef(CodeGenFunction &CGF,
4676 return EmitClassRefViaRuntime(CGF, ID, ObjCTypes);
4678 return EmitClassRefFromId(CGF, ID->getIdentifier());
4681 llvm::Value *CGObjCMac::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) {
4683 return EmitClassRefFromId(CGF, II);
4686 llvm::Value *CGObjCMac::EmitSelector(CodeGenFunction &CGF, Selector Sel) {
4687 return CGF.Builder.CreateLoad(EmitSelectorAddr(CGF, Sel));
4690 Address CGObjCMac::EmitSelectorAddr(CodeGenFunction &CGF, Selector Sel) {
4691 CharUnits Align = CGF.getPointerAlign();
6125 llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF,
6138 CharUnits Align = CGF.getPointerAlign();
6142 return CGF.Builder.CreateAlignedLoad(PTGV, Align);
6153 return CGF.Builder.CreateAlignedLoad(PTGV, Align);
6676 CodeGen::CodeGenFunction &CGF,
6682 llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar);
6683 return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers,
6688 CodeGen::CodeGenFunction &CGF,
6692 IvarOffsetValue = CGF.Builder.CreateAlignedLoad(IvarOffsetValue,
6693 CGF.getSizeAlign(), "ivar");
6694 if (IsIvarOffsetKnownIdempotent(CGF, Ivar))
6703 IvarOffsetValue = CGF.Builder.CreateIntCast(
6732 CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,
6746 arg0 = CGF.Builder.CreateBitCast(arg0, ObjCTypes.ObjectPtrTy);
6773 nullReturn.init(CGF, arg0);
6818 nullReturn.init(CGF, arg0);
6825 Address(CGF.Builder.CreateBitCast(messageRef, ObjCTypes.MessageRefPtrTy),
6826 CGF.getPointerAlign());
6833 CGF.Builder.CreateStructGEP(mref, 0, CharUnits::Zero());
6834 llvm::Value *callee = CGF.Builder.CreateLoad(calleeAddr, "msgSend_fn");
6836 callee = CGF.Builder.CreateBitCast(callee, MSI.MessengerType);
6838 RValue result = CGF.EmitCall(MSI.CallInfo, callee, returnSlot, args);
6839 return nullReturn.complete(CGF, result, resultType, formalArgs,
6845 CGObjCNonFragileABIMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
6854 ? EmitVTableMessageSend(CGF, Return, ResultType, Sel,
6855 Receiver, CGF.getContext().getObjCIdType(),
6857 : EmitMessageSend(CGF, Return, ResultType,
6858 EmitSelector(CGF, Sel),
6859 Receiver, CGF.getContext().getObjCIdType(),
6879 llvm::Value *CGObjCNonFragileABIMac::EmitClassRefFromId(CodeGenFunction &CGF,
6883 CharUnits Align = CGF.getPointerAlign();
6897 return CGF.Builder.CreateAlignedLoad(Entry, Align);
6900 llvm::Value *CGObjCNonFragileABIMac::EmitClassRef(CodeGenFunction &CGF,
6905 return EmitClassRefViaRuntime(CGF, ID, ObjCTypes);
6907 return EmitClassRefFromId(CGF, ID->getIdentifier(), ID->isWeakImported(), ID);
6911 CodeGenFunction &CGF) {
6913 return EmitClassRefFromId(CGF, II, false, nullptr);
6917 CGObjCNonFragileABIMac::EmitSuperClassRef(CodeGenFunction &CGF,
6919 CharUnits Align = CGF.getPointerAlign();
6934 return CGF.Builder.CreateAlignedLoad(Entry, Align);
6940 llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CodeGenFunction &CGF,
6943 CharUnits Align = CGF.getPointerAlign();
6960 return CGF.Builder.CreateAlignedLoad(Entry, Align);
6965 llvm::Value *CGObjCNonFragileABIMac::GetClass(CodeGenFunction &CGF,
6975 return EmitClassRef(CGF, ID);
6982 CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
6996 CGF.CreateTempAlloca(ObjCTypes.SuperTy, CGF.getPointerAlign(),
7000 CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);
7001 CGF.Builder.CreateStore(
7003 CGF.Builder.CreateStructGEP(ObjCSuper, 0, CharUnits::Zero()));
7008 Target = EmitMetaClassRef(CGF, Class, Class->isWeakImported());
7010 Target = EmitSuperClassRef(CGF, Class);
7015 CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());
7016 Target = CGF.Builder.CreateBitCast(Target, ClassTy);
7017 CGF.Builder.CreateStore(
7018 Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1, CGF.getPointerSize()));
7021 ? EmitVTableMessageSend(CGF, Return, ResultType, Sel,
7024 : EmitMessageSend(CGF, Return, ResultType,
7025 EmitSelector(CGF, Sel),
7030 llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CodeGenFunction &CGF,
7032 Address Addr = EmitSelectorAddr(CGF, Sel);
7034 llvm::LoadInst* LI = CGF.Builder.CreateLoad(Addr);
7040 Address CGObjCNonFragileABIMac::EmitSelectorAddr(CodeGenFunction &CGF,
7044 CharUnits Align = CGF.getPointerAlign();
7064 void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF,
7072 src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
7073 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
7074 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
7076 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
7077 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
7079 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignIvarFn(), args);
7086 CodeGen::CodeGenFunction &CGF,
7092 src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
7093 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
7094 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
7096 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
7097 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
7099 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(),
7104 CodeGen::CodeGenFunction &CGF,
7108 SrcPtr = CGF.Builder.CreateBitCast(SrcPtr, ObjCTypes.Int8PtrTy);
7109 DestPtr = CGF.Builder.CreateBitCast(DestPtr, ObjCTypes.Int8PtrTy);
7111 CGF.EmitNounwindRuntimeCall(ObjCTypes.GcMemmoveCollectableFn(), args);
7118 CodeGen::CodeGenFunction &CGF,
7121 AddrWeakObj = CGF.Builder.CreateBitCast(AddrWeakObj, ObjCTypes.PtrObjectPtrTy);
7123 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcReadWeakFn(),
7125 read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy);
7132 void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF,
7138 src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
7139 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
7140 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
7142 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
7143 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
7145 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(),
7152 void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF,
7159 src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy)
7160 : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy));
7161 src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy);
7163 src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
7164 dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
7167 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(),
7170 CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(),
7175 CGObjCNonFragileABIMac::EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF,
7177 EmitAtSynchronizedStmt(CGF, S,
7207 void CGObjCNonFragileABIMac::EmitTryStmt(CodeGen::CodeGenFunction &CGF,
7209 EmitTryCatchStmt(CGF, S,
7216 void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF,
7220 llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr);
7221 Exception = CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy);
7222 CGF.EmitRuntimeCallOrInvoke(ObjCTypes.getExceptionThrowFn(), Exception)
7225 CGF.EmitRuntimeCallOrInvoke(ObjCTypes.getExceptionRethrowFn())
7229 CGF.Builder.CreateUnreachable();
7231 CGF.Builder.ClearInsertionPoint();