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 | 5af4b21c2e5ecc84a509cf54bd65a5b7ceccbe8e (patch) | |
tree | 5f9abe98431ea9e7866b25dcc9ebfb031ff2687b /llvm/lib/IR/DataLayout.cpp | |
parent | ab1c7a77d27d5482f2159bc26297d875db13b936 (diff) | |
download | bcm5719-llvm-5af4b21c2e5ecc84a509cf54bd65a5b7ceccbe8e.tar.gz bcm5719-llvm-5af4b21c2e5ecc84a509cf54bd65a5b7ceccbe8e.zip |
Teach DataLayout that alignments on basic types must be powers of two.
Fixes assertion failures/crashes on bad datalayout specifications.
llvm-svn: 230940
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r-- | llvm/lib/IR/DataLayout.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index b6eaf6f2d99..573e904f2ee 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/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( |