mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[DataLayout] Check StackNatural and FunctionPtr alignments.
MaybeAlignment asserts that the passed in value is == 0 or a power of 2. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16272 Reviewers: michaelplatings, gchatelet, jakehehrlich, jfb Reviewed By: gchatelet Tags: #llvm Differential Revision: https://reviews.llvm.org/D65858 llvm-svn: 368191
This commit is contained in:
parent
e27c0e3409
commit
6fbbb7b6b8
@ -378,7 +378,10 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
}
|
||||
break;
|
||||
case 'S': { // Stack natural alignment.
|
||||
StackNaturalAlign = MaybeAlign(inBytes(getInt(Tok)));
|
||||
uint64_t Alignment = inBytes(getInt(Tok));
|
||||
if (Alignment != 0 && !llvm::isPowerOf2_64(Alignment))
|
||||
report_fatal_error("Alignment is neither 0 nor a power of 2");
|
||||
StackNaturalAlign = MaybeAlign(Alignment);
|
||||
break;
|
||||
}
|
||||
case 'F': {
|
||||
@ -394,7 +397,10 @@ void DataLayout::parseSpecifier(StringRef Desc) {
|
||||
"datalayout string");
|
||||
}
|
||||
Tok = Tok.substr(1);
|
||||
FunctionPtrAlign = MaybeAlign(inBytes(getInt(Tok)));
|
||||
uint64_t Alignment = inBytes(getInt(Tok));
|
||||
if (Alignment != 0 && !llvm::isPowerOf2_64(Alignment))
|
||||
report_fatal_error("Alignment is neither 0 nor a power of 2");
|
||||
FunctionPtrAlign = MaybeAlign(Alignment);
|
||||
break;
|
||||
}
|
||||
case 'P': { // Function address space.
|
||||
|
@ -0,0 +1,5 @@
|
||||
; RUN: not llvm-as %s 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2
|
||||
|
||||
target datalayout = "Fi24"
|
@ -0,0 +1,5 @@
|
||||
; RUN: not llvm-as %s 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2
|
||||
|
||||
target datalayout = "S24"
|
5
test/Bitcode/invalid-functionptr-align.ll
Normal file
5
test/Bitcode/invalid-functionptr-align.ll
Normal file
@ -0,0 +1,5 @@
|
||||
; Bitcode with invalid function pointer alignment.
|
||||
|
||||
; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
|
||||
|
||||
CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2
|
BIN
test/Bitcode/invalid-functionptr-align.ll.bc
Normal file
BIN
test/Bitcode/invalid-functionptr-align.ll.bc
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user