[cfe-commits] r80060 - /cfe/trunk/lib/CodeGen/CGCXX.cpp

Fariborz Jahanian fjahanian at apple.com
Tue Aug 25 17:23:28 PDT 2009


Author: fjahanian
Date: Tue Aug 25 19:23:27 2009
New Revision: 80060

URL: http://llvm.org/viewvc/llvm-project?rev=80060&view=rev
Log:
Simplified default construction of array data members
in the constructor prologue.

Modified:
    cfe/trunk/lib/CodeGen/CGCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=80060&r1=80059&r2=80060&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCXX.cpp Tue Aug 25 19:23:27 2009
@@ -362,9 +362,9 @@
   
   // Generate: if (loop-index < number-of-elements fall to the loop body,
   // otherwise, go to the block after the for-loop.
-  uint64_t NumElements = CA->getSize().getZExtValue();
+  uint64_t NumElements = getContext().getConstantArrayElementCount(CA);
   llvm::Value * NumElementsPtr = 
-  llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), NumElements);
+    llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), NumElements);
   llvm::Value *Counter = Builder.CreateLoad(IndexPtr);
   llvm::Value *IsLess = Builder.CreateICmpULT(Counter, NumElementsPtr, 
                                               "isless");
@@ -376,21 +376,8 @@
   llvm::BasicBlock *ContinueBlock = createBasicBlock("for.inc");
   // Inside the loop body, emit the constructor call on the array element.
   Counter = Builder.CreateLoad(IndexPtr);
-  if (const ConstantArrayType *CAT = 
-      dyn_cast<ConstantArrayType>(Array->getElementType())) {
-    uint64_t delta = getContext().getConstantArrayElementCount(CAT);
-    // Address = This + delta*Counter for current loop iteration.
-    llvm::Value *DeltaPtr = 
-      llvm::ConstantInt::get(llvm::Type::getInt64Ty(VMContext), delta);
-    DeltaPtr = Builder.CreateMul(Counter, DeltaPtr, "mul");
-    llvm::Value *Address = 
-      Builder.CreateInBoundsGEP(This, DeltaPtr, "arrayidx");
-    EmitCXXAggrConstructorCall(D, CAT, Address);
-  } 
-  else {
-    llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
-    EmitCXXConstructorCall(D, Ctor_Complete, Address, 0, 0);
-  }
+  llvm::Value *Address = Builder.CreateInBoundsGEP(This, Counter, "arrayidx");
+  EmitCXXConstructorCall(D, Ctor_Complete, Address, 0, 0);
     
   EmitBlock(ContinueBlock);
   
@@ -1128,6 +1115,7 @@
 /// EmitClassAggrMemberwiseCopy - This routine generates code to copy a class
 /// array of objects from SrcValue to DestValue. Copying can be either a bitwise
 /// copy or via a copy constructor call.
+//  FIXME. Consolidate this with EmitCXXAggrConstructorCall.
 void CodeGenFunction::EmitClassAggrMemberwiseCopy(llvm::Value *Dest, 
                                             llvm::Value *Src,
                                             const ArrayType *Array,





More information about the cfe-commits mailing list