mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
Teach DataLayout that pointer ABI and preferred alignments are required to be powers of two.
Previously this resulted in asserts and/or crashes (depending on build configuration) at various phases in the optimizer. llvm-svn: 230938
This commit is contained in:
parent
22efff3c98
commit
9691e92c81
@ -268,12 +268,18 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
"Missing alignment specification for pointer in datalayout string");
|
||||
Split = split(Rest, ':');
|
||||
unsigned PointerABIAlign = inBytes(getInt(Tok));
|
||||
if (!isPowerOf2_64(PointerABIAlign))
|
||||
report_fatal_error(
|
||||
"Pointer ABI alignment must be a power of 2");
|
||||
|
||||
// Preferred alignment.
|
||||
unsigned PointerPrefAlign = PointerABIAlign;
|
||||
if (!Rest.empty()) {
|
||||
Split = split(Rest, ':');
|
||||
PointerPrefAlign = inBytes(getInt(Tok));
|
||||
if (!isPowerOf2_64(PointerPrefAlign))
|
||||
report_fatal_error(
|
||||
"Pointer preferred alignment must be a power of 2");
|
||||
}
|
||||
|
||||
setPointerAlignment(AddrSpace, PointerABIAlign, PointerPrefAlign,
|
||||
|
6
test/Assembler/invalid-datalayout20.ll
Normal file
6
test/Assembler/invalid-datalayout20.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
|
||||
target datalayout = "p:64:24:64"
|
||||
|
||||
; CHECK: Pointer ABI alignment must be a power of 2
|
||||
|
6
test/Assembler/invalid-datalayout21.ll
Normal file
6
test/Assembler/invalid-datalayout21.ll
Normal file
@ -0,0 +1,6 @@
|
||||
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
|
||||
|
||||
target datalayout = "p:64:64:24"
|
||||
|
||||
; CHECK: Pointer preferred alignment must be a power of 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user