Lines Matching refs:CGF
62 CodeGenFunction &CGF; member in __anonbb924e660111::ScalarExprEmitter
69 : CGF(cgf), Builder(CGF.Builder), IgnoreResultAssign(ira), in ScalarExprEmitter()
83 llvm::Type *ConvertType(QualType T) { return CGF.ConvertType(T); } in ConvertType()
84 LValue EmitLValue(const Expr *E) { return CGF.EmitLValue(E); } in EmitLValue()
86 return CGF.EmitCheckedLValue(E, TCK); in EmitCheckedLValue()
93 return CGF.EmitLoadOfLValue(LV, Loc).getScalarVal(); in EmitLoadOfLValue()
123 Value *AlignmentValue = CGF.EmitScalarExpr(AVAttr->getAlignment()); in EmitLValueAlignmentAssumption()
125 CGF.EmitAlignmentAssumption(V, AlignmentCI->getZExtValue()); in EmitLValueAlignmentAssumption()
204 ApplyDebugLocation DL(CGF, E); in Visit()
209 S->dump(CGF.getContext().getSourceManager()); in VisitStmt()
249 llvm::Value *V = CGF.GetAddrOfLabel(E->getLabel()); in VisitAddrLabelExpr()
258 return CGF.EmitPseudoObjectRValue(E).getScalarVal(); in VisitPseudoObjectExpr()
263 return EmitLoadOfLValue(CGF.getOpaqueLValueMapping(E), E->getExprLoc()); in VisitOpaqueValueExpr()
266 return CGF.getOpaqueRValueMapping(E).getScalarVal(); in VisitOpaqueValueExpr()
271 if (CodeGenFunction::ConstantEmission result = CGF.tryEmitAsConstant(E)) { in VisitDeclRefExpr()
273 return EmitLoadOfLValue(result.getReferenceLValue(CGF, E), in VisitDeclRefExpr()
281 return CGF.EmitObjCSelectorExpr(E); in VisitObjCSelectorExpr()
284 return CGF.EmitObjCProtocolExpr(E); in VisitObjCProtocolExpr()
293 return CGF.EmitObjCMessageExpr(E).getScalarVal(); in VisitObjCMessageExpr()
297 LValue LV = CGF.EmitObjCIsaExpr(E); in VisitObjCIsaExpr()
298 Value *V = CGF.EmitLoadOfLValue(LV, E->getExprLoc()).getScalarVal(); in VisitObjCIsaExpr()
317 CGF.CGM.EmitExplicitCastExprType(E, &CGF); in VisitExplicitCastExpr()
323 if (E->getCallReturnType(CGF.getContext())->isReferenceType()) in VisitCallExpr()
326 Value *V = CGF.EmitCallExpr(E).getScalarVal(); in VisitCallExpr()
362 return CGF.CGM.getMemberPointerConstant(E); in VisitUnaryAddrOf()
394 CodeGenFunction::CXXDefaultInitExprScope Scope(CGF); in VisitCXXDefaultInitExpr()
398 return CGF.LoadCXXThis(); in VisitCXXThisExpr()
402 CGF.enterFullExpression(E); in VisitExprWithCleanups()
403 CodeGenFunction::RunCleanupsScope Scope(CGF); in VisitExprWithCleanups()
407 return CGF.EmitCXXNewExpr(E); in VisitCXXNewExpr()
410 CGF.EmitCXXDeleteExpr(E); in VisitCXXDeleteExpr()
432 CGF.EmitScalarExpr(E->getBase()); in VisitCXXPseudoDestructorExpr()
441 CGF.EmitCXXThrowExpr(E); in VisitCXXThrowExpr()
452 switch (CGF.getLangOpts().getSignedOverflowBehavior()) { in EmitMul()
456 if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) in EmitMul()
465 CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) in EmitMul()
556 return CGF.EmitObjCStringLiteral(E); in VisitObjCStringLiteral()
559 return CGF.EmitObjCBoxedExpr(E); in VisitObjCBoxedExpr()
562 return CGF.EmitObjCArrayLiteral(E); in VisitObjCArrayLiteral()
565 return CGF.EmitObjCDictionaryLiteral(E); in VisitObjCDictionaryLiteral()
585 return CGF.CGM.getCXXABI().EmitMemberPointerIsNotNull(CGF, Src, MPT); in EmitConversionToBool()
600 CodeGenFunction::SanitizerScope SanScope(&CGF); in EmitFloatConversionCheck()
614 APFloat::getLargest(CGF.getContext().getFloatTypeSemantics(DstType)); in EmitFloatConversionCheck()
635 CGF.getContext().getFloatTypeSemantics(OrigSrcType); in EmitFloatConversionCheck()
640 unsigned Width = CGF.getContext().getIntWidth(DstType); in EmitFloatConversionCheck()
671 CGF.getContext().getFloatTypeSemantics(SrcType); in EmitFloatConversionCheck()
698 if (CGF.getContext().getFloatingTypeOrder(OrigSrcType, DstType) != 1) in EmitFloatConversionCheck()
705 CGF.getContext().getFloatTypeSemantics(DstType); in EmitFloatConversionCheck()
713 Value *AbsSrc = CGF.EmitNounwindRuntimeCall( in EmitFloatConversionCheck()
714 CGF.CGM.getIntrinsic(llvm::Intrinsic::fabs, Src->getType()), Src); in EmitFloatConversionCheck()
723 llvm::Constant *StaticArgs[] = {CGF.EmitCheckSourceLocation(Loc), in EmitFloatConversionCheck()
724 CGF.EmitCheckTypeDescriptor(OrigSrcType), in EmitFloatConversionCheck()
725 CGF.EmitCheckTypeDescriptor(DstType)}; in EmitFloatConversionCheck()
726 CGF.EmitCheck(std::make_pair(Check, SanitizerKind::FloatCastOverflow), in EmitFloatConversionCheck()
742 SrcType = CGF.getContext().getCanonicalType(SrcType); in EmitScalarConversion()
743 DstType = CGF.getContext().getCanonicalType(DstType); in EmitScalarConversion()
759 if (SrcType->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) { in EmitScalarConversion()
762 if (!CGF.getContext().getLangOpts().HalfArgsAndReturns) in EmitScalarConversion()
764 CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_from_fp16, DstTy), in EmitScalarConversion()
770 if (!CGF.getContext().getLangOpts().HalfArgsAndReturns) { in EmitScalarConversion()
772 CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_from_fp16, in EmitScalarConversion()
773 CGF.CGM.FloatTy), in EmitScalarConversion()
776 Src = Builder.CreateFPExt(Src, CGF.CGM.FloatTy, "conv"); in EmitScalarConversion()
778 SrcType = CGF.getContext().FloatTy; in EmitScalarConversion()
779 SrcTy = CGF.FloatTy; in EmitScalarConversion()
798 llvm::Type *MiddleTy = CGF.IntPtrTy; in EmitScalarConversion()
836 if (CGF.SanOpts.has(SanitizerKind::FloatCastOverflow) && in EmitScalarConversion()
842 if (DstType->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) { in EmitScalarConversion()
847 if (!CGF.getContext().getLangOpts().HalfArgsAndReturns) in EmitScalarConversion()
849 CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_to_fp16, SrcTy), Src); in EmitScalarConversion()
853 DstTy = CGF.FloatTy; in EmitScalarConversion()
883 if (!CGF.getContext().getLangOpts().HalfArgsAndReturns) { in EmitScalarConversion()
886 CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_to_fp16, CGF.CGM.FloatTy), in EmitScalarConversion()
920 return CGF.EmitFromMemory(CGF.CGM.EmitNullConstant(Ty), Ty); in EmitNullValue()
929 assert(CGF.IsSanitizerScope); in EmitBinOpCheck()
938 StaticData.push_back(CGF.EmitCheckSourceLocation(Info.E->getExprLoc())); in EmitBinOpCheck()
942 StaticData.push_back(CGF.EmitCheckTypeDescriptor(UO->getType())); in EmitBinOpCheck()
950 CGF.EmitCheckTypeDescriptor(BO->getLHS()->getType())); in EmitBinOpCheck()
952 CGF.EmitCheckTypeDescriptor(BO->getRHS()->getType())); in EmitBinOpCheck()
956 StaticData.push_back(CGF.EmitCheckTypeDescriptor(Info.Ty)); in EmitBinOpCheck()
965 StaticData.push_back(CGF.EmitCheckTypeDescriptor(Info.Ty)); in EmitBinOpCheck()
971 CGF.EmitCheck(Checks, CheckName, StaticData, DynamicData); in EmitBinOpCheck()
979 CGF.ErrorUnsupported(E, "scalar expression"); in VisitExpr()
982 return llvm::UndefValue::get(CGF.ConvertType(E->getType())); in VisitExpr()
988 Value *LHS = CGF.EmitScalarExpr(E->getExpr(0)); in VisitShuffleVectorExpr()
989 Value *RHS = CGF.EmitScalarExpr(E->getExpr(1)); in VisitShuffleVectorExpr()
1014 Value *IIndx = llvm::ConstantInt::get(CGF.SizeTy, i); in VisitShuffleVectorExpr()
1023 Value* V1 = CGF.EmitScalarExpr(E->getExpr(0)); in VisitShuffleVectorExpr()
1024 Value* V2 = CGF.EmitScalarExpr(E->getExpr(1)); in VisitShuffleVectorExpr()
1028 llvm::APSInt Idx = E->getShuffleMaskIdx(CGF.getContext(), i-2); in VisitShuffleVectorExpr()
1031 indices.push_back(llvm::UndefValue::get(CGF.Int32Ty)); in VisitShuffleVectorExpr()
1044 Value *Src = CGF.EmitScalarExpr(E->getSrcExpr()); in VisitConvertVectorExpr()
1046 SrcType = CGF.getContext().getCanonicalType(SrcType); in VisitConvertVectorExpr()
1047 DstType = CGF.getContext().getCanonicalType(DstType); in VisitConvertVectorExpr()
1116 if (E->EvaluateAsInt(Value, CGF.getContext(), Expr::SE_AllowSideEffects)) { in VisitMemberExpr()
1118 CGF.EmitScalarExpr(E->getBase()); in VisitMemberExpr()
1143 if (CGF.SanOpts.has(SanitizerKind::ArrayBounds)) in VisitArraySubscriptExpr()
1144 CGF.EmitBoundsCheck(E, E->getBase(), Idx, IdxTy, /*Accessed*/true); in VisitArraySubscriptExpr()
1174 CGF.ErrorUnsupported(E, "GNU array range designator extension"); in VisitInitListExpr()
1218 Args.push_back(getAsInt32(C, CGF.Int32Ty)); in VisitInitListExpr()
1219 Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty)); in VisitInitListExpr()
1228 Args.push_back(getMaskElt(SVV, j, 0, CGF.Int32Ty)); in VisitInitListExpr()
1230 Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty)); in VisitInitListExpr()
1268 CGF.Int32Ty)); in VisitInitListExpr()
1274 Args.push_back(getMaskElt(SVI, j, Offset, CGF.Int32Ty)); in VisitInitListExpr()
1275 Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty)); in VisitInitListExpr()
1289 Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty)); in VisitInitListExpr()
1299 Args.resize(ResElts, llvm::UndefValue::get(CGF.Int32Ty)); in VisitInitListExpr()
1368 Addr = Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(DestTy)); in VisitCastExpr()
1369 LValue LV = CGF.MakeAddrLValue(Addr, DestTy); in VisitCastExpr()
1386 if (CGF.SanOpts.has(SanitizerKind::CFIUnrelatedCast)) { in VisitCastExpr()
1388 CGF.EmitVTablePtrCheckForCast(PT->getPointeeType(), Src, in VisitCastExpr()
1413 Address Base = CGF.EmitPointerWithAlignment(E); in VisitCastExpr()
1415 CGF.GetAddressOfDerivedClass(Base, DerivedClassDecl, in VisitCastExpr()
1417 CGF.ShouldNullCheckClassCastValue(CE)); in VisitCastExpr()
1421 if (CGF.sanitizePerformTypeCheck()) in VisitCastExpr()
1422 CGF.EmitTypeCheck(CodeGenFunction::TCK_DowncastPointer, CE->getExprLoc(), in VisitCastExpr()
1425 if (CGF.SanOpts.has(SanitizerKind::CFIDerivedCast)) in VisitCastExpr()
1426 CGF.EmitVTablePtrCheckForCast(DestTy->getPointeeType(), in VisitCastExpr()
1438 return CGF.EmitPointerWithAlignment(CE).getPointer(); in VisitCastExpr()
1442 Address V = CGF.EmitPointerWithAlignment(E); in VisitCastExpr()
1444 return CGF.EmitDynamicCast(V, DCE); in VisitCastExpr()
1448 return CGF.EmitArrayToPointerDecay(E).getPointer(); in VisitCastExpr()
1464 return CGF.CGM.getCXXABI().EmitNullMemberPointer(MPT); in VisitCastExpr()
1478 return CGF.CGM.getCXXABI().EmitMemberPointerConversion(CGF, CE, Src); in VisitCastExpr()
1482 return CGF.EmitARCRetainScalarExpr(E); in VisitCastExpr()
1484 return CGF.EmitObjCConsumeObject(E->getType(), Visit(E)); in VisitCastExpr()
1486 return CGF.EmitARCReclaimReturnedObject(E, /*allowUnsafe*/ Ignored); in VisitCastExpr()
1488 return CGF.EmitARCExtendBlockObject(E); in VisitCastExpr()
1491 return CGF.EmitBlockCopyAndAutorelease(Visit(E), E->getType()); in VisitCastExpr()
1504 assert(CGF.getContext().hasSameUnqualifiedType(E->getType(), DestTy)); in VisitCastExpr()
1513 llvm::Type *MiddleTy = CGF.IntPtrTy; in VisitCastExpr()
1525 CGF.EmitIgnoredExpr(E); in VisitCastExpr()
1555 return CGF.CGM.getCXXABI().EmitMemberPointerIsNotNull(CGF, MemPtr, MPT); in VisitCastExpr()
1560 return CGF.EmitComplexExpr(E, false, true).first; in VisitCastExpr()
1564 CodeGenFunction::ComplexPairTy V = CGF.EmitComplexExpr(E); in VisitCastExpr()
1582 CodeGenFunction::StmtExprEvaluation eval(CGF); in VisitStmtExpr()
1583 Address RetAlloca = CGF.EmitCompoundStmt(*E->getSubStmt(), in VisitStmtExpr()
1587 return CGF.EmitLoadOfScalar(CGF.MakeAddrLValue(RetAlloca, E->getType()), in VisitStmtExpr()
1612 switch (CGF.getLangOpts().getSignedOverflowBehavior()) { in EmitIncDecConsiderOverflowBehavior()
1616 if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) in EmitIncDecConsiderOverflowBehavior()
1639 llvm::Value *True = CGF.EmitToMemory(Builder.getTrue(), type); in EmitScalarPrePostIncDec()
1656 CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) && in EmitScalarPrePostIncDec()
1657 CGF.getLangOpts().getSignedOverflowBehavior() != in EmitScalarPrePostIncDec()
1663 llvm::Value *amt = CGF.EmitToMemory( in EmitScalarPrePostIncDec()
1673 llvm::BasicBlock *opBB = CGF.createBasicBlock("atomic_op", CGF.CurFn); in EmitScalarPrePostIncDec()
1674 value = CGF.EmitToMemory(value, type); in EmitScalarPrePostIncDec()
1700 CGF.IntTy->getIntegerBitWidth(); in EmitScalarPrePostIncDec()
1704 CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) { in EmitScalarPrePostIncDec()
1718 = CGF.getContext().getAsVariableArrayType(type)) { in EmitScalarPrePostIncDec()
1719 llvm::Value *numElts = CGF.getVLASize(vla).first; in EmitScalarPrePostIncDec()
1721 if (CGF.getLangOpts().isSignedOverflowDefined()) in EmitScalarPrePostIncDec()
1730 value = CGF.EmitCastToVoidPtr(value); in EmitScalarPrePostIncDec()
1731 if (CGF.getLangOpts().isSignedOverflowDefined()) in EmitScalarPrePostIncDec()
1740 if (CGF.getLangOpts().isSignedOverflowDefined()) in EmitScalarPrePostIncDec()
1764 if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) { in EmitScalarPrePostIncDec()
1766 if (!CGF.getContext().getLangOpts().HalfArgsAndReturns) { in EmitScalarPrePostIncDec()
1768 CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_from_fp16, in EmitScalarPrePostIncDec()
1769 CGF.CGM.FloatTy), in EmitScalarPrePostIncDec()
1772 value = Builder.CreateFPExt(input, CGF.CGM.FloatTy, "incdec.conv"); in EmitScalarPrePostIncDec()
1790 FS = &CGF.getTarget().getFloat128Format(); in EmitScalarPrePostIncDec()
1792 FS = &CGF.getTarget().getHalfFormat(); in EmitScalarPrePostIncDec()
1794 FS = &CGF.getTarget().getLongDoubleFormat(); in EmitScalarPrePostIncDec()
1800 if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) { in EmitScalarPrePostIncDec()
1801 if (!CGF.getContext().getLangOpts().HalfArgsAndReturns) { in EmitScalarPrePostIncDec()
1803 CGF.CGM.getIntrinsic(llvm::Intrinsic::convert_to_fp16, in EmitScalarPrePostIncDec()
1804 CGF.CGM.FloatTy), in EmitScalarPrePostIncDec()
1814 value = CGF.EmitCastToVoidPtr(value); in EmitScalarPrePostIncDec()
1816 CharUnits size = CGF.getContext().getTypeSizeInChars(OPT->getObjectType()); in EmitScalarPrePostIncDec()
1819 llvm::ConstantInt::get(CGF.SizeTy, size.getQuantity()); in EmitScalarPrePostIncDec()
1821 if (CGF.getLangOpts().isSignedOverflowDefined()) in EmitScalarPrePostIncDec()
1830 llvm::BasicBlock *contBB = CGF.createBasicBlock("atomic_cont", CGF.CurFn); in EmitScalarPrePostIncDec()
1831 auto Pair = CGF.EmitAtomicCompareExchange( in EmitScalarPrePostIncDec()
1833 llvm::Value *old = CGF.EmitToMemory(Pair.first.getScalarVal(), type); in EmitScalarPrePostIncDec()
1843 CGF.EmitStoreThroughBitfieldLValue(RValue::get(value), LV, &value); in EmitScalarPrePostIncDec()
1845 CGF.EmitStoreThroughLValue(RValue::get(value), LV); in EmitScalarPrePostIncDec()
1891 Value *BoolVal = CGF.EvaluateExprAsBool(E->getSubExpr()); in VisitUnaryLNot()
1905 if (E->EvaluateAsInt(Value, CGF.getContext())) in VisitOffsetOfExpr()
1920 llvm::Value* Idx = CGF.EmitScalarExpr(IdxExpr); in VisitOffsetOfExpr()
1926 CGF.getContext().getAsArrayType(CurrentType)->getElementType(); in VisitOffsetOfExpr()
1930 CGF.getContext().getTypeSizeInChars(CurrentType).getQuantity()); in VisitOffsetOfExpr()
1940 const ASTRecordLayout &RL = CGF.getContext().getASTRecordLayout(RD); in VisitOffsetOfExpr()
1955 CGF.getContext().getCharWidth(); in VisitOffsetOfExpr()
1968 CGF.ErrorUnsupported(E, "virtual base in offsetof"); in VisitOffsetOfExpr()
1973 const ASTRecordLayout &RL = CGF.getContext().getASTRecordLayout(RD); in VisitOffsetOfExpr()
1999 CGF.getContext().getAsVariableArrayType(TypeToSize)) { in VisitUnaryExprOrTypeTraitExpr()
2002 CGF.EmitVariablyModifiedType(TypeToSize); in VisitUnaryExprOrTypeTraitExpr()
2006 CGF.EmitIgnoredExpr(E->getArgumentExpr()); in VisitUnaryExprOrTypeTraitExpr()
2011 std::tie(numElts, eltType) = CGF.getVLASize(VAT); in VisitUnaryExprOrTypeTraitExpr()
2016 CharUnits eltSize = CGF.getContext().getTypeSizeInChars(eltType); in VisitUnaryExprOrTypeTraitExpr()
2018 size = CGF.Builder.CreateNUWMul(CGF.CGM.getSize(eltSize), numElts); in VisitUnaryExprOrTypeTraitExpr()
2024 CGF.getContext() in VisitUnaryExprOrTypeTraitExpr()
2025 .toCharUnitsFromBits(CGF.getContext().getOpenMPDefaultSimdAlign( in VisitUnaryExprOrTypeTraitExpr()
2028 return llvm::ConstantInt::get(CGF.SizeTy, Alignment); in VisitUnaryExprOrTypeTraitExpr()
2033 return Builder.getInt(E->EvaluateKnownConstInt(CGF.getContext())); in VisitUnaryExprOrTypeTraitExpr()
2043 return CGF.EmitLoadOfLValue(CGF.EmitLValue(E), in VisitUnaryReal()
2047 return CGF.EmitComplexExpr(Op, false, true).first; in VisitUnaryReal()
2060 return CGF.EmitLoadOfLValue(CGF.EmitLValue(E), in VisitUnaryImag()
2064 return CGF.EmitComplexExpr(Op, true, false).second; in VisitUnaryImag()
2070 CGF.EmitLValue(Op); in VisitUnaryImag()
2072 CGF.EmitScalarExpr(Op, true); in VisitUnaryImag()
2100 return CGF.EmitScalarCompoundAssignWithComplex(E, Result); in EmitCompoundAssignLValue()
2117 CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) && in EmitCompoundAssignLValue()
2118 CGF.getLangOpts().getSignedOverflowBehavior() != in EmitCompoundAssignLValue()
2147 llvm::Value *amt = CGF.EmitToMemory( in EmitCompoundAssignLValue()
2159 llvm::BasicBlock *opBB = CGF.createBasicBlock("atomic_op", CGF.CurFn); in EmitCompoundAssignLValue()
2161 OpInfo.LHS = CGF.EmitToMemory(OpInfo.LHS, type); in EmitCompoundAssignLValue()
2184 llvm::BasicBlock *contBB = CGF.createBasicBlock("atomic_cont", CGF.CurFn); in EmitCompoundAssignLValue()
2185 auto Pair = CGF.EmitAtomicCompareExchange( in EmitCompoundAssignLValue()
2187 llvm::Value *old = CGF.EmitToMemory(Pair.first.getScalarVal(), LHSTy); in EmitCompoundAssignLValue()
2200 CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, &Result); in EmitCompoundAssignLValue()
2202 CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV); in EmitCompoundAssignLValue()
2218 if (!CGF.getLangOpts().CPlusPlus) in EmitCompoundAssign()
2233 if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) { in EmitUndefinedBehaviorIntegerDivAndRemCheck()
2238 if (CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow) && in EmitUndefinedBehaviorIntegerDivAndRemCheck()
2259 CodeGenFunction::SanitizerScope SanScope(&CGF); in EmitDiv()
2260 if ((CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero) || in EmitDiv()
2261 CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) && in EmitDiv()
2265 } else if (CGF.SanOpts.has(SanitizerKind::FloatDivideByZero) && in EmitDiv()
2276 if (CGF.getLangOpts().OpenCL) { in EmitDiv()
2282 CGF.SetFPAccuracy(Val, 2.5); in EmitDiv()
2294 if (CGF.SanOpts.has(SanitizerKind::IntegerDivideByZero)) { in EmitRem()
2295 CodeGenFunction::SanitizerScope SanScope(&CGF); in EmitRem()
2339 llvm::Type *opTy = CGF.CGM.getTypes().ConvertType(Ops.Ty); in EmitOverflowCheckedBinOp()
2341 llvm::Function *intrinsic = CGF.CGM.getIntrinsic(IID, opTy); in EmitOverflowCheckedBinOp()
2349 &CGF.getLangOpts().OverflowHandler; in EmitOverflowCheckedBinOp()
2353 if (!isSigned || CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) { in EmitOverflowCheckedBinOp()
2354 CodeGenFunction::SanitizerScope SanScope(&CGF); in EmitOverflowCheckedBinOp()
2360 CGF.EmitTrapCheck(Builder.CreateNot(overflow)); in EmitOverflowCheckedBinOp()
2367 llvm::BasicBlock *continueBB = CGF.createBasicBlock("nooverflow", CGF.CurFn, in EmitOverflowCheckedBinOp()
2369 llvm::BasicBlock *overflowBB = CGF.createBasicBlock("overflow", CGF.CurFn); in EmitOverflowCheckedBinOp()
2378 llvm::Type *Int8Ty = CGF.Int8Ty; in EmitOverflowCheckedBinOp()
2379 llvm::Type *argTypes[] = { CGF.Int64Ty, CGF.Int64Ty, Int8Ty, Int8Ty }; in EmitOverflowCheckedBinOp()
2381 llvm::FunctionType::get(CGF.Int64Ty, argTypes, true); in EmitOverflowCheckedBinOp()
2382 llvm::Value *handler = CGF.CGM.CreateRuntimeFunction(handlerTy, *handlerName); in EmitOverflowCheckedBinOp()
2386 llvm::Value *lhs = Builder.CreateSExt(Ops.LHS, CGF.Int64Ty); in EmitOverflowCheckedBinOp()
2387 llvm::Value *rhs = Builder.CreateSExt(Ops.RHS, CGF.Int64Ty); in EmitOverflowCheckedBinOp()
2398 CGF.EmitNounwindRuntimeCall(handler, handlerArgs); in EmitOverflowCheckedBinOp()
2413 static Value *emitPointerArithmetic(CodeGenFunction &CGF, in emitPointerArithmetic() argument
2432 if (width != CGF.PointerWidthInBits) { in emitPointerArithmetic()
2436 index = CGF.Builder.CreateIntCast(index, CGF.PtrDiffTy, isSigned, in emitPointerArithmetic()
2442 index = CGF.Builder.CreateNeg(index, "idx.neg"); in emitPointerArithmetic()
2444 if (CGF.SanOpts.has(SanitizerKind::ArrayBounds)) in emitPointerArithmetic()
2445 CGF.EmitBoundsCheck(op.E, pointerOperand, index, indexOperand->getType(), in emitPointerArithmetic()
2455 = CGF.CGM.getSize(CGF.getContext().getTypeSizeInChars(objectType)); in emitPointerArithmetic()
2457 index = CGF.Builder.CreateMul(index, objectSize); in emitPointerArithmetic()
2459 Value *result = CGF.Builder.CreateBitCast(pointer, CGF.VoidPtrTy); in emitPointerArithmetic()
2460 result = CGF.Builder.CreateGEP(result, index, "add.ptr"); in emitPointerArithmetic()
2461 return CGF.Builder.CreateBitCast(result, pointer->getType()); in emitPointerArithmetic()
2466 = CGF.getContext().getAsVariableArrayType(elementType)) { in emitPointerArithmetic()
2468 llvm::Value *numElements = CGF.getVLASize(vla).first; in emitPointerArithmetic()
2474 if (CGF.getLangOpts().isSignedOverflowDefined()) { in emitPointerArithmetic()
2475 index = CGF.Builder.CreateMul(index, numElements, "vla.index"); in emitPointerArithmetic()
2476 pointer = CGF.Builder.CreateGEP(pointer, index, "add.ptr"); in emitPointerArithmetic()
2478 index = CGF.Builder.CreateNSWMul(index, numElements, "vla.index"); in emitPointerArithmetic()
2479 pointer = CGF.Builder.CreateInBoundsGEP(pointer, index, "add.ptr"); in emitPointerArithmetic()
2488 Value *result = CGF.Builder.CreateBitCast(pointer, CGF.VoidPtrTy); in emitPointerArithmetic()
2489 result = CGF.Builder.CreateGEP(result, index, "add.ptr"); in emitPointerArithmetic()
2490 return CGF.Builder.CreateBitCast(result, pointer->getType()); in emitPointerArithmetic()
2493 if (CGF.getLangOpts().isSignedOverflowDefined()) in emitPointerArithmetic()
2494 return CGF.Builder.CreateGEP(pointer, index, "add.ptr"); in emitPointerArithmetic()
2496 return CGF.Builder.CreateInBoundsGEP(pointer, index, "add.ptr"); in emitPointerArithmetic()
2505 const CodeGenFunction &CGF, CGBuilderTy &Builder, in buildFMulAdd() argument
2524 CGF.CGM.getIntrinsic(llvm::Intrinsic::fmuladd, Addend->getType()), in buildFMulAdd()
2538 const CodeGenFunction &CGF, CGBuilderTy &Builder, in tryEmitFMulAdd() argument
2551 if (CGF.CGM.getCodeGenOpts().getFPContractMode() != CodeGenOptions::FPC_On) in tryEmitFMulAdd()
2560 return buildFMulAdd(LHSBinOp, op.RHS, CGF, Builder, false, isSub); in tryEmitFMulAdd()
2565 return buildFMulAdd(RHSBinOp, op.LHS, CGF, Builder, isSub, false); in tryEmitFMulAdd()
2574 return emitPointerArithmetic(CGF, op, /*subtraction*/ false); in EmitAdd()
2577 switch (CGF.getLangOpts().getSignedOverflowBehavior()) { in EmitAdd()
2581 if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) in EmitAdd()
2590 CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) in EmitAdd()
2595 if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder)) in EmitAdd()
2608 switch (CGF.getLangOpts().getSignedOverflowBehavior()) { in EmitSub()
2612 if (!CGF.SanOpts.has(SanitizerKind::SignedIntegerOverflow)) in EmitSub()
2621 CGF.SanOpts.has(SanitizerKind::UnsignedIntegerOverflow)) in EmitSub()
2626 if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder, true)) in EmitSub()
2637 return emitPointerArithmetic(CGF, op, /*subtraction*/ true); in EmitSub()
2643 = Builder.CreatePtrToInt(op.LHS, CGF.PtrDiffTy, "sub.ptr.lhs.cast"); in EmitSub()
2645 = Builder.CreatePtrToInt(op.RHS, CGF.PtrDiffTy, "sub.ptr.rhs.cast"); in EmitSub()
2656 = CGF.getContext().getAsVariableArrayType(elementType)) { in EmitSub()
2658 std::tie(numElements, elementType) = CGF.getVLASize(vla); in EmitSub()
2663 CharUnits eltSize = CGF.getContext().getTypeSizeInChars(elementType); in EmitSub()
2665 divisor = CGF.Builder.CreateNUWMul(CGF.CGM.getSize(eltSize), divisor); in EmitSub()
2677 elementSize = CGF.getContext().getTypeSizeInChars(elementType); in EmitSub()
2683 divisor = CGF.CGM.getSize(elementSize); in EmitSub()
2708 bool SanitizeBase = CGF.SanOpts.has(SanitizerKind::ShiftBase) && in EmitShl()
2710 bool SanitizeExponent = CGF.SanOpts.has(SanitizerKind::ShiftExponent); in EmitShl()
2712 if (CGF.getLangOpts().OpenCL) in EmitShl()
2717 CodeGenFunction::SanitizerScope SanScope(&CGF); in EmitShl()
2732 llvm::BasicBlock *Cont = CGF.createBasicBlock("cont"); in EmitShl()
2733 llvm::BasicBlock *CheckShiftBase = CGF.createBasicBlock("check"); in EmitShl()
2735 CGF.EmitBlock(CheckShiftBase); in EmitShl()
2741 if (CGF.getLangOpts().CPlusPlus) { in EmitShl()
2751 CGF.EmitBlock(Cont); in EmitShl()
2773 if (CGF.getLangOpts().OpenCL) in EmitShr()
2776 else if (CGF.SanOpts.has(SanitizerKind::ShiftExponent) && in EmitShr()
2778 CodeGenFunction::SanitizerScope SanScope(&CGF); in EmitShr()
2834 Value *LHS = CGF.EmitScalarExpr(E->getLHS()); in EmitCompare()
2835 Value *RHS = CGF.EmitScalarExpr(E->getRHS()); in EmitCompare()
2836 Result = CGF.CGM.getCXXABI().EmitMemberPointerComparison( in EmitCompare()
2837 CGF, LHS, RHS, MPT, E->getOpcode() == BO_NE); in EmitCompare()
2902 llvm::Function *F = CGF.CGM.getIntrinsic(ID); in EmitCompare()
2904 return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), in EmitCompare()
2927 LHS = CGF.EmitComplexExpr(E->getLHS()); in EmitCompare()
2935 RHS = CGF.EmitComplexExpr(E->getRHS()); in EmitCompare()
2936 assert(CGF.getContext().hasSameUnqualifiedType(CETy, in EmitCompare()
2943 assert(CGF.getContext().hasSameUnqualifiedType(CETy, RHSTy) && in EmitCompare()
2967 return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(), in EmitCompare()
2979 std::tie(LHS, RHS) = CGF.EmitARCStoreStrong(E, Ignore); in VisitBinAssign()
2983 std::tie(LHS, RHS) = CGF.EmitARCStoreAutoreleasing(E); in VisitBinAssign()
2987 std::tie(LHS, RHS) = CGF.EmitARCStoreUnsafeUnretained(E, Ignore); in VisitBinAssign()
2993 RHS = CGF.EmitARCStoreWeak(LHS.getAddress(), RHS, Ignore); in VisitBinAssign()
3007 CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, &RHS); in VisitBinAssign()
3009 CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS); in VisitBinAssign()
3017 if (!CGF.getLangOpts().CPlusPlus) in VisitBinAssign()
3031 CGF.incrementProfileCounter(E); in VisitBinLAnd()
3052 if (CGF.ConstantFoldsToSimpleInteger(E->getLHS(), LHSCondVal)) { in VisitBinLAnd()
3054 CGF.incrementProfileCounter(E); in VisitBinLAnd()
3056 Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); in VisitBinLAnd()
3062 if (!CGF.ContainsLabel(E->getRHS())) in VisitBinLAnd()
3066 llvm::BasicBlock *ContBlock = CGF.createBasicBlock("land.end"); in VisitBinLAnd()
3067 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("land.rhs"); in VisitBinLAnd()
3069 CodeGenFunction::ConditionalEvaluation eval(CGF); in VisitBinLAnd()
3072 CGF.EmitBranchOnBoolExpr(E->getLHS(), RHSBlock, ContBlock, in VisitBinLAnd()
3073 CGF.getProfileCount(E->getRHS())); in VisitBinLAnd()
3084 eval.begin(CGF); in VisitBinLAnd()
3085 CGF.EmitBlock(RHSBlock); in VisitBinLAnd()
3086 CGF.incrementProfileCounter(E); in VisitBinLAnd()
3087 Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); in VisitBinLAnd()
3088 eval.end(CGF); in VisitBinLAnd()
3096 auto NL = ApplyDebugLocation::CreateEmpty(CGF); in VisitBinLAnd()
3097 CGF.EmitBlock(ContBlock); in VisitBinLAnd()
3109 CGF.incrementProfileCounter(E); in VisitBinLOr()
3130 if (CGF.ConstantFoldsToSimpleInteger(E->getLHS(), LHSCondVal)) { in VisitBinLOr()
3132 CGF.incrementProfileCounter(E); in VisitBinLOr()
3134 Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); in VisitBinLOr()
3140 if (!CGF.ContainsLabel(E->getRHS())) in VisitBinLOr()
3144 llvm::BasicBlock *ContBlock = CGF.createBasicBlock("lor.end"); in VisitBinLOr()
3145 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("lor.rhs"); in VisitBinLOr()
3147 CodeGenFunction::ConditionalEvaluation eval(CGF); in VisitBinLOr()
3150 CGF.EmitBranchOnBoolExpr(E->getLHS(), ContBlock, RHSBlock, in VisitBinLOr()
3151 CGF.getCurrentProfileCount() - in VisitBinLOr()
3152 CGF.getProfileCount(E->getRHS())); in VisitBinLOr()
3163 eval.begin(CGF); in VisitBinLOr()
3166 CGF.EmitBlock(RHSBlock); in VisitBinLOr()
3167 CGF.incrementProfileCounter(E); in VisitBinLOr()
3168 Value *RHSCond = CGF.EvaluateExprAsBool(E->getRHS()); in VisitBinLOr()
3170 eval.end(CGF); in VisitBinLOr()
3177 CGF.EmitBlock(ContBlock); in VisitBinLOr()
3185 CGF.EmitIgnoredExpr(E->getLHS()); in VisitBinComma()
3186 CGF.EnsureInsertPoint(); in VisitBinComma()
3199 CodeGenFunction &CGF) { in isCheapEnoughToEvaluateUnconditionally() argument
3201 return E->IgnoreParens()->isEvaluatable(CGF.getContext()); in isCheapEnoughToEvaluateUnconditionally()
3217 CodeGenFunction::OpaqueValueMapping binding(CGF, E); in VisitAbstractConditionalOperator()
3226 if (CGF.ConstantFoldsToSimpleInteger(condExpr, CondExprBool)) { in VisitAbstractConditionalOperator()
3231 if (!CGF.ContainsLabel(dead)) { in VisitAbstractConditionalOperator()
3233 CGF.incrementProfileCounter(E); in VisitAbstractConditionalOperator()
3240 Result = llvm::UndefValue::get(CGF.ConvertType(E->getType())); in VisitAbstractConditionalOperator()
3248 if (CGF.getLangOpts().OpenCL in VisitAbstractConditionalOperator()
3250 CGF.incrementProfileCounter(E); in VisitAbstractConditionalOperator()
3252 llvm::Value *CondV = CGF.EmitScalarExpr(condExpr); in VisitAbstractConditionalOperator()
3293 if (isCheapEnoughToEvaluateUnconditionally(lhsExpr, CGF) && in VisitAbstractConditionalOperator()
3294 isCheapEnoughToEvaluateUnconditionally(rhsExpr, CGF)) { in VisitAbstractConditionalOperator()
3295 CGF.incrementProfileCounter(E); in VisitAbstractConditionalOperator()
3297 llvm::Value *CondV = CGF.EvaluateExprAsBool(condExpr); in VisitAbstractConditionalOperator()
3308 llvm::BasicBlock *LHSBlock = CGF.createBasicBlock("cond.true"); in VisitAbstractConditionalOperator()
3309 llvm::BasicBlock *RHSBlock = CGF.createBasicBlock("cond.false"); in VisitAbstractConditionalOperator()
3310 llvm::BasicBlock *ContBlock = CGF.createBasicBlock("cond.end"); in VisitAbstractConditionalOperator()
3312 CodeGenFunction::ConditionalEvaluation eval(CGF); in VisitAbstractConditionalOperator()
3313 CGF.EmitBranchOnBoolExpr(condExpr, LHSBlock, RHSBlock, in VisitAbstractConditionalOperator()
3314 CGF.getProfileCount(lhsExpr)); in VisitAbstractConditionalOperator()
3316 CGF.EmitBlock(LHSBlock); in VisitAbstractConditionalOperator()
3317 CGF.incrementProfileCounter(E); in VisitAbstractConditionalOperator()
3318 eval.begin(CGF); in VisitAbstractConditionalOperator()
3320 eval.end(CGF); in VisitAbstractConditionalOperator()
3325 CGF.EmitBlock(RHSBlock); in VisitAbstractConditionalOperator()
3326 eval.begin(CGF); in VisitAbstractConditionalOperator()
3328 eval.end(CGF); in VisitAbstractConditionalOperator()
3331 CGF.EmitBlock(ContBlock); in VisitAbstractConditionalOperator()
3354 CGF.EmitVariablyModifiedType(Ty); in VisitVAArgExpr()
3357 Address ArgPtr = CGF.EmitVAArg(VE, ArgValue); in VisitVAArgExpr()
3363 CGF.ErrorUnsupported(VE, "va_arg expression"); in VisitVAArgExpr()
3382 return CGF.EmitBlockLiteral(block); in VisitBlockExpr()
3386 static Value *ConvertVec3AndVec4(CGBuilderTy &Builder, CodeGenFunction &CGF, in ConvertVec3AndVec4() argument
3394 Args.push_back(llvm::UndefValue::get(CGF.Int32Ty)); in ConvertVec3AndVec4()
3400 Value *Src = CGF.EmitScalarExpr(E->getSrcExpr()); in VisitAsTypeExpr()
3412 Src = ConvertVec3AndVec4(Builder, CGF, Src, 4); in VisitAsTypeExpr()
3424 Src = ConvertVec3AndVec4(Builder, CGF, Src, 3); in VisitAsTypeExpr()
3433 return CGF.EmitAtomicExpr(E).getScalarVal(); in VisitAtomicExpr()