Fix a bug in OptimizedStructLayout when filling gaps before
authorJohn McCall <rjmccall@apple.com>
Wed, 21 Jul 2021 19:39:42 +0000 (15:39 -0400)
committerJohn McCall <rjmccall@apple.com>
Wed, 21 Jul 2021 19:47:18 +0000 (15:47 -0400)
commit326a5a2658d81db46a78b184fe42e522ef170f32
tree219ddf79c93c83b67f09bf6732d37709b38221f9
parent9643d11e1d7f918c0e5184c9488935720d591c90
Fix a bug in OptimizedStructLayout when filling gaps before
fixed fields with highly-aligned flexible fields.

The code was not considering the possibility that aligning
the current offset to the alignment of a queue might push
us past the end of the gap.  Subtracting the offsets to
figure out the maximum field size for the gap then overflowed,
making us think that we had nearly unbounded space to fill.

Fixes PR 51131.
llvm/lib/Support/OptimizedStructLayout.cpp
llvm/unittests/Support/OptimizedStructLayoutTest.cpp