[cfe-commits] r108882 - /cfe/trunk/lib/CodeGen/CGExprCXX.cpp
Chris Lattner
sabre at nondot.org
Tue Jul 20 11:45:57 PDT 2010
Author: lattner
Date: Tue Jul 20 13:45:57 2010
New Revision: 108882
URL: http://llvm.org/viewvc/llvm-project?rev=108882&view=rev
Log:
remove the special case for constant array sizes from
EmitCXXNewAllocSize. This code uses IRBuilder, which does
constant folding already.
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=108882&r1=108881&r2=108882&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Jul 20 13:45:57 2010
@@ -420,9 +420,9 @@
}
static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context,
- CodeGenFunction &CGF,
+ CodeGenFunction &CGF,
const CXXNewExpr *E,
- llvm::Value *& NumElements) {
+ llvm::Value *&NumElements) {
QualType Type = E->getAllocatedType();
CharUnits TypeSize = CGF.getContext().getTypeSizeInChars(Type);
const llvm::Type *SizeTy = CGF.ConvertType(CGF.getContext().getSizeType());
@@ -432,28 +432,6 @@
CharUnits CookiePadding = CalculateCookiePadding(CGF.getContext(), E);
- Expr::EvalResult Result;
- if (E->getArraySize()->Evaluate(Result, CGF.getContext()) &&
- !Result.HasSideEffects && Result.Val.isInt()) {
-
- CharUnits AllocSize =
- Result.Val.getInt().getZExtValue() * TypeSize + CookiePadding;
-
- NumElements =
- llvm::ConstantInt::get(SizeTy, Result.Val.getInt().getZExtValue());
- while (const ArrayType *AType = Context.getAsArrayType(Type)) {
- const llvm::ArrayType *llvmAType =
- cast<llvm::ArrayType>(CGF.ConvertType(Type));
- NumElements =
- CGF.Builder.CreateMul(NumElements,
- llvm::ConstantInt::get(
- SizeTy, llvmAType->getNumElements()));
- Type = AType->getElementType();
- }
-
- return llvm::ConstantInt::get(SizeTy, AllocSize.getQuantity());
- }
-
// Emit the array size expression.
NumElements = CGF.EmitScalarExpr(E->getArraySize());
More information about the cfe-commits
mailing list