diff options
author | Ken Dyck <kd@kendyck.com> | 2011-04-24 17:25:32 +0000 |
---|---|---|
committer | Ken Dyck <kd@kendyck.com> | 2011-04-24 17:25:32 +0000 |
commit | 5ff1a3508b39cfe3c9d108679a6532d85586b5ce (patch) | |
tree | 80ec5e9ab681c2a6225315e4e7d9bec3ef7b0ff5 /lib/CodeGen/CGExprAgg.cpp | |
parent | 02c45333b8310bb792a15f85f219706025f9752c (diff) |
Convert type size and alignment to CharUnits in CheckAggExprForMemSetUse().
No change in functionality intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130112 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 3910ee7ce6..5c2dc7f511 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -804,26 +804,27 @@ static void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E, if (Slot.isZeroed() || Slot.isVolatile() || Slot.getAddr() == 0) return; // If the type is 16-bytes or smaller, prefer individual stores over memset. - std::pair<uint64_t, unsigned> TypeInfo = - CGF.getContext().getTypeInfo(E->getType()); - if (TypeInfo.first/8 <= 16) + std::pair<CharUnits, CharUnits> TypeInfo = + CGF.getContext().getTypeInfoInChars(E->getType()); + if (TypeInfo.first <= CharUnits::fromQuantity(16)) return; // Check to see if over 3/4 of the initializer are known to be zero. If so, // we prefer to emit memset + individual stores for the rest. - uint64_t NumNonZeroBytes = GetNumNonZeroBytesInInit(E, CGF).getQuantity(); - if (NumNonZeroBytes*4 > TypeInfo.first/8) + CharUnits NumNonZeroBytes = GetNumNonZeroBytesInInit(E, CGF); + if (NumNonZeroBytes*4 > TypeInfo.first) return; // Okay, it seems like a good idea to use an initial memset, emit the call. - llvm::Constant *SizeVal = CGF.Builder.getInt64(TypeInfo.first/8); - unsigned Align = TypeInfo.second/8; + llvm::Constant *SizeVal = CGF.Builder.getInt64(TypeInfo.first.getQuantity()); + CharUnits Align = TypeInfo.second; llvm::Value *Loc = Slot.getAddr(); const llvm::Type *BP = llvm::Type::getInt8PtrTy(CGF.getLLVMContext()); Loc = CGF.Builder.CreateBitCast(Loc, BP); - CGF.Builder.CreateMemSet(Loc, CGF.Builder.getInt8(0), SizeVal, Align, false); + CGF.Builder.CreateMemSet(Loc, CGF.Builder.getInt8(0), SizeVal, + Align.getQuantity(), false); // Tell the AggExprEmitter that the slot is known zero. Slot.setZeroed(); |