Skip to content

Commit 392e83c

Browse files
committed
use copy in TypeSSA
1 parent 531c479 commit 392e83c

2 files changed

Lines changed: 4 additions & 14 deletions

File tree

src/passes/TypeSSA.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,20 +98,7 @@ std::vector<HeapType> ensureTypesAreInNewRecGroup(RecGroup recGroup,
9898
// Make a builder and add a slot for the hash.
9999
TypeBuilder builder(num + 1);
100100
for (Index i = 0; i < num; i++) {
101-
auto type = types[i];
102-
if (type.isStruct()) {
103-
builder[i] = type.getStruct();
104-
} else {
105-
// Atm this pass only needs struct and array types. If we refactor
106-
// this function to be general purpose we'd need to extend that. TODO
107-
assert(type.isArray());
108-
builder[i] = type.getArray();
109-
}
110-
if (auto super = type.getDeclaredSuperType()) {
111-
builder[i].subTypeOf(*super);
112-
}
113-
builder[i].setOpen(type.isOpen());
114-
builder[i].setShared(type.getShared());
101+
builder[i].copy(types[i]);
115102
}
116103

117104
// Implement the hash as a struct with "random" fields, and add it.

src/wasm-type.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,9 @@ struct TypeBuilder {
822822
builder.copyHeapType(index, type, map);
823823
return *this;
824824
}
825+
Entry& copy(HeapType type) {
826+
return copy(type, [](HeapType t) { return t; });
827+
}
825828
};
826829

827830
Entry operator[](size_t i) { return Entry{*this, i}; }

0 commit comments

Comments
 (0)