diff options
author | Owen Anderson <resistor@mac.com> | 2015-03-02 09:35:03 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2015-03-02 09:35:03 +0000 |
commit | 8fae2845b1aa7c9e83796dfb656f9a74bf846205 (patch) | |
tree | fdc0c2d1e63f6525928d453187596a23065bc868 /lib/IR/DataLayout.cpp | |
parent | c7292fdabe8fb9d0f08f6e8d811f37c286c64dbb (diff) |
Teach DataLayout that alignments on basic types must be powers of two.
Fixes assertion failures/crashes on bad datalayout specifications.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/DataLayout.cpp')
-rw-r--r-- | lib/IR/DataLayout.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/IR/DataLayout.cpp b/lib/IR/DataLayout.cpp index b6eaf6f2d99..573e904f2ee 100644 --- a/lib/IR/DataLayout.cpp +++ b/lib/IR/DataLayout.cpp @@ -405,6 +405,10 @@ DataLayout::setAlignment(AlignTypeEnum align_type, unsigned abi_align, report_fatal_error("Invalid ABI alignment, must be a 16bit integer"); if (!isUInt<16>(pref_align)) report_fatal_error("Invalid preferred alignment, must be a 16bit integer"); + if (abi_align != 0 && !isPowerOf2_64(abi_align)) + report_fatal_error("Invalid ABI alignment, must be a power of 2"); + if (pref_align != 0 && !isPowerOf2_64(pref_align)) + report_fatal_error("Invalid preferred alignment, must be a power of 2"); if (pref_align < abi_align) report_fatal_error( |