[cfe-commits] r123805 - in /cfe/trunk/lib/CodeGen: CGCall.cpp CGExpr.cpp CGExprCXX.cpp CGExprScalar.cpp CGObjC.cpp
Ken Dyck
kd at kendyck.com
Tue Jan 18 17:58:38 PST 2011
Author: kjdyck
Date: Tue Jan 18 19:58:38 2011
New Revision: 123805
URL: http://llvm.org/viewvc/llvm-project?rev=123805&view=rev
Log:
Replace calls to getTypeSize() and getTypeAlign() with their 'InChars'
counterparts where char units are needed.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=123805&r1=123804&r2=123805&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Jan 18 19:58:38 2011
@@ -879,18 +879,19 @@
// FIXME: We should have a common utility for generating an aggregate
// copy.
const llvm::Type *I8PtrTy = Builder.getInt8PtrTy();
- unsigned Size = getContext().getTypeSize(Ty) / 8;
+ CharUnits Size = getContext().getTypeSizeInChars(Ty);
Builder.CreateMemCpy(Builder.CreateBitCast(AlignedTemp, I8PtrTy),
Builder.CreateBitCast(V, I8PtrTy),
- llvm::ConstantInt::get(IntPtrTy, Size),
+ llvm::ConstantInt::get(IntPtrTy,
+ Size.getQuantity()),
ArgI.getIndirectAlign(),
false);
V = AlignedTemp;
}
} else {
// Load scalar value from indirect argument.
- unsigned Alignment = getContext().getTypeAlignInChars(Ty).getQuantity();
- V = EmitLoadOfScalar(V, false, Alignment, Ty);
+ CharUnits Alignment = getContext().getTypeAlignInChars(Ty);
+ V = EmitLoadOfScalar(V, false, Alignment.getQuantity(), Ty);
if (!getContext().typesAreCompatible(Ty, Arg->getType())) {
// This must be a promotion, for something like
// "void a(x) short x; {..."
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=123805&r1=123804&r2=123805&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Jan 18 19:58:38 2011
@@ -475,7 +475,8 @@
LValue CodeGenFunction::EmitCheckedLValue(const Expr *E) {
LValue LV = EmitLValue(E);
if (!isa<DeclRefExpr>(E) && !LV.isBitField() && LV.isSimple())
- EmitCheck(LV.getAddress(), getContext().getTypeSize(E->getType()) / 8);
+ EmitCheck(LV.getAddress(),
+ getContext().getTypeSizeInChars(E->getType()).getQuantity());
return LV;
}
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=123805&r1=123804&r2=123805&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Jan 18 19:58:38 2011
@@ -640,8 +640,9 @@
if (NewPtr->getType() != BP)
NewPtr = CGF.Builder.CreateBitCast(NewPtr, BP, "tmp");
+ CharUnits Alignment = CGF.getContext().getTypeAlignInChars(T);
CGF.Builder.CreateMemSet(NewPtr, CGF.Builder.getInt8(0), Size,
- CGF.getContext().getTypeAlign(T)/8, false);
+ Alignment.getQuantity(), false);
}
static void EmitNewInitializer(CodeGenFunction &CGF, const CXXNewExpr *E,
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=123805&r1=123804&r2=123805&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Jan 18 19:58:38 2011
@@ -1245,10 +1245,10 @@
if (const ObjCObjectType *OIT = PTEE->getAs<ObjCObjectType>()) {
// Handle interface types, which are not represented with a concrete
// type.
- int size = CGF.getContext().getTypeSize(OIT) / 8;
+ CharUnits size = CGF.getContext().getTypeSizeInChars(OIT);
if (!isInc)
size = -size;
- Inc = llvm::ConstantInt::get(Inc->getType(), size);
+ Inc = llvm::ConstantInt::get(Inc->getType(), size.getQuantity());
const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(VMContext);
InVal = Builder.CreateBitCast(InVal, i8Ty);
NextVal = Builder.CreateGEP(InVal, Inc, "add.ptr");
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=123805&r1=123804&r2=123805&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Jan 18 19:58:38 2011
@@ -241,9 +241,10 @@
Types.ConvertType(getContext().VoidPtrTy)));
Args.push_back(std::make_pair(RV, getContext().VoidPtrTy));
// sizeof (Type of Ivar)
- uint64_t Size = getContext().getTypeSize(Ivar->getType()) / 8;
+ CharUnits Size = getContext().getTypeSizeInChars(Ivar->getType());
llvm::Value *SizeVal =
- llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy), Size);
+ llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy),
+ Size.getQuantity());
Args.push_back(std::make_pair(RValue::get(SizeVal),
getContext().LongTy));
llvm::Value *isAtomic =
@@ -374,9 +375,10 @@
RV = RValue::get(ArgAsPtrTy);
Args.push_back(std::make_pair(RV, getContext().VoidPtrTy));
// sizeof (Type of Ivar)
- uint64_t Size = getContext().getTypeSize(Ivar->getType()) / 8;
+ CharUnits Size = getContext().getTypeSizeInChars(Ivar->getType());
llvm::Value *SizeVal =
- llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy), Size);
+ llvm::ConstantInt::get(Types.ConvertType(getContext().LongTy),
+ Size.getQuantity());
Args.push_back(std::make_pair(RValue::get(SizeVal),
getContext().LongTy));
llvm::Value *True =
More information about the cfe-commits
mailing list