aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DataLayout.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-10-26 10:19:06 +0200
committerGitHub <noreply@github.com>2023-10-26 10:19:06 +0200
commit4f131b0d2214b5fbaef43d130e576b40a20bda32 (patch)
tree65c902ff53971a00eda1d2c16bcc50bb70bab3ad /llvm/lib/IR/DataLayout.cpp
parent4506de1e2bfe9352331d75fe6d3c89f3d2f5287c (diff)
downloadllvm-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.cpp2
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) {