On Fri, Jun 24, 2011 at 7:11 PM, John McCall <[email protected]> wrote: > Author: rjmccall > Date: Fri Jun 24 21:11:03 2011 > New Revision: 133860 > > URL: http://llvm.org/viewvc/llvm-project?rev=133860&view=rev > Log: > LValue carries a type now, so simplify the main EmitLoad/Store APIs > by removing the redundant type parameter. > > > Modified: > cfe/trunk/lib/CodeGen/CGCall.cpp > cfe/trunk/lib/CodeGen/CGClass.cpp > cfe/trunk/lib/CodeGen/CGDecl.cpp > cfe/trunk/lib/CodeGen/CGExpr.cpp > cfe/trunk/lib/CodeGen/CGExprAgg.cpp > cfe/trunk/lib/CodeGen/CGExprScalar.cpp > cfe/trunk/lib/CodeGen/CGObjC.cpp > cfe/trunk/lib/CodeGen/CGStmt.cpp > cfe/trunk/lib/CodeGen/CodeGenFunction.h > > Modified: cfe/trunk/lib/CodeGen/CGCall.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGCall.cpp Fri Jun 24 21:11:03 2011 > @@ -359,7 +359,7 @@ > if (CodeGenFunction::hasAggregateLLVMType(FT)) { > AI = ExpandTypeFromArgs(FT, LV, AI); > } else { > - EmitStoreThroughLValue(RValue::get(AI), LV, FT); > + EmitStoreThroughLValue(RValue::get(AI), LV); > ++AI; > } > } > @@ -386,7 +386,7 @@ > if (CodeGenFunction::hasAggregateLLVMType(FT)) { > ExpandTypeToArgs(FT, RValue::getAggregate(LV.getAddress()), Args); > } else { > - RValue RV = EmitLoadOfLValue(LV, FT); > + RValue RV = EmitLoadOfLValue(LV); > assert(RV.isScalar() && > "Unexpected non-scalar rvalue during struct expansion."); > Args.push_back(RV.getScalarVal()); > @@ -1329,8 +1329,7 @@ > // Perform the writeback. > QualType srcAddrType = writeback.AddressType; > CGF.EmitStoreThroughLValue(RValue::get(value), > - CGF.MakeAddrLValue(srcAddr, srcAddrType), > - srcAddrType); > + CGF.MakeAddrLValue(srcAddr, srcAddrType)); > > // Jump to the continuation block. > if (!provablyNonNull) > @@ -1407,7 +1406,7 @@ > // Perform a copy if necessary. > if (shouldCopy) { > LValue srcLV = CGF.MakeAddrLValue(srcAddr, srcAddrType); > - RValue srcRV = CGF.EmitLoadOfLValue(srcLV, srcAddrType); > + RValue srcRV = CGF.EmitLoadOfLValue(srcLV); > assert(srcRV.isScalar()); > > llvm::Value *src = srcRV.getScalarVal(); > > Modified: cfe/trunk/lib/CodeGen/CGClass.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGClass.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Jun 24 21:11:03 2011 > @@ -556,7 +556,7 @@ > CGF.EmitExprAsInit(MemberInit->getInit(), Field, LHS, false); > } else { > RValue RHS = RValue::get(CGF.EmitScalarExpr(MemberInit->getInit())); > - CGF.EmitStoreThroughLValue(RHS, LHS, FieldType); > + CGF.EmitStoreThroughLValue(RHS, LHS); > } > } else if (MemberInit->getInit()->getType()->isAnyComplexType()) { > CGF.EmitComplexExprIntoAddr(MemberInit->getInit(), LHS.getAddress(), > > Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGDecl.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Jun 24 21:11:03 2011 > @@ -482,7 +482,7 @@ > llvm::Value *value = EmitScalarExpr(init); > if (capturedByInit) > drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D)); > - EmitStoreThroughLValue(RValue::get(value), lvalue, lvalue.getType()); > + EmitStoreThroughLValue(RValue::get(value), lvalue); > return; > } > > @@ -579,7 +579,7 @@ > void CodeGenFunction::EmitScalarInit(llvm::Value *init, LValue lvalue) { > Qualifiers::ObjCLifetime lifetime = lvalue.getObjCLifetime(); > if (!lifetime) > - return EmitStoreThroughLValue(RValue::get(init), lvalue, > lvalue.getType()); > + return EmitStoreThroughLValue(RValue::get(init), lvalue); > > switch (lifetime) { > case Qualifiers::OCL_None: > @@ -982,7 +982,7 @@ > RValue rvalue = EmitReferenceBindingToExpr(init, D); > if (capturedByInit) > drillIntoBlockVariable(*this, lvalue, cast<VarDecl>(D)); > - EmitStoreThroughLValue(rvalue, lvalue, type); > + EmitStoreThroughLValue(rvalue, lvalue); > } else if (!hasAggregateLLVMType(type)) { > EmitScalarInit(init, D, lvalue, capturedByInit); > } else if (type->isAnyComplexType()) { > @@ -1163,10 +1163,11 @@ > } > > // Store the initial value into the alloca. > - if (doStore) > - EmitStoreOfScalar(Arg, DeclPtr, Ty.isVolatileQualified(), > - getContext().getDeclAlign(&D).getQuantity(), Ty, > - CGM.getTBAAInfo(Ty)); > + if (doStore) { > + LValue lv = MakeAddrLValue(DeclPtr, Ty, > + > getContext().getDeclAlign(&D).getQuantity()); > + EmitStoreOfScalar(Arg, lv); > + } > } > > llvm::Value *&DMEntry = LocalDeclMap[&D]; > > Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Jun 24 21:11:03 2011 > @@ -140,7 +140,7 @@ > else { > RValue RV = RValue::get(EmitScalarExpr(E, /*Ignore*/ false)); > LValue LV = MakeAddrLValue(Location, E->getType()); > - EmitStoreThroughLValue(RV, LV, E->getType()); > + EmitStoreThroughLValue(RV, LV); > } > } > > @@ -251,7 +251,7 @@ > return LV.getAddress(); > > // We have to load the lvalue. > - RV = CGF.EmitLoadOfLValue(LV, E->getType()); > + RV = CGF.EmitLoadOfLValue(LV); > } else { > if (!ObjCARCReferenceLifetimeType.isNull()) { > ReferenceTemporary = CreateReferenceTemporary(CGF, > @@ -395,7 +395,7 @@ > Object = CreateReferenceTemporary(CGF, T, InitializedDecl); > LValue TempLV = CGF.MakeAddrLValue(Object, > Adjustment.Field->getType()); > - CGF.EmitStoreThroughLValue(CGF.EmitLoadOfLValue(LV, T), TempLV, T); > + CGF.EmitStoreThroughLValue(CGF.EmitLoadOfLValue(LV), TempLV); > break; > } > > @@ -780,7 +780,7 @@ > /// EmitLoadOfLValue - Given an expression that represents a value lvalue, > this > /// method emits the address of the lvalue, then loads the result as an > rvalue, > /// returning the rvalue. > -RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) { > +RValue CodeGenFunction::EmitLoadOfLValue(LValue LV) { > if (LV.isObjCWeak()) { > // load of a __weak object. > llvm::Value *AddrWeakObj = LV.getAddress(); > @@ -791,17 +791,10 @@ > return RValue::get(EmitARCLoadWeak(LV.getAddress())); > > if (LV.isSimple()) { > - llvm::Value *Ptr = LV.getAddress(); > - > - // Functions are l-values that don't require loading. > - if (ExprType->isFunctionType()) > - return RValue::get(Ptr); > + assert(!LV.getType()->isFunctionType());
This asserts fires in practice: http://llvm.org/bugs/show_bug.cgi?id=10204 > > // Everything needs a load. > - return RValue::get(EmitLoadOfScalar(Ptr, LV.isVolatileQualified(), > - LV.getAlignment(), ExprType, > - LV.getTBAAInfo())); > - > + return RValue::get(EmitLoadOfScalar(LV)); > } > > if (LV.isVectorElt()) { > @@ -814,21 +807,20 @@ > // If this is a reference to a subset of the elements of a vector, either > // shuffle the input or extract/insert them as appropriate. > if (LV.isExtVectorElt()) > - return EmitLoadOfExtVectorElementLValue(LV, ExprType); > + return EmitLoadOfExtVectorElementLValue(LV); > > if (LV.isBitField()) > - return EmitLoadOfBitfieldLValue(LV, ExprType); > + return EmitLoadOfBitfieldLValue(LV); > > assert(LV.isPropertyRef() && "Unknown LValue type!"); > return EmitLoadOfPropertyRefLValue(LV); > } > > -RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV, > - QualType ExprType) { > +RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV) { > const CGBitFieldInfo &Info = LV.getBitFieldInfo(); > > // Get the output type. > - const llvm::Type *ResLTy = ConvertType(ExprType); > + const llvm::Type *ResLTy = ConvertType(LV.getType()); > unsigned ResSizeInBits = CGM.getTargetData().getTypeSizeInBits(ResLTy); > > // Compute the result as an OR of all of the individual component accesses. > @@ -854,7 +846,7 @@ > // Cast to the access type. > const llvm::Type *PTy = llvm::Type::getIntNPtrTy(getLLVMContext(), > AI.AccessWidth, > - > CGM.getContext().getTargetAddressSpace(ExprType)); > + CGM.getContext().getTargetAddressSpace(LV.getType())); > Ptr = Builder.CreateBitCast(Ptr, PTy); > > // Perform the load. > @@ -898,8 +890,7 @@ > > // If this is a reference to a subset of the elements of a vector, create an > // appropriate shufflevector. > -RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV, > - QualType ExprType) { > +RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV) { > llvm::Value *Vec = Builder.CreateLoad(LV.getExtVectorAddr(), > LV.isVolatileQualified(), "tmp"); > > @@ -907,7 +898,7 @@ > > // If the result of the expression is a non-vector type, we must be > extracting > // a single element. Just codegen as an extractelement. > - const VectorType *ExprVT = ExprType->getAs<VectorType>(); > + const VectorType *ExprVT = LV.getType()->getAs<VectorType>(); > if (!ExprVT) { > unsigned InIdx = getAccessedFieldNo(0, Elts); > llvm::Value *Elt = llvm::ConstantInt::get(Int32Ty, InIdx); > @@ -934,8 +925,7 @@ > /// EmitStoreThroughLValue - Store the specified rvalue into the specified > /// lvalue, where both are guaranteed to the have the same type, and that > type > /// is 'Ty'. > -void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, > - QualType Ty) { > +void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst) { > if (!Dst.isSimple()) { > if (Dst.isVectorElt()) { > // Read/modify/write the vector, inserting the new element. > @@ -950,10 +940,10 @@ > // If this is an update of extended vector elements, insert them as > // appropriate. > if (Dst.isExtVectorElt()) > - return EmitStoreThroughExtVectorComponentLValue(Src, Dst, Ty); > + return EmitStoreThroughExtVectorComponentLValue(Src, Dst); > > if (Dst.isBitField()) > - return EmitStoreThroughBitfieldLValue(Src, Dst, Ty); > + return EmitStoreThroughBitfieldLValue(Src, Dst); > > assert(Dst.isPropertyRef() && "Unknown LValue type"); > return EmitStoreThroughPropertyRefLValue(Src, Dst); > @@ -970,7 +960,7 @@ > break; > > case Qualifiers::OCL_Strong: > - EmitARCStoreStrong(Dst, Ty, Src.getScalarVal(), /*ignore*/ true); > + EmitARCStoreStrong(Dst, Src.getScalarVal(), /*ignore*/ true); > return; > > case Qualifiers::OCL_Weak: > @@ -978,7 +968,8 @@ > return; > > case Qualifiers::OCL_Autoreleasing: > - Src = RValue::get(EmitObjCExtendObjectLifetime(Ty, > Src.getScalarVal())); > + Src = RValue::get(EmitObjCExtendObjectLifetime(Dst.getType(), > + Src.getScalarVal())); > // fall into the normal path > break; > } > @@ -1021,18 +1012,17 @@ > } > > void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, > - QualType Ty, > llvm::Value **Result) { > const CGBitFieldInfo &Info = Dst.getBitFieldInfo(); > > // Get the output type. > - const llvm::Type *ResLTy = ConvertTypeForMem(Ty); > + const llvm::Type *ResLTy = ConvertTypeForMem(Dst.getType()); > unsigned ResSizeInBits = CGM.getTargetData().getTypeSizeInBits(ResLTy); > > // Get the source value, truncated to the width of the bit-field. > llvm::Value *SrcVal = Src.getScalarVal(); > > - if (Ty->isBooleanType()) > + if (Dst.getType()->isBooleanType()) > SrcVal = Builder.CreateIntCast(SrcVal, ResLTy, /*IsSigned=*/false); > > SrcVal = Builder.CreateAnd(SrcVal, llvm::APInt::getLowBitsSet(ResSizeInBits, > @@ -1127,8 +1117,7 @@ > } > > void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, > - LValue Dst, > - QualType Ty) { > + LValue Dst) { > // This access turns into a read/modify/write of the vector. Load the input > // value now. > llvm::Value *Vec = Builder.CreateLoad(Dst.getExtVectorAddr(), > @@ -1137,7 +1126,7 @@ > > llvm::Value *SrcVal = Src.getScalarVal(); > > - if (const VectorType *VTy = Ty->getAs<VectorType>()) { > + if (const VectorType *VTy = Dst.getType()->getAs<VectorType>()) { > unsigned NumSrcElts = VTy->getNumElements(); > unsigned NumDstElts = > cast<llvm::VectorType>(Vec->getType())->getNumElements(); > @@ -2247,7 +2236,7 @@ > > RValue RV = EmitAnyExpr(E->getRHS()); > LValue LV = EmitLValue(E->getLHS()); > - EmitStoreThroughLValue(RV, LV, E->getType()); > + EmitStoreThroughLValue(RV, LV); > return LV; > } > > > Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Jun 24 21:11:03 2011 > @@ -588,7 +588,7 @@ > EmitNullInitializationToLValue(LV); > } else if (type->isReferenceType()) { > RValue RV = CGF.EmitReferenceBindingToExpr(E, /*InitializedDecl=*/0); > - CGF.EmitStoreThroughLValue(RV, LV, type); > + CGF.EmitStoreThroughLValue(RV, LV); > } else if (type->isAnyComplexType()) { > CGF.EmitComplexExprIntoAddr(E, LV.getAddress(), false); > } else if (CGF.hasAggregateLLVMType(type)) { > @@ -597,7 +597,7 @@ > } else if (LV.isSimple()) { > CGF.EmitScalarInit(E, /*D=*/0, LV, /*Captured=*/false); > } else { > - CGF.EmitStoreThroughLValue(RValue::get(CGF.EmitScalarExpr(E)), LV, type); > + CGF.EmitStoreThroughLValue(RValue::get(CGF.EmitScalarExpr(E)), LV); > } > } > > @@ -612,7 +612,7 @@ > if (!CGF.hasAggregateLLVMType(type)) { > // For non-aggregates, we can store zero > llvm::Value *null = llvm::Constant::getNullValue(CGF.ConvertType(type)); > - CGF.EmitStoreThroughLValue(RValue::get(null), lv, type); > + CGF.EmitStoreThroughLValue(RValue::get(null), lv); > } else { > // There's a potential optimization opportunity in combining > // memsets; that would be easy for arrays, but relatively > > Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Jun 24 21:11:03 2011 > @@ -82,15 +82,15 @@ > LValue EmitLValue(const Expr *E) { return CGF.EmitLValue(E); } > LValue EmitCheckedLValue(const Expr *E) { return CGF.EmitCheckedLValue(E); } > > - Value *EmitLoadOfLValue(LValue LV, QualType T) { > - return CGF.EmitLoadOfLValue(LV, T).getScalarVal(); > + Value *EmitLoadOfLValue(LValue LV) { > + return CGF.EmitLoadOfLValue(LV).getScalarVal(); > } > > /// EmitLoadOfLValue - Given an expression with complex type that > represents a > /// value l-value, this method emits the address of the l-value, then loads > /// and returns the result. > Value *EmitLoadOfLValue(const Expr *E) { > - return EmitLoadOfLValue(EmitCheckedLValue(E), E->getType()); > + return EmitLoadOfLValue(EmitCheckedLValue(E)); > } > > /// EmitConversionToBool - Convert the specified expression value to a > @@ -197,7 +197,7 @@ > > Value *VisitOpaqueValueExpr(OpaqueValueExpr *E) { > if (E->isGLValue()) > - return EmitLoadOfLValue(CGF.getOpaqueLValueMapping(E), E->getType()); > + return EmitLoadOfLValue(CGF.getOpaqueLValueMapping(E)); > > // Otherwise, assume the mapping is the scalar directly. > return CGF.getOpaqueRValueMapping(E).getScalarVal(); > @@ -252,7 +252,7 @@ > > Value *VisitObjCIsaExpr(ObjCIsaExpr *E) { > LValue LV = CGF.EmitObjCIsaExpr(E); > - Value *V = CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal(); > + Value *V = CGF.EmitLoadOfLValue(LV).getScalarVal(); > return V; > } > > @@ -1018,7 +1018,7 @@ > Value *V = EmitLValue(E).getAddress(); > V = Builder.CreateBitCast(V, > > ConvertType(CGF.getContext().getPointerType(DestTy))); > - return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), DestTy); > + return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy)); > } > > case CK_AnyPointerToObjCPointerCast: > @@ -1125,7 +1125,7 @@ > assert(CGF.getContext().hasSameUnqualifiedType(E->getType(), DestTy)); > assert(E->isGLValue() && E->getObjectKind() == OK_ObjCProperty && > "CK_GetObjCProperty for non-lvalue or non-ObjCProperty"); > - RValue RV = CGF.EmitLoadOfLValue(CGF.EmitLValue(E), E->getType()); > + RValue RV = CGF.EmitLoadOfLValue(CGF.EmitLValue(E)); > return RV.getScalarVal(); > } > > @@ -1224,7 +1224,7 @@ > > Value *ScalarExprEmitter::VisitBlockDeclRefExpr(const BlockDeclRefExpr *E) { > LValue LV = CGF.EmitBlockDeclRefLValue(E); > - return CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal(); > + return CGF.EmitLoadOfLValue(LV).getScalarVal(); > } > > //===----------------------------------------------------------------------===// > @@ -1261,7 +1261,7 @@ > bool isInc, bool isPre) { > > QualType type = E->getSubExpr()->getType(); > - llvm::Value *value = EmitLoadOfLValue(LV, type); > + llvm::Value *value = EmitLoadOfLValue(LV); > llvm::Value *input = value; > > int amount = (isInc ? 1 : -1); > @@ -1375,9 +1375,9 @@ > > // Store the updated result through the lvalue. > if (LV.isBitField()) > - CGF.EmitStoreThroughBitfieldLValue(RValue::get(value), LV, type, &value); > + CGF.EmitStoreThroughBitfieldLValue(RValue::get(value), LV, &value); > else > - CGF.EmitStoreThroughLValue(RValue::get(value), LV, type); > + CGF.EmitStoreThroughLValue(RValue::get(value), LV); > > // If this is a postinc, return the value read from memory, otherwise use > the > // updated value. > @@ -1558,8 +1558,7 @@ > // Note that we have to ask E because Op might be an l-value that > // this won't work for, e.g. an Obj-C property. > if (E->isGLValue()) > - return CGF.EmitLoadOfLValue(CGF.EmitLValue(E), E->getType()) > - .getScalarVal(); > + return CGF.EmitLoadOfLValue(CGF.EmitLValue(E)).getScalarVal(); > > // Otherwise, calculate and project. > return CGF.EmitComplexExpr(Op, false, true).first; > @@ -1575,8 +1574,7 @@ > // Note that we have to ask E because Op might be an l-value that > // this won't work for, e.g. an Obj-C property. > if (Op->isGLValue()) > - return CGF.EmitLoadOfLValue(CGF.EmitLValue(E), E->getType()) > - .getScalarVal(); > + return CGF.EmitLoadOfLValue(CGF.EmitLValue(E)).getScalarVal(); > > // Otherwise, calculate and project. > return CGF.EmitComplexExpr(Op, true, false).second; > @@ -1628,7 +1626,7 @@ > OpInfo.E = E; > // Load/convert the LHS. > LValue LHSLV = EmitCheckedLValue(E->getLHS()); > - OpInfo.LHS = EmitLoadOfLValue(LHSLV, LHSTy); > + OpInfo.LHS = EmitLoadOfLValue(LHSLV); > OpInfo.LHS = EmitScalarConversion(OpInfo.LHS, LHSTy, > E->getComputationLHSType()); > > @@ -1643,10 +1641,9 @@ > // 'An assignment expression has the value of the left operand after the > // assignment...'. > if (LHSLV.isBitField()) > - CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, LHSTy, > - &Result); > + CGF.EmitStoreThroughBitfieldLValue(RValue::get(Result), LHSLV, &Result); > else > - CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV, LHSTy); > + CGF.EmitStoreThroughLValue(RValue::get(Result), LHSLV); > > return LHSLV; > } > @@ -1674,7 +1671,7 @@ > return RHS; > > // Otherwise, reload the value. > - return EmitLoadOfLValue(LHS, E->getType()); > + return EmitLoadOfLValue(LHS); > } > > void ScalarExprEmitter::EmitUndefinedBehaviorIntegerDivAndRemCheck( > @@ -2262,10 +2259,9 @@ > // 'An assignment expression has the value of the left operand after > // the assignment...'. > if (LHS.isBitField()) > - CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, E->getType(), > - &RHS); > + CGF.EmitStoreThroughBitfieldLValue(RValue::get(RHS), LHS, &RHS); > else > - CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS, E->getType()); > + CGF.EmitStoreThroughLValue(RValue::get(RHS), LHS); > } > > // If the result is clearly ignored, return now. > @@ -2285,7 +2281,7 @@ > return RHS; > > // Otherwise, reload the value. > - return EmitLoadOfLValue(LHS, E->getType()); > + return EmitLoadOfLValue(LHS); > } > > Value *ScalarExprEmitter::VisitBinLAnd(const BinaryOperator *E) { > @@ -2681,7 +2677,7 @@ > llvm::Value *Src = EmitScalarExpr(BaseExpr); > Builder.CreateStore(Src, V); > V = ScalarExprEmitter(*this).EmitLoadOfLValue( > - MakeAddrLValue(V, E->getType()), E->getType()); > + MakeAddrLValue(V, E->getType())); > } else { > if (E->isArrow()) > V = ScalarExprEmitter(*this).EmitLoadOfLValue(BaseExpr); > > Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGObjC.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGObjC.cpp Fri Jun 24 21:11:03 2011 > @@ -466,7 +466,7 @@ > } > else { > LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), > - Ivar, 0); > + Ivar, 0); > QualType propType = PD->getType(); > > llvm::Value *value; > @@ -478,7 +478,7 @@ > PD->getType()->isObjCRetainableType()) > value = emitARCRetainLoadOfScalar(*this, LV, IVART); > else > - value = EmitLoadOfLValue(LV, IVART).getScalarVal(); > + value = EmitLoadOfLValue(LV).getScalarVal(); > > value = Builder.CreateBitCast(value, ConvertType(propType)); > } > @@ -1141,7 +1141,7 @@ > // time through the loop. > if (!elementIsVariable) { > elementLValue = EmitLValue(cast<Expr>(S.getElement())); > - EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue, > elementType); > + EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue); > } else { > EmitScalarInit(CurrentItem, elementLValue); > } > @@ -1205,7 +1205,7 @@ > > llvm::Value *null = llvm::Constant::getNullValue(convertedElementType); > elementLValue = EmitLValue(cast<Expr>(S.getElement())); > - EmitStoreThroughLValue(RValue::get(null), elementLValue, elementType); > + EmitStoreThroughLValue(RValue::get(null), elementLValue); > } > > if (DI) { > @@ -1566,9 +1566,10 @@ > /// Store into a strong object. Sometimes calls this: > /// call void @objc_storeStrong(i8** %addr, i8* %value) > /// Other times, breaks it down into components. > -llvm::Value *CodeGenFunction::EmitARCStoreStrong(LValue dst, QualType type, > +llvm::Value *CodeGenFunction::EmitARCStoreStrong(LValue dst, > llvm::Value *newValue, > bool ignored) { > + QualType type = dst.getType(); > bool isBlock = type->isBlockPointerType(); > > // Use a store barrier at -O0 unless this is a block type or the > @@ -1585,15 +1586,11 @@ > newValue = EmitARCRetain(type, newValue); > > // Read the old value. > - llvm::Value *oldValue = > - EmitLoadOfScalar(dst.getAddress(), dst.isVolatileQualified(), > - dst.getAlignment(), type, dst.getTBAAInfo()); > + llvm::Value *oldValue = EmitLoadOfScalar(dst); > > // Store. We do this before the release so that any deallocs won't > // see the old value. > - EmitStoreOfScalar(newValue, dst.getAddress(), > - dst.isVolatileQualified(), dst.getAlignment(), > - type, dst.getTBAAInfo()); > + EmitStoreOfScalar(newValue, dst); > > // Finally, release the old value. > EmitARCRelease(oldValue, /*precise*/ false); > @@ -2184,7 +2181,7 @@ > case Qualifiers::OCL_ExplicitNone: > case Qualifiers::OCL_Strong: > case Qualifiers::OCL_Autoreleasing: > - return TryEmitResult(CGF.EmitLoadOfLValue(lvalue, type).getScalarVal(), > + return TryEmitResult(CGF.EmitLoadOfLValue(lvalue).getScalarVal(), > false); > > case Qualifiers::OCL_Weak: > @@ -2279,7 +2276,7 @@ > > // Load the object pointer and cast it to the appropriate type. > QualType exprType = e->getType(); > - llvm::Value *result = CGF.EmitLoadOfLValue(lv, exprType).getScalarVal(); > + llvm::Value *result = CGF.EmitLoadOfLValue(lv).getScalarVal(); > > if (resultType) > result = CGF.Builder.CreateBitCast(result, resultType); > @@ -2288,8 +2285,7 @@ > llvm::Value *null > = llvm::ConstantPointerNull::get( > > cast<llvm::PointerType>(CGF.ConvertType(exprType))); > - CGF.EmitStoreOfScalar(null, lv.getAddress(), lv.isVolatileQualified(), > - lv.getAlignment(), exprType); > + CGF.EmitStoreOfScalar(null, lv); > > return TryEmitResult(result, true); > } > @@ -2430,7 +2426,7 @@ > e->getType(), lvalue.getTBAAInfo()); > EmitARCRelease(oldValue, /*precise*/ false); > } else { > - value = EmitARCStoreStrong(lvalue, e->getType(), value, ignored); > + value = EmitARCStoreStrong(lvalue, value, ignored); > } > > return std::pair<LValue,llvm::Value*>(lvalue, value); > > Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CGStmt.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGStmt.cpp Fri Jun 24 21:11:03 2011 > @@ -1299,7 +1299,7 @@ > llvm::Value *Arg; > if (Info.allowsRegister() || !Info.allowsMemory()) { > if (!CodeGenFunction::hasAggregateLLVMType(InputType)) { > - Arg = EmitLoadOfLValue(InputValue, InputType).getScalarVal(); > + Arg = EmitLoadOfLValue(InputValue).getScalarVal(); > } else { > const llvm::Type *Ty = ConvertType(InputType); > uint64_t Size = CGM.getTargetData().getTypeSizeInBits(Ty); > @@ -1637,7 +1637,6 @@ > } > } > > - EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i], > - ResultRegQualTys[i]); > + EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); > } > } > > Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=133860&r1=133859&r2=133860&view=diff > ============================================================================== > --- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original) > +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Fri Jun 24 21:11:03 2011 > @@ -1856,6 +1856,11 @@ > llvm::Value *EmitLoadOfScalar(llvm::Value *Addr, bool Volatile, > unsigned Alignment, QualType Ty, > llvm::MDNode *TBAAInfo = 0); > + > + /// EmitLoadOfScalar - Load a scalar value from an address, taking > + /// care to appropriately convert from the memory representation to > + /// the LLVM value representation. The l-value must be a simple > + /// l-value. > llvm::Value *EmitLoadOfScalar(LValue lvalue); > > /// EmitStoreOfScalar - Store a scalar value to an address, taking > @@ -1864,23 +1869,27 @@ > void EmitStoreOfScalar(llvm::Value *Value, llvm::Value *Addr, > bool Volatile, unsigned Alignment, QualType Ty, > llvm::MDNode *TBAAInfo = 0); > + > + /// EmitStoreOfScalar - Store a scalar value to an address, taking > + /// care to appropriately convert from the memory representation to > + /// the LLVM value representation. The l-value must be a simple > + /// l-value. > void EmitStoreOfScalar(llvm::Value *value, LValue lvalue); > > /// EmitLoadOfLValue - Given an expression that represents a value lvalue, > /// this method emits the address of the lvalue, then loads the result as an > /// rvalue, returning the rvalue. > - RValue EmitLoadOfLValue(LValue V, QualType LVType); > - RValue EmitLoadOfExtVectorElementLValue(LValue V, QualType LVType); > - RValue EmitLoadOfBitfieldLValue(LValue LV, QualType ExprType); > + RValue EmitLoadOfLValue(LValue V); > + RValue EmitLoadOfExtVectorElementLValue(LValue V); > + RValue EmitLoadOfBitfieldLValue(LValue LV); > RValue EmitLoadOfPropertyRefLValue(LValue LV, > ReturnValueSlot Return = ReturnValueSlot()); > > /// EmitStoreThroughLValue - Store the specified rvalue into the specified > /// lvalue, where both are guaranteed to the have the same type, and that > type > /// is 'Ty'. > - void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty); > - void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst, > - QualType Ty); > + void EmitStoreThroughLValue(RValue Src, LValue Dst); > + void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst); > void EmitStoreThroughPropertyRefLValue(RValue Src, LValue Dst); > > /// EmitStoreThroughLValue - Store Src into Dst with same constraints as > @@ -1889,7 +1898,7 @@ > /// \param Result [out] - If non-null, this will be set to a Value* for the > /// bit-field contents after the store, appropriate for use as the result of > /// an assignment to the bit-field. > - void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, QualType Ty, > + void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, > llvm::Value **Result=0); > > /// Emit an l-value for an assignment (simple or compound) of complex type. > @@ -2064,8 +2073,8 @@ > void EmitARCMoveWeak(llvm::Value *dst, llvm::Value *src); > llvm::Value *EmitARCRetainAutorelease(QualType type, llvm::Value *value); > llvm::Value *EmitARCRetainAutoreleaseNonBlock(llvm::Value *value); > - llvm::Value *EmitARCStoreStrong(LValue addr, QualType type, > - llvm::Value *value, bool ignored); > + llvm::Value *EmitARCStoreStrong(LValue lvalue, llvm::Value *value, > + bool ignored); > llvm::Value *EmitARCStoreStrongCall(llvm::Value *addr, llvm::Value *value, > bool ignored); > llvm::Value *EmitARCRetain(QualType type, llvm::Value *value); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
