diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-06-04 23:15:27 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-06-04 23:15:27 +0000 |
| commit | e971b9a26002cfe32b899bf4a746a4c2136ce0d0 (patch) | |
| tree | a7ac4b7a4e68968a4452e1e908b1e61bd4f6efe9 /clang/lib/AST/ASTContext.cpp | |
| parent | a1e08fb2561ec734cdf5b8dc37ce64e14944bf23 (diff) | |
| download | bcm5719-llvm-e971b9a26002cfe32b899bf4a746a4c2136ce0d0.tar.gz bcm5719-llvm-e971b9a26002cfe32b899bf4a746a4c2136ce0d0.zip | |
Correctly align large arrays in x86-64. This fixes PR5599.
llvm-svn: 105500
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 43bf21313f6..6e7bb0773cf 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -414,6 +414,15 @@ CharUnits ASTContext::getDeclAlign(const Decl *D, bool RefAsPointee) { T = getPointerType(RT->getPointeeType()); } if (!T->isIncompleteType() && !T->isFunctionType()) { + unsigned MinWidth = Target.getLargeArrayMinWidth(); + unsigned ArrayAlign = Target.getLargeArrayAlign(); + if (isa<VariableArrayType>(T) && MinWidth != 0) + Align = std::max(Align, ArrayAlign); + if (ConstantArrayType *CT = dyn_cast<ConstantArrayType>(T)) { + unsigned Size = getTypeSize(CT); + if (MinWidth != 0 && MinWidth <= Size) + Align = std::max(Align, ArrayAlign); + } // Incomplete or function types default to 1. while (isa<VariableArrayType>(T) || isa<IncompleteArrayType>(T)) T = cast<ArrayType>(T)->getElementType(); |

