Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -2462,6 +2462,7 @@ def write_commands(commands, filename):
("--remove-unused-types",),
("--reorder-functions",),
("--reorder-locals",),
("--reorder-types",),
("--flatten", "--rereloop",),
("--roundtrip",),
("--rse",),
Expand Down Expand Up @@ -2496,6 +2497,7 @@ def write_commands(commands, filename):
("--abstract-type-refining",),
("--cfp",),
("--cfp-reftest",),
("--reorder-types",),
("--type-finalizing",),
("--type-unfinalizing",),
("--type-ssa",),
Expand Down
4 changes: 2 additions & 2 deletions src/ir/module-utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ InsertOrderedMap<HeapType, HeapTypeInfo> collectHeapTypeInfo(

// We've found all the types there are to find without considering more
// control flow types. Consider one more control flow type and repeat.
for (; controlFlowIt != info.controlFlowSignatures.end(); ++controlFlowIt) {
auto& [sig, count] = *controlFlowIt;
while (controlFlowIt != info.controlFlowSignatures.end()) {
auto& [sig, count] = *controlFlowIt++;
if (auto it = seenSigs.find(sig); it != seenSigs.end()) {
info.info[it->second].useCount += count;
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/ir/type-updating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ void GlobalTypeRewriter::update() {

GlobalTypeRewriter::PredecessorGraph
GlobalTypeRewriter::getPrivatePredecessors() {
// Check if a type is private, looking for its info (if there is none, it is
// not private).
// Check if a type is private based on its collected info.
auto isPublic = [&](HeapType type) {
auto it = typeInfo.find(type);
assert(it != typeInfo.end());
Expand Down
14 changes: 3 additions & 11 deletions src/passes/ReorderTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ namespace wasm {
namespace {

struct ReorderingTypeRewriter : GlobalTypeRewriter {
using InfoMap = InsertOrderedMap<HeapType, ModuleUtils::HeapTypeInfo>;

InfoMap& typeInfo;

// Use a simpler cost calculation so the effects can be seen with smaller test
// cases.
bool forTesting;
Expand All @@ -45,8 +41,8 @@ struct ReorderingTypeRewriter : GlobalTypeRewriter {
static constexpr float maxFactor = 1.0;
static constexpr Index numFactors = 21;

ReorderingTypeRewriter(Module& wasm, InfoMap& typeInfo, bool forTesting)
: GlobalTypeRewriter(wasm), typeInfo(typeInfo), forTesting(forTesting) {}
ReorderingTypeRewriter(Module& wasm, bool forTesting)
: GlobalTypeRewriter(wasm), forTesting(forTesting) {}

std::vector<HeapType> getSortedTypes(PredecessorGraph preds) override {
auto numTypes = preds.size();
Expand Down Expand Up @@ -150,11 +146,7 @@ struct ReorderTypes : Pass {
Fatal() << "ReorderTypes requires --closed-world";
}

// Collect the use counts for each type.
auto typeInfo = ModuleUtils::collectHeapTypeInfo(
*module, ModuleUtils::TypeInclusion::BinaryTypes);

ReorderingTypeRewriter(*module, typeInfo, forTesting).update();
ReorderingTypeRewriter(*module, forTesting).update();
}
};

Expand Down
Loading
Loading