diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2008-05-31 21:20:41 +0000 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2008-05-31 21:20:41 +0000 |
| commit | 252e5f1b2975aceb35c739d4511df7003055f2bd (patch) | |
| tree | 602d4a09e3d934b6e936059fefbf3bd766495447 /clang/lib/CodeGen | |
| parent | 380df93fd642693c5c8ef78a2c0b266405152179 (diff) | |
| download | bcm5719-llvm-252e5f1b2975aceb35c739d4511df7003055f2bd.tar.gz bcm5719-llvm-252e5f1b2975aceb35c739d4511df7003055f2bd.zip | |
Calculate alignment for local variables.
llvm-svn: 51826
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 4541fc4caa3..8723a668721 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -129,8 +129,12 @@ void CodeGenFunction::EmitLocalBlockVarDecl(const VarDecl &D) { if (!Target.useGlobalsForAutomaticVariables()) { // A normal fixed sized variable becomes an alloca in the entry block. const llvm::Type *LTy = ConvertType(Ty); - // TODO: Alignment - DeclPtr = CreateTempAlloca(LTy, D.getName()); + llvm::AllocaInst * Alloc = CreateTempAlloca(LTy, D.getName()); + unsigned align = getContext().getTypeAlign(Ty); + if (const AlignedAttr* AA = D.getAttr<AlignedAttr>()) + align = std::max(align, AA->getAlignment()); + Alloc->setAlignment(align >> 3); + DeclPtr = Alloc; } else { // Targets that don't support recursion emit locals as globals. const char *Class = |

