Skip to content

Commit 38b376f

Browse files
committed
[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.
1 parent 27e5416 commit 38b376f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

llvm/lib/IR/DataLayout.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,12 @@ void DataLayout::setPointerSpec(uint32_t AddrSpace, uint32_t BitWidth,
694694

695695
Align DataLayout::getIntegerAlignment(uint32_t BitWidth,
696696
bool abi_or_pref) const {
697-
auto I = lower_bound(IntSpecs, BitWidth, LessPrimitiveBitWidth());
697+
auto I = IntSpecs.begin();
698+
for (; I != IntSpecs.end(); ++I) {
699+
if (I->BitWidth >= BitWidth)
700+
break;
701+
}
702+
698703
// If we don't have an exact match, use alignment of next larger integer
699704
// type. If there is none, use alignment of largest integer type by going
700705
// back one element.

0 commit comments

Comments
 (0)