From 6ba9aaed5eb612402d69117a0b63351272b4ae2e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 20 Jul 2010 18:49:33 +0000 Subject: [PATCH] delete a loop that just generates dead code. In an example like this: void *test(long N) { return new int[N][42][42]; } the loop generates two dead mul instructions: %tmp = load i64* %N.addr ; [#uses=2] %0 = mul i64 %tmp, 7056 ; [#uses=1] %1 = mul i64 %tmp, 42 ; [#uses=1] %2 = mul i64 %1, 42 ; [#uses=0] %call = call noalias i8* @_Znam(i64 %0) ; [#uses=1] The scale of these multiplies is already handled by the typesize stuff. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108884 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprCXX.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index 7ff452d8c8..f9c4b30d0b 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -440,16 +440,6 @@ static llvm::Value *EmitCXXNewAllocSize(ASTContext &Context, CGF.Builder.CreateMul(NumElements, llvm::ConstantInt::get(SizeTy, TypeSize.getQuantity())); - - while (const ArrayType *AType = Context.getAsArrayType(Type)) { - const llvm::ArrayType *llvmAType = - cast(CGF.ConvertType(Type)); - NumElements = - CGF.Builder.CreateMul(NumElements, - llvm::ConstantInt::get( - SizeTy, llvmAType->getNumElements())); - Type = AType->getElementType(); - } // And add the cookie padding if necessary. if (!CookiePadding.isZero()) -- 2.40.0