Home | History | Annotate | Download | only in CodeGen

Lines Matching full:cgf

931 static void forConstantArrayExpansion(CodeGenFunction &CGF,
935 CharUnits EltSize = CGF.getContext().getTypeSizeInChars(CAE->EltTy);
941 CGF.Builder.CreateConstGEP2_32(nullptr, BaseAddr.getPointer(), 0, i);
1036 static Address CreateTempAllocaForCoercion(CodeGenFunction &CGF, llvm::Type *Ty,
1039 auto PrefAlign = CGF.CGM.getDataLayout().getPrefTypeAlignment(Ty);
1042 return CGF.CreateTempAlloca(Ty, Align);
1052 uint64_t DstSize, CodeGenFunction &CGF) {
1063 CGF.CGM.getDataLayout().getTypeStoreSize(FirstElt);
1065 FirstEltSize < CGF.CGM.getDataLayout().getTypeStoreSize(SrcSTy))
1069 SrcPtr = CGF.Builder.CreateStructGEP(SrcPtr, 0, CharUnits(), "coerce.dive");
1074 return EnterStructPointerForCoercedAccess(SrcPtr, SrcSTy, DstSize, CGF);
1088 CodeGenFunction &CGF) {
1095 return CGF.Builder.CreateBitCast(Val, Ty, "coerce.val");
1098 Val = CGF.Builder.CreatePtrToInt(Val, CGF.IntPtrTy, "coerce.val.pi");
1103 DestIntTy = CGF.IntPtrTy;
1106 const llvm::DataLayout &DL = CGF.CGM.getDataLayout();
1114 Val = CGF.Builder.CreateLShr(Val, SrcSize - DstSize, "coerce.highbits");
1115 Val = CGF.Builder.CreateTrunc(Val, DestIntTy, "coerce.val.ii");
1117 Val = CGF.Builder.CreateZExt(Val, DestIntTy, "coerce.val.ii");
1118 Val = CGF.Builder.CreateShl(Val, DstSize - SrcSize, "coerce.highbits");
1122 Val = CGF.Builder.CreateIntCast(Val, DestIntTy, false, "coerce.val.ii");
1127 Val = CGF.Builder.CreateIntToPtr(Val, Ty, "coerce.val.ip");
1141 CodeGenFunction &CGF) {
1146 return CGF.Builder.CreateLoad(Src);
1148 uint64_t DstSize = CGF.CGM.getDataLayout().getTypeAllocSize(Ty);
1151 Src = EnterStructPointerForCoercedAccess(Src, SrcSTy, DstSize, CGF);
1155 uint64_t SrcSize = CGF.CGM.getDataLayout().getTypeAllocSize(SrcTy);
1161 llvm::Value *Load = CGF.Builder.CreateLoad(Src);
1162 return CoerceIntOrPtrToIntOrPtr(Load, Ty, CGF);
1173 Src = CGF.Builder.CreateBitCast(Src, llvm::PointerType::getUnqual(Ty));
1174 return CGF.Builder.CreateLoad(Src);
1178 Address Tmp = CreateTempAllocaForCoercion(CGF, Ty, Src.getAlignment());
1179 Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.Int8PtrTy);
1180 Address SrcCasted = CGF.Builder.CreateBitCast(Src, CGF.Int8PtrTy);
1181 CGF.Builder.CreateMemCpy(Casted, SrcCasted,
1182 llvm::ConstantInt::get(CGF.IntPtrTy, SrcSize),
1184 return CGF.Builder.CreateLoad(Tmp);
1191 static void BuildAggStore(CodeGenFunction &CGF, llvm::Value *Val,
1197 CGF.CGM.getDataLayout().getStructLayout(STy);
1201 Address EltPtr = CGF.Builder.CreateStructGEP(Dest, i, EltOffset);
1202 llvm::Value *Elt = CGF.Builder.CreateExtractValue(Val, i);
1203 CGF.Builder.CreateStore(Elt, EltPtr, DestIsVolatile);
1206 CGF.Builder.CreateStore(Val, Dest, DestIsVolatile);
1219 CodeGenFunction &CGF) {
1223 CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
1227 uint64_t SrcSize = CGF.CGM.getDataLayout().getTypeAllocSize(SrcTy);
1230 Dst = EnterStructPointerForCoercedAccess(Dst, DstSTy, SrcSize, CGF);
1238 Src = CoerceIntOrPtrToIntOrPtr(Src, DstTy, CGF);
1239 CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
1243 uint64_t DstSize = CGF.CGM.getDataLayout().getTypeAllocSize(DstTy);
1247 Dst = CGF.Builder.CreateBitCast(Dst, llvm::PointerType::getUnqual(SrcTy));
1248 BuildAggStore(CGF, Src, Dst, DstIsVolatile);
1259 Address Tmp = CreateTempAllocaForCoercion(CGF, SrcTy, Dst.getAlignment());
1260 CGF.Builder.CreateStore(Src, Tmp);
1261 Address Casted = CGF.Builder.CreateBitCast(Tmp, CGF.Int8PtrTy);
1262 Address DstCasted = CGF.Builder.CreateBitCast(Dst, CGF.Int8PtrTy);
1263 CGF.Builder.CreateMemCpy(DstCasted, Casted,
1264 llvm::ConstantInt::get(CGF.IntPtrTy, DstSize),
1269 static Address emitAddressAtOffset(CodeGenFunction &CGF, Address addr,
1272 addr = CGF.Builder.CreateElementBitCast(addr, CGF.Int8Ty);
1273 addr = CGF.Builder.CreateConstInBoundsByteGEP(addr,
1275 addr = CGF.Builder.CreateElementBitCast(addr, info.getCoerceToType());
2014 static llvm::Value *emitArgumentDemotion(CodeGenFunction &CGF,
2017 llvm::Type *varType = CGF.ConvertType(var->getType());
2027 return CGF.Builder.CreateTrunc(value, varType, "arg.unpromote");
2029 return CGF.Builder.CreateFPCast(value, varType, "arg.unpromote");
2065 void Emit(CodeGenFunction &CGF, Flags flags) override {
2066 llvm::Value *errorValue = CGF.Builder.CreateLoad(Temp);
2067 CGF.Builder.CreateStore(errorValue, Arg);
2456 static llvm::Value *tryEmitFusedAutoreleaseOfResult(CodeGenFunction &CGF,
2459 llvm::BasicBlock *BB = CGF.Builder.GetInsertBlock();
2493 if (call->getCalledValue() == CGF.CGM.getObjCEntrypoints().objc_retain) {
2495 } else if (call->getCalledValue() == CGF.CGM.getObjCEntrypoints()
2504 if (CGF.CGM.getObjCEntrypoints().retainAutoreleasedReturnValueMarker) {
2513 CGF.CGM.getObjCEntrypoints().retainAutoreleasedReturnValueMarker);
2538 result = CGF.EmitARCRetainAutoreleaseReturnValue(result);
2541 return CGF.Builder.CreateBitCast(result, resultType);
2545 static llvm::Value *tryRemoveRetainOfSelf(CodeGenFunction &CGF,
2549 dyn_cast_or_null<ObjCMethodDecl>(CGF.CurCodeDecl);
2558 retainCall->getCalledValue() != CGF.CGM.getObjCEntrypoints().objc_retain)
2566 load->getPointerOperand() != CGF.GetAddrOfLocalVar(self).getPointer())
2578 return CGF.Builder.CreateBitCast(load, resultType);
2584 static llvm::Value *emitAutoreleaseOfResult(CodeGenFunction &CGF,
2590 if (llvm::Value *self = tryRemoveRetainOfSelf(CGF, result))
2594 if (CGF.shouldUseFusedARCCalls())
2595 if (llvm::Value *fused = tryEmitFusedAutoreleaseOfResult(CGF, result))
2598 return CGF.EmitARCAutoreleaseReturnValue(result);
2602 static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
2606 auto GetStoreIfValid = [&CGF](llvm::User *U) -> llvm::StoreInst * {
2608 if (!SI || SI->getPointerOperand() != CGF.ReturnValue.getPointer())
2619 if (!CGF.ReturnValue.getPointer()->hasOneUse()) {
2620 llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock();
2647 GetStoreIfValid(CGF.ReturnValue.getPointer()->user_back());
2653 llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock();
2861 static AggValueSlot createPlaceholderSlot(CodeGenFunction &CGF,
2865 llvm::Type *IRTy = CGF.ConvertTypeForMem(Ty);
2868 Placeholder = CGF.Builder.CreateDefaultAlignedLoad(Placeholder);
2911 static void emitWriteback(CodeGenFunction &CGF,
2924 llvm::BasicBlock *writebackBB = CGF.createBasicBlock("icr.writeback");
2925 contBB = CGF.createBasicBlock("icr.done");
2928 CGF.Builder.CreateIsNull(srcAddr.getPointer(), "icr.isnull");
2929 CGF.Builder.CreateCondBr(isNull, contBB, writebackBB);
2930 CGF.EmitBlock(writebackBB);
2934 llvm::Value *value = CGF.Builder.CreateLoad(writeback.Temporary);
2937 value = CGF.Builder.CreateBitCast(value, srcAddr.getElementType(),
2952 value = CGF.EmitARCRetainNonBlock(value);
2955 CGF.EmitARCIntrinsicUse(writeback.ToUse);
2958 llvm::Value *oldValue = CGF.EmitLoadOfScalar(srcLV, SourceLocation());
2961 CGF.EmitStoreOfScalar(value, srcLV, /*init*/ false);
2964 CGF.EmitARCRelease(oldValue, srcLV.isARCPreciseLifetime());
2968 CGF.EmitStoreThroughLValue(RValue::get(value), srcLV);
2973 CGF.EmitBlock(contBB);
2976 static void emitWritebacks(CodeGenFunction &CGF,
2979 emitWriteback(CGF, I);
2982 static void deactivateArgCleanupsBeforeCall(CodeGenFunction &CGF,
2984 assert(CGF.getTarget().getCXXABI().areArgsDestroyedLeftToRightInCallee());
2989 CGF.DeactivateCleanupBlock(I.Cleanup, I.IsActiveIP);
3005 static void emitWritebackArg(CodeGenFunction &CGF, CallArgList &args,
3012 srcLV = CGF.EmitLValue(lvExpr);
3016 Address srcAddr = CGF.EmitPointerWithAlignment(CRE->getSubExpr());
3020 srcLV = CGF.MakeAddrLValue(srcAddr, srcAddrType);
3028 cast<llvm::PointerType>(CGF.ConvertType(CRE->getType()));
3038 Address temp = CGF.CreateTempAlloca(destType->getElementType(),
3039 CGF.getPointerAlign(),
3045 CodeGenFunction::ConditionalEvaluation condEval(CGF);
3053 CGF.Builder.CreateStore(null, temp);
3067 CGF.Builder.CreateIsNull(srcAddr.getPointer(), "icr.isnull");
3069 finalArgument = CGF.Builder.CreateSelect(isNull,
3076 originBB = CGF.Builder.GetInsertBlock();
3077 contBB = CGF.createBasicBlock("icr.cont");
3078 llvm::BasicBlock *copyBB = CGF.createBasicBlock("icr.copy");
3079 CGF.Builder.CreateCondBr(isNull, contBB, copyBB);
3080 CGF.EmitBlock(copyBB);
3081 condEval.begin(CGF);
3089 RValue srcRV = CGF.EmitLoadOfLValue(srcLV, SourceLocation());
3093 src = CGF.Builder.CreateBitCast(src, destType->getElementType(),
3097 CGF.Builder.CreateStore(src, temp);
3104 if (CGF.CGM.getCodeGenOpts().OptimizationLevel != 0 &&
3112 llvm::BasicBlock *copyBB = CGF.Builder.GetInsertBlock();
3113 CGF.EmitBlock(contBB);
3117 llvm::PHINode *phiToUse = CGF.Builder.CreatePHI(valueToUse->getType(), 2,
3125 condEval.end(CGF);
3132 void CallArgList::allocateArgumentMemory(CodeGenFunction &CGF) {
3136 llvm::Function *F = CGF.CGM.getIntrinsic(llvm::Intrinsic::stacksave);
3137 StackBase = CGF.Builder.CreateCall(F, {}, "inalloca.save");
3140 void CallArgList::freeArgumentMemory(CodeGenFunction &CGF) const {
3143 llvm::Value *F = CGF.CGM.getIntrinsic(llvm::Intrinsic::stackrestore);
3144 CGF.Builder.CreateCall(F, StackBase);
3241 void Emit(CodeGenFunction &CGF, Flags flags) override {
3244 CGF.EmitCXXDestructorCall(Dtor, Dtor_Complete, /*for vbase*/ false,
3250 CodeGenFunction &CGF;
3252 DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) {
3253 if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.getDebugInfo()))
3254 CGF.disableDebugInfo();
3258 CGF.enableDebugInfo();
3494 static void EmitInitStoreOfNonAggregate(CodeGenFunction &CGF, RValue Src,
3497 CGF.EmitStoreOfScalar(Src.getScalarVal(), Dst, /*init=*/true);
3499 CGF.EmitStoreOfComplex(Src.getComplexVal(), Dst, /*init=*/true);