From: Ken Dyck Date: Sun, 24 Apr 2011 17:25:32 +0000 (+0000) Subject: Convert type size and alignment to CharUnits in CheckAggExprForMemSetUse(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5ff1a3508b39cfe3c9d108679a6532d85586b5ce;p=clang 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 --- 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 TypeInfo = - CGF.getContext().getTypeInfo(E->getType()); - if (TypeInfo.first/8 <= 16) + std::pair 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();