[PATCH] D65858: [DataLayout] Check StackNatural and FunctionPtr alignments.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 7 10:20:39 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368191: [DataLayout] Check StackNatural and FunctionPtr alignments. (authored by fhahn, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D65858?vs=213847&id=213941#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65858/new/
https://reviews.llvm.org/D65858
Files:
llvm/trunk/lib/IR/DataLayout.cpp
llvm/trunk/test/Assembler/datalayout-invalid-function-ptr-alignment.ll
llvm/trunk/test/Assembler/datalayout-invalid-stack-natural-alignment.ll
llvm/trunk/test/Bitcode/invalid-functionptr-align.ll
llvm/trunk/test/Bitcode/invalid-functionptr-align.ll.bc
Index: llvm/trunk/test/Assembler/datalayout-invalid-stack-natural-alignment.ll
===================================================================
--- llvm/trunk/test/Assembler/datalayout-invalid-stack-natural-alignment.ll
+++ llvm/trunk/test/Assembler/datalayout-invalid-stack-natural-alignment.ll
@@ -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"
Index: llvm/trunk/test/Assembler/datalayout-invalid-function-ptr-alignment.ll
===================================================================
--- llvm/trunk/test/Assembler/datalayout-invalid-function-ptr-alignment.ll
+++ llvm/trunk/test/Assembler/datalayout-invalid-function-ptr-alignment.ll
@@ -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"
Index: llvm/trunk/test/Bitcode/invalid-functionptr-align.ll
===================================================================
--- llvm/trunk/test/Bitcode/invalid-functionptr-align.ll
+++ llvm/trunk/test/Bitcode/invalid-functionptr-align.ll
@@ -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
Index: llvm/trunk/lib/IR/DataLayout.cpp
===================================================================
--- llvm/trunk/lib/IR/DataLayout.cpp
+++ llvm/trunk/lib/IR/DataLayout.cpp
@@ -378,7 +378,10 @@
}
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 @@
"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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65858.213941.patch
Type: text/x-patch
Size: 2396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190807/3eaba13b/attachment.bin>
More information about the llvm-commits
mailing list