diff options
Diffstat (limited to 'gnu/llvm/tools/clang/lib/CodeGen/CGObjC.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/CodeGen/CGObjC.cpp | 230 |
1 files changed, 115 insertions, 115 deletions
diff --git a/gnu/llvm/tools/clang/lib/CodeGen/CGObjC.cpp b/gnu/llvm/tools/clang/lib/CodeGen/CGObjC.cpp index f26263d9472..b94bbf2a384 100644 --- a/gnu/llvm/tools/clang/lib/CodeGen/CGObjC.cpp +++ b/gnu/llvm/tools/clang/lib/CodeGen/CGObjC.cpp @@ -45,7 +45,7 @@ static llvm::Constant *getNullForVariable(Address addr) { /// Emits an instance of NSConstantString representing the object. llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E) { - llvm::Constant *C = + llvm::Constant *C = CGM.getObjCRuntime().GenerateConstantString(E->getString()).getPointer(); // FIXME: This bitcast should just be made an invariant on the Runtime. return llvm::ConstantExpr::getBitCast(C, ConvertType(E->getType())); @@ -65,7 +65,7 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { assert(BoxingMethod && "BoxingMethod is null"); assert(BoxingMethod->isClassMethod() && "BoxingMethod must be a class method"); Selector Sel = BoxingMethod->getSelector(); - + // Generate a reference to the class pointer, which will be the receiver. // Assumes that the method was introduced in the class that should be // messaged (avoids pulling it out of the result type). @@ -76,8 +76,8 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { CallArgList Args; const ParmVarDecl *ArgDecl = *BoxingMethod->param_begin(); QualType ArgQT = ArgDecl->getType().getUnqualifiedType(); - - // ObjCBoxedExpr supports boxing of structs and unions + + // ObjCBoxedExpr supports boxing of structs and unions // via [NSValue valueWithBytes:objCType:] const QualType ValueType(SubExpr->getType().getCanonicalType()); if (ValueType->isObjCBoxableRecordType()) { @@ -92,7 +92,7 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { std::string Str; getContext().getObjCEncodingForType(ValueType, Str); llvm::Constant *GV = CGM.GetAddrOfConstantCString(Str).getPointer(); - + // Cast type encoding to correct type const ParmVarDecl *EncodingDecl = BoxingMethod->parameters()[1]; QualType EncodingQT = EncodingDecl->getType().getUnqualifiedType(); @@ -106,7 +106,7 @@ CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { RValue result = Runtime.GenerateMessageSend( *this, ReturnValueSlot(), BoxingMethod->getReturnType(), Sel, Receiver, Args, ClassDecl, BoxingMethod); - return Builder.CreateBitCast(result.getScalarVal(), + return Builder.CreateBitCast(result.getScalarVal(), ConvertType(E->getType())); } @@ -119,7 +119,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, DLE = cast<ObjCDictionaryLiteral>(E); // Optimize empty collections by referencing constants, when available. - uint64_t NumElements = + uint64_t NumElements = ALE ? ALE->getNumElements() : DLE->getNumElements(); if (NumElements == 0 && CGM.getLangOpts().ObjCRuntime.hasEmptyCollections()) { StringRef ConstantName = ALE ? "__NSArray0__" : "__NSDictionary0__"; @@ -138,8 +138,8 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, llvm::APInt APNumElements(Context.getTypeSize(Context.getSizeType()), NumElements); QualType ElementType = Context.getObjCIdType().withConst(); - QualType ElementArrayType - = Context.getConstantArrayType(ElementType, APNumElements, + QualType ElementArrayType + = Context.getConstantArrayType(ElementType, APNumElements, ArrayType::Normal, /*IndexTypeQuals=*/0); // Allocate the temporary array(s). @@ -147,7 +147,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, Address Keys = Address::invalid(); if (DLE) Keys = CreateMemTemp(ElementArrayType, "keys"); - + // In ARC, we may need to do extra work to keep all the keys and // values alive until after the call. SmallVector<llvm::Value *, 16> NeededObjects; @@ -169,7 +169,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, if (TrackNeededObjects) { NeededObjects.push_back(value); } - } else { + } else { // Emit the key and store it to the appropriate array slot. const Expr *Key = DLE->getKeyValueElement(i).Key; LValue KeyLV = MakeAddrLValue( @@ -191,9 +191,9 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, } } } - + // Generate the argument list. - CallArgList Args; + CallArgList Args; ObjCMethodDecl::param_const_iterator PI = MethodWithObjects->param_begin(); const ParmVarDecl *argDecl = *PI++; QualType ArgQT = argDecl->getType().getUnqualifiedType(); @@ -205,7 +205,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, } argDecl = *PI; ArgQT = argDecl->getType().getUnqualifiedType(); - llvm::Value *Count = + llvm::Value *Count = llvm::ConstantInt::get(CGM.getTypes().ConvertType(ArgQT), NumElements); Args.add(RValue::get(Count), ArgQT); @@ -214,7 +214,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, QualType ResultType = E->getType(); const ObjCObjectPointerType *InterfacePointerType = ResultType->getAsObjCInterfacePointerType(); - ObjCInterfaceDecl *Class + ObjCInterfaceDecl *Class = InterfacePointerType->getObjectType()->getInterface(); CGObjCRuntime &Runtime = CGM.getObjCRuntime(); llvm::Value *Receiver = Runtime.GetClass(*this, Class); @@ -232,7 +232,7 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, EmitARCIntrinsicUse(NeededObjects); } - return Builder.CreateBitCast(result.getScalarVal(), + return Builder.CreateBitCast(result.getScalarVal(), ConvertType(E->getType())); } @@ -259,7 +259,7 @@ llvm::Value *CodeGenFunction::EmitObjCProtocolExpr(const ObjCProtocolExpr *E) { return CGM.getObjCRuntime().GenerateProtocolRef(*this, E->getProtocol()); } -/// \brief Adjust the type of an Objective-C object that doesn't match up due +/// Adjust the type of an Objective-C object that doesn't match up due /// to type erasure at various points, e.g., related result types or the use /// of parameterized classes. static RValue AdjustObjCObjectType(CodeGenFunction &CGF, QualType ExpT, @@ -557,7 +557,7 @@ void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD, if (CGM.getLangOpts().ObjCAutoRefCount && OMD->isInstanceMethod() && OMD->getSelector().isUnarySelector()) { - const IdentifierInfo *ident = + const IdentifierInfo *ident = OMD->getSelector().getIdentifierInfoForSlot(0); if (ident->isStr("dealloc")) EHStack.pushCleanup<FinishARCDealloc>(getARCCleanupKind()); @@ -580,7 +580,7 @@ void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) { /// emitStructGetterCall - Call the runtime function to load a property /// into the return value slot. -static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar, +static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar, bool isAtomic, bool hasStrong) { ASTContext &Context = CGF.getContext(); @@ -588,7 +588,7 @@ static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar, CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0) .getAddress(); - // objc_copyStruct (ReturnValue, &structIvar, + // objc_copyStruct (ReturnValue, &structIvar, // sizeof (Type of Ivar), isAtomic, false); CallArgList args; @@ -803,7 +803,7 @@ PropertyImplStrategy::PropertyImplStrategy(CodeGenModule &CGM, Kind = Native; } -/// \brief Generate an Objective-C property getter function. +/// Generate an Objective-C property getter function. /// /// The given Decl must be an ObjCImplementationDecl. \@synthesize /// is illegal within a category. @@ -844,30 +844,30 @@ static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl) { return false; } -/// emitCPPObjectAtomicGetterCall - Call the runtime function to +/// emitCPPObjectAtomicGetterCall - Call the runtime function to /// copy the ivar into the resturn slot. -static void emitCPPObjectAtomicGetterCall(CodeGenFunction &CGF, +static void emitCPPObjectAtomicGetterCall(CodeGenFunction &CGF, llvm::Value *returnAddr, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn) { // objc_copyCppObjectAtomic (&returnSlot, &CppObjectIvar, // AtomicHelperFn); CallArgList args; - + // The 1st argument is the return Slot. args.add(RValue::get(returnAddr), CGF.getContext().VoidPtrTy); - + // The 2nd argument is the address of the ivar. - llvm::Value *ivarAddr = - CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), + llvm::Value *ivarAddr = + CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0).getPointer(); ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy); args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy); - + // Third argument is the helper function. args.add(RValue::get(AtomicHelperFn), CGF.getContext().VoidPtrTy); - - llvm::Constant *copyCppAtomicObjectFn = + + llvm::Constant *copyCppAtomicObjectFn = CGF.CGM.getObjCRuntime().GetCppAtomicObjectGetFunction(); CGCallee callee = CGCallee::forDirect(copyCppAtomicObjectFn); CGF.EmitCall( @@ -889,7 +889,7 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, } else { ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); - emitCPPObjectAtomicGetterCall(*this, ReturnValue.getPointer(), + emitCPPObjectAtomicGetterCall(*this, ReturnValue.getPointer(), ivar, AtomicHelperFn); } return; @@ -899,7 +899,7 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, QualType propType = prop->getType(); ObjCMethodDecl *getterMethod = prop->getGetterMethodDecl(); - ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); + ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); // Pick an implementation strategy. PropertyImplStrategy strategy(CGM, propImpl); @@ -1008,12 +1008,14 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, /*init*/ true); return; } - case TEK_Aggregate: + case TEK_Aggregate: { // The return value slot is guaranteed to not be aliased, but // that's not necessarily the same as "on the stack", so // we still potentially need objc_memmove_collectable. - EmitAggregateCopy(ReturnValue, LV.getAddress(), ivarType); + EmitAggregateCopy(/* Dest= */ MakeAddrLValue(ReturnValue, ivarType), + /* Src= */ LV, ivarType, overlapForReturnValue()); return; + } case TEK_Scalar: { llvm::Value *value; if (propType->isReferenceType()) { @@ -1037,7 +1039,7 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, value = Builder.CreateBitCast( value, ConvertType(GetterMethodDecl->getReturnType())); } - + EmitReturnOfRValue(RValue::get(value), propType); return; } @@ -1053,7 +1055,7 @@ CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, /// from the first formal parameter into the given ivar. static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar) { - // objc_copyStruct (&structIvar, &Arg, + // objc_copyStruct (&structIvar, &Arg, // sizeof (struct something), true, false); CallArgList args; @@ -1066,7 +1068,7 @@ static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, // The second argument is the address of the parameter variable. ParmVarDecl *argVar = *OMD->param_begin(); - DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(), + DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(), VK_LValue, SourceLocation()); llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(); argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy); @@ -1091,36 +1093,36 @@ static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, callee, ReturnValueSlot(), args); } -/// emitCPPObjectAtomicSetterCall - Call the runtime function to store -/// the value from the first formal parameter into the given ivar, using +/// emitCPPObjectAtomicSetterCall - Call the runtime function to store +/// the value from the first formal parameter into the given ivar, using /// the Cpp API for atomic Cpp objects with non-trivial copy assignment. -static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF, +static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn) { - // objc_copyCppObjectAtomic (&CppObjectIvar, &Arg, + // objc_copyCppObjectAtomic (&CppObjectIvar, &Arg, // AtomicHelperFn); CallArgList args; - + // The first argument is the address of the ivar. - llvm::Value *ivarAddr = - CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), + llvm::Value *ivarAddr = + CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0).getPointer(); ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy); args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy); - + // The second argument is the address of the parameter variable. ParmVarDecl *argVar = *OMD->param_begin(); - DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(), + DeclRefExpr argRef(argVar, false, argVar->getType().getNonReferenceType(), VK_LValue, SourceLocation()); llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(); argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy); args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy); - + // Third argument is the helper function. args.add(RValue::get(AtomicHelperFn), CGF.getContext().VoidPtrTy); - - llvm::Constant *fn = + + llvm::Constant *fn = CGF.CGM.getObjCRuntime().GetCppAtomicObjectSetFunction(); CGCallee callee = CGCallee::forDirect(fn); CGF.EmitCall( @@ -1166,7 +1168,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyDecl *prop = propImpl->getPropertyDecl(); ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); ObjCMethodDecl *setterMethod = prop->getSetterMethodDecl(); - + // Just use the setter expression if Sema gave us one and it's // non-trivial. if (!hasTrivialSetExpr(propImpl)) { @@ -1219,7 +1221,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, llvm::Constant *setPropertyFn = nullptr; if (UseOptimizedSetter(CGM)) { // 10.8 and iOS 6.0 code and GC is off - setOptimizedPropertyFn = + setOptimizedPropertyFn = CGM.getObjCRuntime() .GetOptimizedPropertySetFunction(strategy.isAtomic(), strategy.isCopy()); @@ -1235,7 +1237,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, return; } } - + // Emit objc_setProperty((id) self, _cmd, offset, arg, // <is-atomic>, <is-copy>). llvm::Value *cmd = @@ -1270,7 +1272,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, EmitCall(getTypes().arrangeBuiltinFunctionCall(getContext().VoidTy, args), callee, ReturnValueSlot(), args); } - + return; } @@ -1299,7 +1301,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, ImplicitCastExpr argLoad(ImplicitCastExpr::OnStack, argType.getUnqualifiedType(), CK_LValueToRValue, &arg, VK_RValue); - + // The property type can differ from the ivar type in some situations with // Objective-C pointer types, we can always bit cast the RHS in these cases. // The following absurdity is just to ensure well-formed IR. @@ -1334,7 +1336,7 @@ CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, EmitStmt(&assign); } -/// \brief Generate an Objective-C property setter function. +/// Generate an Objective-C property setter function. /// /// The given Decl must be an ObjCImplementationDecl. \@synthesize /// is illegal within a category. @@ -1433,12 +1435,13 @@ void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, for (const auto *IvarInit : IMP->inits()) { FieldDecl *Field = IvarInit->getAnyMember(); ObjCIvarDecl *Ivar = cast<ObjCIvarDecl>(Field); - LValue LV = EmitLValueForIvar(TypeOfSelfObject(), + LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0); EmitAggExpr(IvarInit->getInit(), AggValueSlot::forLValue(LV, AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, - AggValueSlot::IsNotAliased)); + AggValueSlot::IsNotAliased, + AggValueSlot::DoesNotOverlap)); } // constructor returns 'self'. CodeGenTypes &Types = CGM.getTypes(); @@ -1814,22 +1817,6 @@ void CodeGenFunction::EmitARCIntrinsicUse(ArrayRef<llvm::Value*> values) { } -static bool IsForwarding(StringRef Name) { - return llvm::StringSwitch<bool>(Name) - .Cases("objc_autoreleaseReturnValue", // ARCInstKind::AutoreleaseRV - "objc_autorelease", // ARCInstKind::Autorelease - "objc_retainAutoreleaseReturnValue", // ARCInstKind::FusedRetainAutoreleaseRV - "objc_retainAutoreleasedReturnValue", // ARCInstKind::RetainRV - "objc_retainAutorelease", // ARCInstKind::FusedRetainAutorelease - "objc_retainedObject", // ARCInstKind::NoopCast - "objc_retain", // ARCInstKind::Retain - "objc_unretainedObject", // ARCInstKind::NoopCast - "objc_unretainedPointer", // ARCInstKind::NoopCast - "objc_unsafeClaimAutoreleasedReturnValue", // ARCInstKind::ClaimRV - true) - .Default(false); -} - static llvm::Constant *createARCRuntimeFunction(CodeGenModule &CGM, llvm::FunctionType *FTy, StringRef Name) { @@ -1847,9 +1834,6 @@ static llvm::Constant *createARCRuntimeFunction(CodeGenModule &CGM, // performance. F->addFnAttr(llvm::Attribute::NonLazyBind); } - - if (IsForwarding(Name)) - F->arg_begin()->addAttr(llvm::Attribute::Returned); } return RTF; @@ -2031,7 +2015,7 @@ static void emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF) { } else if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { llvm::FunctionType *type = llvm::FunctionType::get(CGF.VoidTy, /*variadic*/false); - + marker = llvm::InlineAsm::get(type, assembly, "", /*sideeffects*/ true); // If we're at -O1 and above, we don't want to litter the code @@ -2052,7 +2036,7 @@ static void emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF) { // Call the marker asm if we made one, which we do only at -O0. if (marker) - CGF.Builder.CreateCall(marker); + CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker)); } /// Retain the given object which is the result of a function call. @@ -2070,7 +2054,7 @@ CodeGenFunction::EmitARCRetainAutoreleasedReturnValue(llvm::Value *value) { /// Claim a possibly-autoreleased return value at +0. This is only /// valid to do in contexts which do not rely on the retain to keep -/// the object valid for for all of its uses; for example, when +/// the object valid for all of its uses; for example, when /// the value is ignored, or when it is being assigned to an /// __unsafe_unretained variable. /// @@ -2325,6 +2309,21 @@ void CodeGenFunction::EmitARCCopyWeak(Address dst, Address src) { "objc_copyWeak"); } +void CodeGenFunction::emitARCCopyAssignWeak(QualType Ty, Address DstAddr, + Address SrcAddr) { + llvm::Value *Object = EmitARCLoadWeakRetained(SrcAddr); + Object = EmitObjCConsumeObject(Ty, Object); + EmitARCStoreWeak(DstAddr, Object, false); +} + +void CodeGenFunction::emitARCMoveAssignWeak(QualType Ty, Address DstAddr, + Address SrcAddr) { + llvm::Value *Object = EmitARCLoadWeakRetained(SrcAddr); + Object = EmitObjCConsumeObject(Ty, Object); + EmitARCStoreWeak(DstAddr, Object, false); + EmitARCDestroyWeak(SrcAddr); +} + /// Produce the code to do a objc_autoreleasepool_push. /// call i8* \@objc_autoreleasePoolPush(void) llvm::Value *CodeGenFunction::EmitObjCAutoreleasePoolPush() { @@ -2369,10 +2368,10 @@ llvm::Value *CodeGenFunction::EmitObjCMRRAutoreleasePoolPush() { IdentifierInfo *II = &CGM.getContext().Idents.get("alloc"); Selector AllocSel = getContext().Selectors.getSelector(0, &II); CallArgList Args; - RValue AllocRV = - Runtime.GenerateMessageSend(*this, ReturnValueSlot(), + RValue AllocRV = + Runtime.GenerateMessageSend(*this, ReturnValueSlot(), getContext().getObjCIdType(), - AllocSel, Receiver, Args); + AllocSel, Receiver, Args); // [Receiver init] Receiver = AllocRV.getScalarVal(); @@ -2381,7 +2380,7 @@ llvm::Value *CodeGenFunction::EmitObjCMRRAutoreleasePoolPush() { RValue InitRV = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), getContext().getObjCIdType(), - InitSel, Receiver, Args); + InitSel, Receiver, Args); return InitRV.getScalarVal(); } @@ -2392,7 +2391,7 @@ void CodeGenFunction::EmitObjCMRRAutoreleasePoolPop(llvm::Value *Arg) { Selector DrainSel = getContext().Selectors.getSelector(0, &II); CallArgList Args; CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), - getContext().VoidTy, DrainSel, Arg, Args); + getContext().VoidTy, DrainSel, Arg, Args); } void CodeGenFunction::destroyARCStrongPrecise(CodeGenFunction &CGF, @@ -2472,7 +2471,7 @@ static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, e = e->IgnoreParens(); QualType type = e->getType(); - // If we're loading retained from a __strong xvalue, we can avoid + // If we're loading retained from a __strong xvalue, we can avoid // an extra retain/release pair by zeroing out the source of this // "move" operation. if (e->isXValue() && @@ -2480,14 +2479,14 @@ static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, type.getObjCLifetime() == Qualifiers::OCL_Strong) { // Emit the lvalue. LValue lv = CGF.EmitLValue(e); - + // Load the object pointer. llvm::Value *result = CGF.EmitLoadOfLValue(lv, SourceLocation()).getScalarVal(); - + // Set the source pointer to NULL. CGF.EmitStoreOfScalar(getNullForVariable(lv.getAddress()), lv); - + return TryEmitResult(result, true); } @@ -3226,7 +3225,7 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( assert(PID->getSetterCXXAssignment() && "SetterCXXAssignment - null"); if ((HelperFn = CGM.getAtomicSetterHelperFnMap(Ty))) return HelperFn; - + ASTContext &C = getContext(); IdentifierInfo *II = &CGM.getContext().Idents.get("__assign_helper_atomic_property_"); @@ -3242,7 +3241,7 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( QualType SrcTy = Ty; SrcTy.addConst(); SrcTy = C.getPointerType(SrcTy); - + FunctionArgList args; ImplicitParamDecl DstDecl(getContext(), FD, SourceLocation(), /*Id=*/nullptr, DestTy, ImplicitParamDecl::Other); @@ -3255,32 +3254,32 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args); llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); - + llvm::Function *Fn = llvm::Function::Create(LTy, llvm::GlobalValue::InternalLinkage, "__assign_helper_atomic_property_", &CGM.getModule()); - CGM.SetInternalFunctionAttributes(nullptr, Fn, FI); + CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); StartFunction(FD, C.VoidTy, Fn, FI, args); - + DeclRefExpr DstExpr(&DstDecl, false, DestTy, VK_RValue, SourceLocation()); UnaryOperator DST(&DstExpr, UO_Deref, DestTy->getPointeeType(), - VK_LValue, OK_Ordinary, SourceLocation()); - + VK_LValue, OK_Ordinary, SourceLocation(), false); + DeclRefExpr SrcExpr(&SrcDecl, false, SrcTy, VK_RValue, SourceLocation()); UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(), - VK_LValue, OK_Ordinary, SourceLocation()); - + VK_LValue, OK_Ordinary, SourceLocation(), false); + Expr *Args[2] = { &DST, &SRC }; CallExpr *CalleeExp = cast<CallExpr>(PID->getSetterCXXAssignment()); CXXOperatorCallExpr TheCall(C, OO_Equal, CalleeExp->getCallee(), Args, DestTy->getPointeeType(), VK_LValue, SourceLocation(), FPOptions()); - + EmitStmt(&TheCall); FinishFunction(); @@ -3308,8 +3307,8 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( assert(PID->getGetterCXXConstructor() && "getGetterCXXConstructor - null"); if ((HelperFn = CGM.getAtomicGetterHelperFnMap(Ty))) return HelperFn; - - + + ASTContext &C = getContext(); IdentifierInfo *II = &CGM.getContext().Idents.get("__copy_helper_atomic_property_"); @@ -3325,7 +3324,7 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( QualType SrcTy = Ty; SrcTy.addConst(); SrcTy = C.getPointerType(SrcTy); - + FunctionArgList args; ImplicitParamDecl DstDecl(getContext(), FD, SourceLocation(), /*Id=*/nullptr, DestTy, ImplicitParamDecl::Other); @@ -3338,24 +3337,24 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( CGM.getTypes().arrangeBuiltinFunctionDeclaration(C.VoidTy, args); llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); - + llvm::Function *Fn = llvm::Function::Create(LTy, llvm::GlobalValue::InternalLinkage, "__copy_helper_atomic_property_", &CGM.getModule()); - - CGM.SetInternalFunctionAttributes(nullptr, Fn, FI); + + CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); StartFunction(FD, C.VoidTy, Fn, FI, args); - + DeclRefExpr SrcExpr(&SrcDecl, false, SrcTy, VK_RValue, SourceLocation()); - + UnaryOperator SRC(&SrcExpr, UO_Deref, SrcTy->getPointeeType(), - VK_LValue, OK_Ordinary, SourceLocation()); - - CXXConstructExpr *CXXConstExpr = + VK_LValue, OK_Ordinary, SourceLocation(), false); + + CXXConstructExpr *CXXConstExpr = cast<CXXConstructExpr>(PID->getGetterCXXConstructor()); - + SmallVector<Expr*, 4> ConstructorArgs; ConstructorArgs.push_back(&SRC); ConstructorArgs.append(std::next(CXXConstExpr->arg_begin()), @@ -3372,20 +3371,21 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( CXXConstExpr->requiresZeroInitialization(), CXXConstExpr->getConstructionKind(), SourceRange()); - + DeclRefExpr DstExpr(&DstDecl, false, DestTy, VK_RValue, SourceLocation()); - + RValue DV = EmitAnyExpr(&DstExpr); CharUnits Alignment = getContext().getTypeAlignInChars(TheCXXConstructExpr->getType()); - EmitAggExpr(TheCXXConstructExpr, + EmitAggExpr(TheCXXConstructExpr, AggValueSlot::forAddr(Address(DV.getScalarVal(), Alignment), Qualifiers(), AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, - AggValueSlot::IsNotAliased)); - + AggValueSlot::IsNotAliased, + AggValueSlot::DoesNotOverlap)); + FinishFunction(); HelperFn = llvm::ConstantExpr::getBitCast(Fn, VoidPtrTy); CGM.setAtomicGetterHelperFnMap(Ty, HelperFn); |
