aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGCXX.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-08-26 00:23:27 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-08-26 00:23:27 +0000
commit4f68d537c3f072366b25f3137f052eee36fddfcd (patch)
tree7d8f7063e60977a9a54ecfc4936d30d649e02031 /lib/CodeGen/CGCXX.cpp
parentdacd434c49658286c380c7b4c357d76d53cb4aa1 (diff)
Simplified default construction of array data members
in the constructor prologue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXX.cpp')
-rw-r--r--lib/CodeGen/CGCXX.cpp22
1 files changed, 5 insertions, 17 deletions
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 7a2c410fe8..3efda13db8 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -362,9 +362,9 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
// 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 @@ CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
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 @@ llvm::Value *CodeGenFunction::GenerateVtable(const CXXRecordDecl *RD) {
/// 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,