diff options
author | Nikita Popov <npopov@redhat.com> | 2023-10-26 10:19:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-26 10:19:06 +0200 |
commit | 4f131b0d2214b5fbaef43d130e576b40a20bda32 (patch) | |
tree | 65c902ff53971a00eda1d2c16bcc50bb70bab3ad /llvm/lib/IR/DataLayout.cpp | |
parent | 4506de1e2bfe9352331d75fe6d3c89f3d2f5287c (diff) | |
download | llvm-4f131b0d2214b5fbaef43d130e576b40a20bda32.zip llvm-4f131b0d2214b5fbaef43d130e576b40a20bda32.tar.gz llvm-4f131b0d2214b5fbaef43d130e576b40a20bda32.tar.bz2 |
[IR] Require index width to be ule pointer width (#70015)
I don't think there is a use case for having an index type that is wider
than the pointer type, and I'm not entirely clear what semantics this
would even have.
Also clarify the GEP semantics to explicitly say how they interact with
the index type width.
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r-- | llvm/lib/IR/DataLayout.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index d324c4b4..c8ef232 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -649,6 +649,8 @@ Error DataLayout::setPointerAlignmentInBits(uint32_t AddrSpace, Align ABIAlign, if (PrefAlign < ABIAlign) return reportError( "Preferred alignment cannot be less than the ABI alignment"); + if (IndexBitWidth > TypeBitWidth) + return reportError("Index width cannot be larger than pointer width"); auto I = lower_bound(Pointers, AddrSpace, [](const PointerAlignElem &A, uint32_t AddressSpace) { |