| ... | @@ -34349,9 +34349,28 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { | ... | @@ -34349,9 +34349,28 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { |
| 34349 | return a_align.compare(.gt, b_align); | 34349 | return a_align.compare(.gt, b_align); |
| 34350 | } | 34350 | } |
| 34351 | }; | 34351 | }; |
| 34352 | mem.sortUnstable(RuntimeOrder, runtime_order, AlignSortContext{ | 34352 | if (struct_type.isTuple(ip) or !mod.backendSupportsFeature(.field_reordering)) { |
| 34353 | .aligns = aligns, | 34353 | // TODO: don't handle tuples differently. This logic exists only because it |
| 34354 | }, AlignSortContext.lessThan); | 34354 | // uncovers latent bugs if removed. Fix the latent bugs and remove this logic! |
| | 34355 | // Likewise, implement field reordering support in all the backends! |
| | 34356 | // This logic does not reorder fields; it only moves the omitted ones to the end |
| | 34357 | // so that logic elsewhere does not need to special-case tuples. |
| | 34358 | var i: usize = 0; |
| | 34359 | var off: usize = 0; |
| | 34360 | while (i + off < runtime_order.len) { |
| | 34361 | if (runtime_order[i + off] == .omitted) { |
| | 34362 | off += 1; |
| | 34363 | continue; |
| | 34364 | } |
| | 34365 | runtime_order[i] = runtime_order[i + off]; |
| | 34366 | i += 1; |
| | 34367 | } |
| | 34368 | @memset(runtime_order[i..], .omitted); |
| | 34369 | } else { |
| | 34370 | mem.sortUnstable(RuntimeOrder, runtime_order, AlignSortContext{ |
| | 34371 | .aligns = aligns, |
| | 34372 | }, AlignSortContext.lessThan); |
| | 34373 | } |
| 34355 | } | 34374 | } |
| 34356 | | 34375 | |
| 34357 | // Calculate size, alignment, and field offsets. | 34376 | // Calculate size, alignment, and field offsets. |