llvm.org GIT mirror llvm / 2e0aa49
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368191 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 3 months ago
5 changed file(s) with 23 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
377377 }
378378 break;
379379 case 'S': { // Stack natural alignment.
380 StackNaturalAlign = MaybeAlign(inBytes(getInt(Tok)));
380 uint64_t Alignment = inBytes(getInt(Tok));
381 if (Alignment != 0 && !llvm::isPowerOf2_64(Alignment))
382 report_fatal_error("Alignment is neither 0 nor a power of 2");
383 StackNaturalAlign = MaybeAlign(Alignment);
381384 break;
382385 }
383386 case 'F': {
393396 "datalayout string");
394397 }
395398 Tok = Tok.substr(1);
396 FunctionPtrAlign = MaybeAlign(inBytes(getInt(Tok)));
399 uint64_t Alignment = inBytes(getInt(Tok));
400 if (Alignment != 0 && !llvm::isPowerOf2_64(Alignment))
401 report_fatal_error("Alignment is neither 0 nor a power of 2");
402 FunctionPtrAlign = MaybeAlign(Alignment);
397403 break;
398404 }
399405 case 'P': { // Function address space.
0 ; RUN: not llvm-as %s 2>&1 | FileCheck %s
1
2 ; CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2
3
4 target datalayout = "Fi24"
0 ; RUN: not llvm-as %s 2>&1 | FileCheck %s
1
2 ; CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2
3
4 target datalayout = "S24"
0 ; Bitcode with invalid function pointer alignment.
1
2 ; RUN: not llvm-dis %s.bc -o - 2>&1 | FileCheck %s
3
4 CHECK: LLVM ERROR: Alignment is neither 0 nor a power of 2