Home | History | Annotate | Download | only in CodeGen

Lines Matching full:cgf

33 tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e);
34 static RValue AdjustObjCObjectType(CodeGenFunction &CGF,
251 static RValue AdjustObjCObjectType(CodeGenFunction &CGF, QualType ExpT,
257 llvm::Type *ExpLLVMTy = CGF.ConvertType(ExpT);
262 return RValue::get(CGF.Builder.CreateBitCast(Result.getScalarVal(),
489 void Emit(CodeGenFunction &CGF, Flags flags) override {
490 const ObjCMethodDecl *method = cast<ObjCMethodDecl>(CGF.CurCodeDecl);
499 llvm::Value *self = CGF.LoadObjCSelf();
502 CGF.CGM.getObjCRuntime().GenerateMessageSendSuper(CGF, ReturnValueSlot(),
503 CGF.getContext().VoidTy,
553 static llvm::Value *emitARCRetainLoadOfScalar(CodeGenFunction &CGF,
569 static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar,
571 ASTContext &Context = CGF.getContext();
574 CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0)
581 Address dest = CGF.Builder.CreateBitCast(CGF.ReturnValue, CGF.VoidPtrTy);
584 src = CGF.Builder.CreateBitCast(src, CGF.VoidPtrTy);
587 CharUnits size = CGF.getContext().getTypeSizeInChars(ivar->getType());
588 args.add(RValue::get(CGF.CGM.getSize(size)), Context.getSizeType());
589 args.add(RValue::get(CGF.Builder.getInt1(isAtomic)), Context.BoolTy);
590 args.add(RValue::get(CGF.Builder.getInt1(hasStrong)), Context.BoolTy);
592 llvm::Value *fn = CGF.CGM.getObjCRuntime().GetGetStructFunction();
593 CGF.EmitCall(CGF.getTypes().arrangeBuiltinFunctionCall(Context.VoidTy, args),
834 static void emitCPPObjectAtomicGetterCall(CodeGenFunction &CGF,
843 args.add(RValue::get(returnAddr), CGF.getContext().VoidPtrTy);
847 CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(),
848 CGF.LoadObjCSelf(), ivar, 0).getPointer();
849 ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy);
850 args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy);
853 args.add(RValue::get(AtomicHelperFn), CGF.getContext().VoidPtrTy);
856 CGF
857 CGF.EmitCall(
858 CGF.getTypes().arrangeBuiltinFunctionCall(CGF.getContext().VoidTy, args),
1038 static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD,
1045 llvm::Value *ivarAddr = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(),
1046 CGF.LoadObjCSelf(), ivar, 0)
1048 ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy);
1049 args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy);
1055 llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer();
1056 argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
1057 args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy);
1061 CGF.CGM.getSize(CGF.getContext().getTypeSizeInChars(ivar->getType()));
1062 args.add(RValue::get(size), CGF.getContext().getSizeType());
1065 args.add(RValue::get(CGF.Builder.getTrue()), CGF.getContext().BoolTy);
1069 args.add(RValue::get(CGF.Builder.getFalse()), CGF.getContext().BoolTy);
1071 llvm::Value *copyStructFn = CGF.CGM.getObjCRuntime().GetSetStructFunction();
1072 CGF.EmitCall(
1073 CGF.getTypes().arrangeBuiltinFunctionCall(CGF.getContext().VoidTy, args),
1080 static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF,
1090 CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(),
1091 CGF.LoadObjCSelf(), ivar, 0).getPointer();
1092 ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy);
1093 args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy);
1099 llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer();
1100 argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy);
1101 args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy);
1104 args.add(RValue::get(AtomicHelperFn), CGF.getContext().VoidPtrTy);
1107 CGF.CGM.getObjCRuntime().GetCppAtomicObjectSetFunction();
1108 CGF.EmitCall(
1109 CGF.getTypes().arrangeBuiltinFunctionCall(CGF.getContext().VoidTy, args),
1349 void Emit(CodeGenFunction &CGF, Flags flags) override {
1351 = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), addr, ivar, /*CVR*/ 0);
1352 CGF.emitDestroy(lvalue.getAddress(), ivar->getType(), destroyer,
1359 static void destroyARCStrongWithStore(CodeGenFunction &CGF,
1363 CGF.EmitARCStoreStrongCall(addr, null, /*ignored*/ true);
1366 static void emitCXXDestructMethod(CodeGenFunction &CGF,
1368 CodeGenFunction::RunCleanupsScope scope(CGF);
1370 llvm::Value *self = CGF.LoadObjCSelf();
1390 destroyer = CGF.getDestroyer(dtorKind);
1393 CleanupKind cleanupKind = CGF.getCleanupKind(dtorKind);
1395 CGF.EHStack.pushCleanup<DestroyIvar>(cleanupKind, self, ivar, destroyer,
1759 void Emit(CodeGenFunction &CGF, Flags flags) override {
1761 CGF.EmitARCRelease(object, ARCImpreciseLifetime);
1821 static llvm::Value *emitARCValueOperation(CodeGenFunction &CGF,
1830 llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrTy, false);
1831 fn = createARCRuntimeFunction(CGF.CGM, fnType, fnName);
1836 value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy);
1839 llvm::CallInst *call = CGF.EmitNounwindRuntimeCall(fn, value);
1844 return CGF.Builder.CreateBitCast(call, origType);
1849 static llvm::Value *emitARCLoadOperation(CodeGenFunction &CGF,
1855 llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrPtrTy, false);
1856 fn = createARCRuntimeFunction(CGF.CGM, fnType, fnName);
1861 addr = CGF.Builder.CreateBitCast(addr, CGF.Int8PtrPtrTy);
1864 llvm::Value *result = CGF.EmitNounwindRuntimeCall(fn, addr.getPointer());
1867 if (origType != CGF.Int8PtrTy)
1868 result = CGF.Builder.CreateBitCast(result, origType);
1875 static llvm::Value *emitARCStoreOperation(CodeGenFunction &CGF,
1884 llvm::Type *argTypes[] = { CGF.Int8PtrPtrTy, CGF.Int8PtrTy };
1887 = llvm::FunctionType::get(CGF.Int8PtrTy, argTypes, false);
1888 fn = createARCRuntimeFunction(CGF.CGM, fnType, fnName);
1894 CGF.Builder.CreateBitCast(addr.getPointer(), CGF.Int8PtrPtrTy),
1895 CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy)
1897 llvm::CallInst *result = CGF.EmitNounwindRuntimeCall(fn, args);
1901 return CGF.Builder.CreateBitCast(result, origType);
1906 static void emitARCCopyOperation(CodeGenFunction &CGF,
1914 llvm::Type *argTypes[] = { CGF.Int8PtrPtrTy, CGF.Int8PtrPtrTy };
1917 = llvm::FunctionType::get(CGF.Builder.getVoidTy(), argTypes, false);
1918 fn = createARCRuntimeFunction(CGF.CGM, fnType, fnName);
1922 CGF.Builder.CreateBitCast(dst.getPointer(), CGF.Int8PtrPtrTy),
1923 CGF.Builder.CreateBitCast(src.getPointer(), CGF.Int8PtrPtrTy)
1925 CGF.EmitNounwindRuntimeCall(fn, args);
1975 static void emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF) {
1979 = CGF.CGM.getObjCEntrypoints().retainAutoreleasedReturnValueMarker;
1982 = CGF.CGM.getTargetCodeGenInfo()
1990 } else if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) {
1992 llvm::FunctionType::get(CGF.VoidTy, /*variadic*/false);
2001 CGF.CGM.getModule().getOrInsertNamedMetadata(
2005 auto &ctx = CGF.getLLVMContext();
2014 CGF.Builder.CreateCall(marker);
2357 void CodeGenFunction::destroyARCStrongPrecise(CodeGenFunction &CGF,
2360 CGF.EmitARCDestroyStrong(addr, ARCPreciseLifetime);
2363 void CodeGenFunction::destroyARCStrongImprecise(CodeGenFunction &CGF,
2366 CGF.EmitARCDestroyStrong(addr, ARCImpreciseLifetime);
2369 void CodeGenFunction::destroyARCWeak(CodeGenFunction &CGF,
2372 CGF.EmitARCDestroyWeak(addr);
2381 void Emit(CodeGenFunction &CGF, Flags flags) override {
2382 CGF.EmitObjCAutoreleasePoolPop(Token);
2390 void Emit(CodeGenFunction &CGF, Flags flags) override {
2391 CGF.EmitObjCMRRAutoreleasePoolPop(Token);
2403 static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF,
2411 return TryEmitResult(CGF.EmitLoadOfLValue(lvalue,
2416 return TryEmitResult(CGF.EmitARCLoadWeakRetained(lvalue.getAddress()),
2423 static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF,
2435 LValue lv = CGF.EmitLValue(e);
2438 llvm::Value *result = CGF.EmitLoadOfLValue(lv,
2442 CGF.EmitStoreOfScalar(getNullForVariable(lv.getAddress()), lv);
2450 if (CGF.getLangOpts().CPlusPlus &&
2455 return TryEmitResult(CGF.EmitScalarExpr(e), false);
2457 return tryEmitARCRetainLoadOfScalar(CGF, CGF.EmitLValue(e), type);
2460 typedef llvm::function_ref<llvm::Value *(CodeGenFunction &CGF,
2465 static llvm::Value *emitARCOperationAfterCall(CodeGenFunction &CGF,
2470 CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
2473 CGF.Builder.SetInsertPoint(call->getParent(),
2475 value = doAfterCall(CGF, value);
2477 CGF.Builder.restoreIP(ip);
2480 CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP();
2484 CGF.Builder.SetInsertPoint(BB, BB->begin());
2485 value = doAfterCall(CGF, value);
2487 CGF.Builder.restoreIP(ip);
2494 operand = emitARCOperationAfterCall(CGF, operand, doAfterCall, doFallback);
2502 return doFallback(CGF, value);
2508 static llvm::Value *emitARCRetainCallResult(CodeGenFunction &CGF,
2510 llvm::Value *value = CGF.EmitScalarExpr(e);
2511 return emitARCOperationAfterCall(CGF, value,
2512 [](CodeGenFunction &CGF, llvm::Value *value) {
2513 return CGF.EmitARCRetainAutoreleasedReturnValue(value);
2515 [](CodeGenFunction &CGF, llvm::Value *value) {
2516 return CGF.EmitARCRetainNonBlock(value);
2522 static llvm::Value *emitARCUnsafeClaimCallResult(CodeGenFunction &CGF,
2524 llvm::Value *value = CGF.EmitScalarExpr(e);
2525 return emitARCOperationAfterCall(CGF, value,
2526 [](CodeGenFunction &CGF, llvm::Value *value) {
2527 return CGF.EmitARCUnsafeClaimAutoreleasedReturnValue(value);
2529 CGF, llvm::Value *value) {
2586 CodeGenFunction &CGF;
2589 ARCExprEmitter(CodeGenFunction &CGF) : CGF(CGF) {}
2643 opaqueData = OVMA::bind(CGF, ov,
2648 opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr());
2659 CGF.EmitIgnoredExpr(semantic);
2665 opaques[i].unbind(CGF);
2683 llvm::Type *resultType = CGF.ConvertType(e->getType());
2710 CGF.EmitIgnoredExpr(e->getLHS());
2711 CGF.EnsureInsertPoint();
2754 CGF.EmitCheckedLValue(e->getLHS(), CodeGenFunction::TCK_Store);
2755 CGF.EmitStoreThroughLValue(RValue::get(asImpl().getValueOfResult(result)),
2824 ARCRetainExprEmitter(CodeGenFunction &CGF) : ARCExprEmitter(CGF) {}
2832 value = CGF.Builder.CreateBitCast(value, resultType);
2838 return tryEmitARCRetainLoadOfScalar(CGF, e);
2844 llvm::Value *result = CGF.EmitScalarExpr(e);
2857 result = CGF.EmitScalarExpr(e);
2873 result = CGF.EmitARCRetainBlock(result, /*mandatory*/ true);
2880 llvm::Value *result = emitARCRetainCallResult(CGF, e);
2886 llvm::Value *result = emitARCRetainCallResult(CGF, e);
2895 llvm::Value *result = CGF.EmitScalarExpr(e);
2902 tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e) {
2903 return ARCRetainExprEmitter(CGF).visit(e);
2906 static llvm::Value *emitARCRetainLoadOfScalar(CodeGenFunction &CGF,
2909 TryEmitResult result = tryEmitARCRetainLoadOfScalar(CGF, lvalue, type);
2912 value = CGF.EmitARCRetain(type, value);
2993 ARCUnsafeUnretainedExprEmitter(CodeGenFunction &CGF) : ARCExprEmitter(CGF) {}
3000 return CGF.Builder.CreateBitCast(value, resultType);
3004 return CGF.EmitScalarExpr(e);
3010 llvm::Value *value = CGF.EmitScalarExpr(e);
3011 return CGF.EmitObjCConsumeObject(e->getType(), value);
3017 return CGF.EmitARCExtendBlockObject(e);
3022 return CGF.EmitARCReclaimReturnedObject(e, /*unsafe*/ true);
3028 return CGF.EmitScalarExpr(e);
3033 return CGF.EmitScalarExpr(e);
3038 static llvm::Value *emitARCUnsafeUnretainedScalarExpr(CodeGenFunction &CGF,
3040 return ARCUnsafeUnretainedExprEmitter(CGF).visit(e);