1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

Teach DataLayout that alignments on basic types must be powers of two.

Fixes assertion failures/crashes on bad datalayout specifications.

llvm-svn: 230940
This commit is contained in:
Owen Anderson 2015-03-02 09:35:03 +00:00
parent f1ccd9db94
commit e464d46ff1
3 changed files with 16 additions and 0 deletions

View File

@ -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(

View File

@ -0,0 +1,6 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
target datalayout = "i32:24:32"
; CHECK: Invalid ABI alignment, must be a power of 2

View File

@ -0,0 +1,6 @@
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
target datalayout = "i32:32:24"
; CHECK: Invalid preferred alignment, must be a power of 2