mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
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
This commit is contained in:
parent
c7292fdabe
commit
8fae2845b1
@ -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(
|
||||
|
6
test/Assembler/invalid-datalayout23.ll
Normal file
6
test/Assembler/invalid-datalayout23.ll
Normal 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
|
||||
|
6
test/Assembler/invalid-datalayout24.ll
Normal file
6
test/Assembler/invalid-datalayout24.ll
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user