File tree Expand file tree Collapse file tree 2 files changed +48
-4
lines changed Expand file tree Collapse file tree 2 files changed +48
-4
lines changed Original file line number Diff line number Diff line change @@ -444,11 +444,13 @@ struct GlobalTypeOptimization : public Pass {
444444
445445 // Clear the old names and write the new ones.
446446 nameInfo.fieldNames .clear ();
447- for (Index i = 0 ; i < oldFieldNames .size (); i++) {
447+ for (Index i = 0 ; i < indexesAfterRemoval .size (); i++) {
448448 auto newIndex = indexesAfterRemoval[i];
449- if (newIndex != RemovedField && oldFieldNames.count (i)) {
450- assert (oldFieldNames[i].is ());
451- nameInfo.fieldNames [newIndex] = oldFieldNames[i];
449+ if (newIndex != RemovedField) {
450+ auto iter = oldFieldNames.find (i);
451+ if (iter != oldFieldNames.end ()) {
452+ nameInfo.fieldNames [newIndex] = iter->second ;
453+ }
452454 }
453455 }
454456 }
Original file line number Diff line number Diff line change 16751675 )
16761676 )
16771677)
1678+
1679+ (module
1680+ ;; A struct with partial names: only some fields are named. We should still
1681+ ;; update names properly when removing and reordering.
1682+
1683+ ;; CHECK: (rec
1684+ ;; CHECK-NEXT: (type $struct (sub (struct (field (mut i32)) (field $named (mut i32)))))
1685+ (type $struct (sub (struct (field (mut i32 )) (field (mut i32 )) (field $named (mut i32 )) (field (mut i32 )) (field (mut i32 )))))
1686+
1687+ ;; CHECK: (type $1 (func (param (ref $struct))))
1688+
1689+ ;; CHECK: (func $func (type $1) (param $x (ref $struct))
1690+ ;; CHECK-NEXT: (struct.set $struct 0
1691+ ;; CHECK-NEXT: (local.get $x)
1692+ ;; CHECK-NEXT: (struct.get $struct 0
1693+ ;; CHECK-NEXT: (local.get $x)
1694+ ;; CHECK-NEXT: )
1695+ ;; CHECK-NEXT: )
1696+ ;; CHECK-NEXT: (struct.set $struct $named
1697+ ;; CHECK-NEXT: (local.get $x)
1698+ ;; CHECK-NEXT: (struct.get $struct $named
1699+ ;; CHECK-NEXT: (local.get $x)
1700+ ;; CHECK-NEXT: )
1701+ ;; CHECK-NEXT: )
1702+ ;; CHECK-NEXT: )
1703+ (func $func (param $x (ref $struct ))
1704+ ;; Use fields 1 and 2.
1705+ (struct.set $struct 1
1706+ (local.get $x )
1707+ (struct.get $struct 1
1708+ (local.get $x )
1709+ )
1710+ )
1711+ (struct.set $struct 2
1712+ (local.get $x )
1713+ (struct.get $struct 2
1714+ (local.get $x )
1715+ )
1716+ )
1717+ )
1718+ )
1719+
You can’t perform that action at this time.
0 commit comments