diff options
author | Owen Anderson <resistor@mac.com> | 2015-03-02 06:33:51 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2015-03-02 06:33:51 +0000 |
commit | 040f2f890e95d777e19cb11f090095c86c8d2034 (patch) | |
tree | 477652b18ebc254c660aa839c0aeae91714d3869 /llvm/lib/IR/DataLayout.cpp | |
parent | d333c36e8a765bc08ec0fb44bafcfa10870818c1 (diff) | |
download | llvm-040f2f890e95d777e19cb11f090095c86c8d2034.zip llvm-040f2f890e95d777e19cb11f090095c86c8d2034.tar.gz llvm-040f2f890e95d777e19cb11f090095c86c8d2034.tar.bz2 |
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
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r-- | llvm/lib/IR/DataLayout.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index c414e80..4eb6d78 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -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, |