diff options
author | Nikita Popov <npopov@redhat.com> | 2025-09-03 13:09:37 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2025-09-03 14:04:54 +0200 |
commit | 38b376f1927df5c1dea1065041779b28b13b9dd9 (patch) | |
tree | d0aedce715c20b0f5713b52b4a9b6e9318cf7feb /llvm/lib/IR/DataLayout.cpp | |
parent | 27e541645c2a99cba6ae8705f2969f523410ef4c (diff) | |
download | llvm-38b376f1927df5c1dea1065041779b28b13b9dd9.zip llvm-38b376f1927df5c1dea1065041779b28b13b9dd9.tar.gz llvm-38b376f1927df5c1dea1065041779b28b13b9dd9.tar.bz2 |
[DataLayout] Use linear scan to determine integer alignment (NFC)
The number of alignment entries is usually very small (5-7), so
it is more efficient to use a linear scan than a binary search.
Diffstat (limited to 'llvm/lib/IR/DataLayout.cpp')
-rw-r--r-- | llvm/lib/IR/DataLayout.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp index 50c45f5..ee43ad4 100644 --- a/llvm/lib/IR/DataLayout.cpp +++ b/llvm/lib/IR/DataLayout.cpp @@ -694,7 +694,12 @@ void DataLayout::setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth, Align DataLayout::getIntegerAlignment(uint32_t BitWidth, bool abi_or_pref) const { - auto I = lower_bound(IntSpecs, BitWidth, LessPrimitiveBitWidth()); + auto I = IntSpecs.begin(); + for (; I != IntSpecs.end(); ++I) { + if (I->BitWidth >= BitWidth) + break; + } + // If we don't have an exact match, use alignment of next larger integer // type. If there is none, use alignment of largest integer type by going // back one element. |