diff options
author | Anders Carlsson <andersca@mac.com> | 2009-09-26 18:16:06 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2009-09-26 18:16:06 +0000 |
commit | 41f8a13ac7fa734faef2d8a36feebc3c9a1eed77 (patch) | |
tree | 2b99b543b81f0e61d911aeb0b373d7802e774361 /lib/CodeGen/CGDecl.cpp | |
parent | 022a1253c021aaa03fa7d65b04f237da9613f8fd (diff) |
Set alignment on static function level decls and VLAs. Fixes PR5060.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82868 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index d1f6b27624..73bc0a04a0 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -103,10 +103,13 @@ CodeGenFunction::CreateStaticBlockVarDecl(const VarDecl &D, } const llvm::Type *LTy = CGM.getTypes().ConvertTypeForMem(Ty); - return new llvm::GlobalVariable(CGM.getModule(), LTy, - Ty.isConstant(getContext()), Linkage, - CGM.EmitNullConstant(D.getType()), Name, 0, - D.isThreadSpecified(), Ty.getAddressSpace()); + llvm::GlobalVariable *GV = + new llvm::GlobalVariable(CGM.getModule(), LTy, + Ty.isConstant(getContext()), Linkage, + CGM.EmitNullConstant(D.getType()), Name, 0, + D.isThreadSpecified(), Ty.getAddressSpace()); + GV->setAlignment(getContext().getDeclAlignInBytes(&D)); + return GV; } void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D) { @@ -375,8 +378,10 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { false, "tmp"); // Allocate memory for the array. - llvm::Value *VLA = Builder.CreateAlloca(llvm::Type::getInt8Ty(VMContext), - VLASize, "vla"); + llvm::AllocaInst *VLA = + Builder.CreateAlloca(llvm::Type::getInt8Ty(VMContext), VLASize, "vla"); + VLA->setAlignment(getContext().getDeclAlignInBytes(&D)); + DeclPtr = Builder.CreateBitCast(VLA, LElemPtrTy, "tmp"); } |