summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-26 18:16:06 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-26 18:16:06 +0000
commite33eed5c1ee6356f41de76cad300615a2d8f4238 (patch)
treecd4e6552ee75ac9b1f520c442214980e33f048c8 /clang/lib
parent62995c71a218434e216cd7f0b8a2a54ceaf63c67 (diff)
downloadbcm5719-llvm-e33eed5c1ee6356f41de76cad300615a2d8f4238.tar.gz
bcm5719-llvm-e33eed5c1ee6356f41de76cad300615a2d8f4238.zip
Set alignment on static function level decls and VLAs. Fixes PR5060.
llvm-svn: 82868
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index d1f6b276243..73bc0a04a0c 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/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");
}
OpenPOWER on IntegriCloud