aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-02-05 19:43:10 +0000
committerAnders Carlsson <andersca@mac.com>2009-02-05 19:43:10 +0000
commit96f214776c0f69069fee4d67557c8c7f416009a8 (patch)
tree68b462fe2367ffdd3d9d9cc7da9c48bbdc260265 /lib/CodeGen/CodeGenFunction.cpp
parent1a6b3686bf5671075c5b217fcfc1840cb0aae172 (diff)
Follow Eli's advice and store the VLA size with the native size_t type. Fixes PR3491.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63879 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 58559e5249..2b365c9cca 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -480,18 +480,19 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty)
llvm::Value *ElemSize;
QualType ElemTy = VAT->getElementType();
-
+
+ const llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
+
if (ElemTy->isVariableArrayType())
ElemSize = EmitVLASize(ElemTy);
else {
- // FIXME: We use Int32Ty here because the alloca instruction takes a
- // 32-bit integer. What should we do about overflow?
- ElemSize = llvm::ConstantInt::get(llvm::Type::Int32Ty,
+ ElemSize = llvm::ConstantInt::get(SizeTy,
getContext().getTypeSize(ElemTy) / 8);
}
llvm::Value *NumElements = EmitScalarExpr(VAT->getSizeExpr());
-
+ NumElements = Builder.CreateIntCast(NumElements, SizeTy, false, "tmp");
+
SizeEntry = Builder.CreateMul(ElemSize, NumElements);
}