diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -559,7 +559,10 @@ // with what clang and llvm-gcc do. unsigned Alignment = getTypeAllocSize(cast(Ty)->getElementType()); - Alignment *= cast(Ty)->getNumElements(); + // We're only calculating a natural alignment, so it doesn't have to be + // based on the full size for scalable vectors. Using the minimum element + // count should be enough here. + Alignment *= cast(Ty)->getElementCount().Min; Alignment = PowerOf2Ceil(Alignment); return Align(Alignment); }