[cfe-commits] r111716 - in /cfe/trunk/lib/CodeGen: CGClass.cpp CGExpr.cpp CGExprAgg.cpp CGExprScalar.cpp
Daniel Dunbar
daniel at zuster.org
Fri Aug 20 20:08:16 PDT 2010
Author: ddunbar
Date: Fri Aug 20 22:08:16 2010
New Revision: 111716
URL: http://llvm.org/viewvc/llvm-project?rev=111716&view=rev
Log:
IRgen: Switch a bunch of trivial MakeAddr calls to use MakeAddrLValue.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=111716&r1=111715&r2=111716&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Fri Aug 20 22:08:16 2010
@@ -528,7 +528,7 @@
BasePtr = llvm::PointerType::getUnqual(BasePtr);
llvm::Value *BaseAddrPtr = CGF.Builder.CreateBitCast(LHS.getAddress(),
BasePtr);
- LHS = LValue::MakeAddr(BaseAddrPtr, CGF.MakeQualifiers(BaseElementTy));
+ LHS = CGF.MakeAddrLValue(BaseAddrPtr, BaseElementTy);
// Create an array index that will be used to walk over all of the
// objects we're constructing.
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=111716&r1=111715&r2=111716&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Aug 20 22:08:16 2010
@@ -130,7 +130,7 @@
EmitAggExpr(E, Location, IsLocationVolatile, /*Ignore*/ false, IsInit);
else {
RValue RV = RValue::get(EmitScalarExpr(E, /*Ignore*/ false));
- LValue LV = LValue::MakeAddr(Location, MakeQualifiers(E->getType()));
+ LValue LV = MakeAddrLValue(Location, E->getType());
EmitStoreThroughLValue(RV, LV, E->getType());
}
}
@@ -475,8 +475,7 @@
const char *Name) {
ErrorUnsupported(E, Name);
llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType()));
- return LValue::MakeAddr(llvm::UndefValue::get(Ty),
- MakeQualifiers(E->getType()));
+ return MakeAddrLValue(llvm::UndefValue::get(Ty), E->getType());
}
LValue CodeGenFunction::EmitCheckedLValue(const Expr *E) {
@@ -1125,7 +1124,7 @@
llvm::Value *V = CGF.CGM.GetAddrOfGlobalVar(VD);
if (VD->getType()->isReferenceType())
V = CGF.Builder.CreateLoad(V, "tmp");
- LValue LV = LValue::MakeAddr(V, CGF.MakeQualifiers(E->getType()));
+ LValue LV = CGF.MakeAddrLValue(V, E->getType());
setObjCGCLValueClass(CGF.getContext(), E, LV);
return LV;
}
@@ -1145,7 +1144,7 @@
V = CGF.Builder.CreateBitCast(V, CGF.ConvertType(NoProtoType), "tmp");
}
}
- return LValue::MakeAddr(V, CGF.MakeQualifiers(E->getType()));
+ return CGF.MakeAddrLValue(V, E->getType());
}
LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
@@ -1155,10 +1154,7 @@
const ValueDecl* VD = cast<ValueDecl>(ND);
llvm::Constant *Aliasee = CGM.GetWeakRefReference(VD);
- Qualifiers Quals = MakeQualifiers(E->getType());
- LValue LV = LValue::MakeAddr(Aliasee, Quals);
-
- return LV;
+ return MakeAddrLValue(Aliasee, E->getType());
}
if (const VarDecl *VD = dyn_cast<VarDecl>(ND)) {
@@ -1201,8 +1197,7 @@
if (E->getQualifier()) {
const FieldDecl *FD = cast<FieldDecl>(ND);
llvm::Value *V = CGM.EmitPointerToDataMember(FD);
-
- return LValue::MakeAddr(V, MakeQualifiers(FD->getType()));
+ return MakeAddrLValue(V, FD->getType());
}
assert(false && "Unhandled DeclRefExpr");
@@ -1213,7 +1208,7 @@
}
LValue CodeGenFunction::EmitBlockDeclRefLValue(const BlockDeclRefExpr *E) {
- return LValue::MakeAddr(GetAddrOfBlockDecl(E), MakeQualifiers(E->getType()));
+ return MakeAddrLValue(GetAddrOfBlockDecl(E), E->getType());
}
LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) {
@@ -1246,9 +1241,9 @@
case UnaryOperator::Imag: {
LValue LV = EmitLValue(E->getSubExpr());
unsigned Idx = E->getOpcode() == UnaryOperator::Imag;
- return LValue::MakeAddr(Builder.CreateStructGEP(LV.getAddress(),
+ return MakeAddrLValue(Builder.CreateStructGEP(LV.getAddress(),
Idx, "idx"),
- MakeQualifiers(ExprTy));
+ ExprTy);
}
case UnaryOperator::PreInc:
case UnaryOperator::PreDec: {
@@ -1677,13 +1672,13 @@
assert(!FieldType.getObjCGCAttr() && "fields cannot have GC attrs");
- return LValue::MakeAddr(V, MakeQualifiers(FieldType));
+ return MakeAddrLValue(V, FieldType);
}
LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr* E){
llvm::Value *DeclPtr = CreateMemTemp(E->getType(), ".compoundliteral");
const Expr* InitExpr = E->getInitializer();
- LValue Result = LValue::MakeAddr(DeclPtr, MakeQualifiers(E->getType()));
+ LValue Result = MakeAddrLValue(DeclPtr, E->getType());
EmitAnyExprToMem(InitExpr, DeclPtr, /*Volatile*/ false);
@@ -1736,7 +1731,7 @@
EmitBlock(ContBlock);
Temp = Builder.CreateLoad(Temp, "lv");
- return LValue::MakeAddr(Temp, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(Temp, E->getType());
}
// ?: here should be an aggregate.
@@ -1768,7 +1763,7 @@
RValue RV = EmitLoadOfPropertyRefLValue(LV, QT);
assert(!RV.isScalar() && "EmitCastLValue-scalar cast of property ref");
llvm::Value *V = RV.getAggregateAddr();
- return LValue::MakeAddr(V, MakeQualifiers(QT));
+ return MakeAddrLValue(V, QT);
}
return LV;
}
@@ -1796,15 +1791,14 @@
// that temporary.
llvm::Value *V = CreateMemTemp(E->getType(), "ref.temp");
EmitAnyExprToMem(E, V, false, false);
- return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(V, E->getType());
}
case CastExpr::CK_Dynamic: {
LValue LV = EmitLValue(E->getSubExpr());
llvm::Value *V = LV.getAddress();
const CXXDynamicCastExpr *DCE = cast<CXXDynamicCastExpr>(E);
- return LValue::MakeAddr(EmitDynamicCast(V, DCE),
- MakeQualifiers(E->getType()));
+ return MakeAddrLValue(EmitDynamicCast(V, DCE), E->getType());
}
case CastExpr::CK_ConstructorConversion:
@@ -1835,7 +1829,7 @@
E->path_begin(), E->path_end(),
/*NullCheckValue=*/false);
- return LValue::MakeAddr(Base, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(Base, E->getType());
}
case CastExpr::CK_ToUnion:
return EmitAggExprToLValue(E);
@@ -1852,7 +1846,7 @@
E->path_begin(), E->path_end(),
/*NullCheckValue=*/false);
- return LValue::MakeAddr(Derived, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(Derived, E->getType());
}
case CastExpr::CK_LValueBitCast: {
// This must be a reinterpret_cast (or c-style equivalent).
@@ -1861,14 +1855,14 @@
LValue LV = EmitLValue(E->getSubExpr());
llvm::Value *V = Builder.CreateBitCast(LV.getAddress(),
ConvertType(CE->getTypeAsWritten()));
- return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(V, E->getType());
}
case CastExpr::CK_ObjCObjectLValueCast: {
LValue LV = EmitLValue(E->getSubExpr());
QualType ToType = getContext().getLValueReferenceType(E->getType());
llvm::Value *V = Builder.CreateBitCast(LV.getAddress(),
ConvertType(ToType));
- return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(V, E->getType());
}
}
@@ -1878,7 +1872,7 @@
LValue CodeGenFunction::EmitNullInitializationLValue(
const CXXScalarValueInitExpr *E) {
QualType Ty = E->getType();
- LValue LV = LValue::MakeAddr(CreateMemTemp(Ty), MakeQualifiers(Ty));
+ LValue LV = MakeAddrLValue(CreateMemTemp(Ty), Ty);
EmitNullInitialization(LV.getAddress(), Ty);
return LV;
}
@@ -1958,13 +1952,13 @@
RValue RV = EmitCallExpr(E);
if (!RV.isScalar())
- return LValue::MakeAddr(RV.getAggregateAddr(),MakeQualifiers(E->getType()));
+ return MakeAddrLValue(RV.getAggregateAddr(), E->getType());
assert(E->getCallReturnType()->isReferenceType() &&
"Can't have a scalar return unless the return type is a "
"reference type!");
- return LValue::MakeAddr(RV.getScalarVal(), MakeQualifiers(E->getType()));
+ return MakeAddrLValue(RV.getScalarVal(), E->getType());
}
LValue CodeGenFunction::EmitVAArgExprLValue(const VAArgExpr *E) {
@@ -1975,13 +1969,12 @@
LValue CodeGenFunction::EmitCXXConstructLValue(const CXXConstructExpr *E) {
llvm::Value *Temp = CreateMemTemp(E->getType(), "tmp");
EmitCXXConstructExpr(Temp, E);
- return LValue::MakeAddr(Temp, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(Temp, E->getType());
}
LValue
CodeGenFunction::EmitCXXTypeidLValue(const CXXTypeidExpr *E) {
- llvm::Value *Temp = EmitCXXTypeidExpr(E);
- return LValue::MakeAddr(Temp, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(EmitCXXTypeidExpr(E), E->getType());
}
LValue
@@ -1995,20 +1988,19 @@
RValue RV = EmitObjCMessageExpr(E);
if (!RV.isScalar())
- return LValue::MakeAddr(RV.getAggregateAddr(),
- MakeQualifiers(E->getType()));
+ return MakeAddrLValue(RV.getAggregateAddr(), E->getType());
assert(E->getMethodDecl()->getResultType()->isReferenceType() &&
"Can't have a scalar return unless the return type is a "
"reference type!");
- return LValue::MakeAddr(RV.getScalarVal(), MakeQualifiers(E->getType()));
+ return MakeAddrLValue(RV.getScalarVal(), E->getType());
}
LValue CodeGenFunction::EmitObjCSelectorLValue(const ObjCSelectorExpr *E) {
llvm::Value *V =
CGM.getObjCRuntime().GetSelector(Builder, E->getSelector(), true);
- return LValue::MakeAddr(V, MakeQualifiers(E->getType()));
+ return MakeAddrLValue(V, E->getType());
}
llvm::Value *CodeGenFunction::EmitIvarOffset(const ObjCInterfaceDecl *Interface,
@@ -2070,7 +2062,7 @@
LValue CodeGenFunction::EmitStmtExprLValue(const StmtExpr *E) {
// Can only get l-value for message expression returning aggregate type
RValue RV = EmitAnyExprToTemp(E);
- return LValue::MakeAddr(RV.getAggregateAddr(), MakeQualifiers(E->getType()));
+ return MakeAddrLValue(RV.getAggregateAddr(), E->getType());
}
RValue CodeGenFunction::EmitCall(QualType CalleeType, llvm::Value *Callee,
@@ -2113,6 +2105,6 @@
const llvm::Type *PType = ConvertType(getContext().getPointerType(Ty));
AddV = Builder.CreateBitCast(AddV, PType);
- return LValue::MakeAddr(AddV, MakeQualifiers(Ty));
+ return MakeAddrLValue(AddV, Ty);
}
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=111716&r1=111715&r2=111716&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Aug 20 22:08:16 2010
@@ -658,17 +658,15 @@
ElementType = CGF.getContext().getAsArrayType(ElementType)->getElementType();
// FIXME: were we intentionally ignoring address spaces and GC attributes?
- Qualifiers Quals = CGF.MakeQualifiers(ElementType);
for (uint64_t i = 0; i != NumArrayElements; ++i) {
llvm::Value *NextVal = Builder.CreateStructGEP(DestPtr, i, ".array");
+ LValue LV = CGF.MakeAddrLValue(NextVal, ElementType);
if (i < NumInitElements)
- EmitInitializationToLValue(E->getInit(i),
- LValue::MakeAddr(NextVal, Quals),
- ElementType);
+ EmitInitializationToLValue(E->getInit(i), LV, ElementType);
+
else
- EmitNullInitializationToLValue(LValue::MakeAddr(NextVal, Quals),
- ElementType);
+ EmitNullInitializationToLValue(LV, ElementType);
}
return;
}
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=111716&r1=111715&r2=111716&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Fri Aug 20 22:08:16 2010
@@ -932,9 +932,7 @@
Value *V = EmitLValue(E).getAddress();
V = Builder.CreateBitCast(V,
ConvertType(CGF.getContext().getPointerType(DestTy)));
- // FIXME: Are the qualifiers correct here?
- return EmitLoadOfLValue(LValue::MakeAddr(V, CGF.MakeQualifiers(DestTy)),
- DestTy);
+ return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), DestTy);
}
case CastExpr::CK_AnyPointerToObjCPointerCast:
@@ -1164,7 +1162,7 @@
NextVal = Builder.CreateGEP(InVal, Inc, "add.ptr");
llvm::Value *lhs = LV.getAddress();
lhs = Builder.CreateBitCast(lhs, llvm::PointerType::getUnqual(i8Ty));
- LV = LValue::MakeAddr(lhs, CGF.MakeQualifiers(ValTy));
+ LV = CGF.MakeAddrLValue(lhs, ValTy);
} else
NextVal = Builder.CreateInBoundsGEP(InVal, Inc, "ptrincdec");
} else {
@@ -2234,21 +2232,19 @@
V = CreateTempAlloca(ClassPtrTy, "resval");
llvm::Value *Src = EmitScalarExpr(BaseExpr);
Builder.CreateStore(Src, V);
- LValue LV = LValue::MakeAddr(V, MakeQualifiers(E->getType()));
- V = ScalarExprEmitter(*this).EmitLoadOfLValue(LV, E->getType());
- }
- else {
- if (E->isArrow())
- V = ScalarExprEmitter(*this).EmitLoadOfLValue(BaseExpr);
- else
- V = EmitLValue(BaseExpr).getAddress();
+ V = ScalarExprEmitter(*this).EmitLoadOfLValue(
+ MakeAddrLValue(V, E->getType()), E->getType());
+ } else {
+ if (E->isArrow())
+ V = ScalarExprEmitter(*this).EmitLoadOfLValue(BaseExpr);
+ else
+ V = EmitLValue(BaseExpr).getAddress();
}
// build Class* type
ClassPtrTy = ClassPtrTy->getPointerTo();
V = Builder.CreateBitCast(V, ClassPtrTy);
- LValue LV = LValue::MakeAddr(V, MakeQualifiers(E->getType()));
- return LV;
+ return MakeAddrLValue(V, E->getType());
}
More information about the cfe-commits
mailing list