summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-20 18:45:57 +0000
committerChris Lattner <sabre@nondot.org>2010-07-20 18:45:57 +0000
commitcb46bdc34f977f1fc523c309f3894e4f13989c53 (patch)
treee5ad9392805e9034b8df5512683e2aa2747642e4 /clang/lib/CodeGen/CGExprCXX.cpp
parent4ab47682bb3abd4ffda70a8fd260fe8a20e81722 (diff)
downloadbcm5719-llvm-cb46bdc34f977f1fc523c309f3894e4f13989c53.tar.gz
bcm5719-llvm-cb46bdc34f977f1fc523c309f3894e4f13989c53.zip
remove the special case for constant array sizes from
EmitCXXNewAllocSize. This code uses IRBuilder, which does constant folding already. llvm-svn: 108882
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp26
1 files changed, 2 insertions, 24 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 69e5f0ef4be..7ff452d8c88 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -420,9 +420,9 @@ static CharUnits CalculateCookiePadding(ASTContext &Ctx, const CXXNewExpr *E) {
}
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 @@ static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context,
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());
OpenPOWER on IntegriCloud