Skip to content

Commit b7dc66f

Browse files
authored
[NFC] Remove unused additionalPrivateTypes (#8136)
GlobalTypeRewriter methods previously took an optional list of extra types to consider private and therefore eligible to be modified. Remove this parameter because it is not used.
1 parent d2469f2 commit b7dc66f

File tree

2 files changed

+17
-44
lines changed

2 files changed

+17
-44
lines changed

src/ir/type-updating.cpp

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ namespace wasm {
2828

2929
GlobalTypeRewriter::GlobalTypeRewriter(Module& wasm) : wasm(wasm) {}
3030

31-
void GlobalTypeRewriter::update(
32-
const std::vector<HeapType>& additionalPrivateTypes) {
33-
mapTypes(rebuildTypes(
34-
getSortedTypes(getPrivatePredecessors(additionalPrivateTypes))));
31+
void GlobalTypeRewriter::update() {
32+
mapTypes(rebuildTypes(getSortedTypes(getPrivatePredecessors())));
3533
}
3634

37-
GlobalTypeRewriter::PredecessorGraph GlobalTypeRewriter::getPrivatePredecessors(
38-
const std::vector<HeapType>& additionalPrivateTypes) {
35+
GlobalTypeRewriter::PredecessorGraph
36+
GlobalTypeRewriter::getPrivatePredecessors() {
3937
// Find the heap types that are not publicly observable. Even in a closed
4038
// world scenario, don't modify public types because we assume that they may
4139
// be reflected on or used for linking. Figure out where each private type
@@ -45,31 +43,19 @@ GlobalTypeRewriter::PredecessorGraph GlobalTypeRewriter::getPrivatePredecessors(
4543
ModuleUtils::TypeInclusion::UsedIRTypes,
4644
ModuleUtils::VisibilityHandling::FindVisibility);
4745

48-
std::unordered_set<HeapType> additionalSet(additionalPrivateTypes.begin(),
49-
additionalPrivateTypes.end());
50-
51-
// Check if a type is private, given the info for it.
52-
auto isPublicGivenInfo = [&](HeapType type, auto& info) {
53-
return info.visibility != ModuleUtils::Visibility::Private &&
54-
!additionalSet.count(type);
55-
};
56-
57-
// Check if a type is private, looking for its info (if there is none, it is
58-
// not private).
46+
// Check if a type is private, by looking up its info.
5947
auto isPublic = [&](HeapType type) {
6048
auto it = typeInfo.find(type);
61-
if (it == typeInfo.end()) {
62-
return false;
63-
}
64-
return isPublicGivenInfo(type, it->second);
49+
assert(it != typeInfo.end());
50+
return it->second.visibility == ModuleUtils::Visibility::Public;
6551
};
6652

6753
// For each type, note all the predecessors it must have, i.e., that must
6854
// appear before it. That includes supertypes and described types.
6955
std::vector<std::pair<HeapType, SmallVector<HeapType, 1>>> preds;
7056
preds.reserve(typeInfo.size());
7157
for (auto& [type, info] : typeInfo) {
72-
if (isPublicGivenInfo(type, info)) {
58+
if (info.visibility == ModuleUtils::Visibility::Public) {
7359
continue;
7460
}
7561
preds.push_back({type, {}});

src/ir/type-updating.h

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,8 @@ class GlobalTypeRewriter {
356356
// the module.
357357
//
358358
// This only operates on private types (so as not to modify the module's
359-
// external ABI). It takes as a parameter a list of public types to consider
360-
// private, which allows more flexibility (e.g. in closed world if a pass
361-
// knows a type is safe to modify despite being public, it can add it).
362-
void update(const std::vector<HeapType>& additionalPrivateTypes = {});
359+
// external ABI).
360+
void update();
363361

364362
using TypeMap = std::unordered_map<HeapType, HeapType>;
365363

@@ -419,10 +417,7 @@ class GlobalTypeRewriter {
419417

420418
// Helper for the repeating pattern of just updating Signature types using a
421419
// map of old heap type => new Signature.
422-
static void
423-
updateSignatures(const SignatureUpdates& updates,
424-
Module& wasm,
425-
const std::vector<HeapType>& additionalPrivateTypes = {}) {
420+
static void updateSignatures(const SignatureUpdates& updates, Module& wasm) {
426421
if (updates.empty()) {
427422
return;
428423
}
@@ -431,11 +426,9 @@ class GlobalTypeRewriter {
431426
const SignatureUpdates& updates;
432427

433428
public:
434-
SignatureRewriter(Module& wasm,
435-
const SignatureUpdates& updates,
436-
const std::vector<HeapType>& additionalPrivateTypes)
429+
SignatureRewriter(Module& wasm, const SignatureUpdates& updates)
437430
: GlobalTypeRewriter(wasm), updates(updates) {
438-
update(additionalPrivateTypes);
431+
update();
439432
}
440433

441434
void modifySignature(HeapType oldSignatureType, Signature& sig) override {
@@ -445,19 +438,16 @@ class GlobalTypeRewriter {
445438
sig.results = getTempType(iter->second.results);
446439
}
447440
}
448-
} rewriter(wasm, updates, additionalPrivateTypes);
441+
} rewriter(wasm, updates);
449442
}
450443

451444
protected:
452445
// Return the graph matching each private type to its private predecessors.
453-
PredecessorGraph getPrivatePredecessors(
454-
const std::vector<HeapType>& additionalPrivateTypes = {});
446+
PredecessorGraph getPrivatePredecessors();
455447

456448
// Builds new types after updating their contents using the hooks below and
457449
// returns a map from the old types to the modified types. Used internally in
458450
// update().
459-
//
460-
// See above regarding private types.
461451
TypeMap rebuildTypes(std::vector<HeapType> types);
462452

463453
private:
@@ -478,13 +468,10 @@ class TypeMapper : public GlobalTypeRewriter {
478468
TypeMapper(Module& wasm, const TypeUpdates& mapping)
479469
: GlobalTypeRewriter(wasm), mapping(mapping) {}
480470

481-
// As rebuildTypes, this can take an optional set of additional types to
482-
// consider private (and therefore to modify).
483-
void map(const std::vector<HeapType>& additionalPrivateTypes = {}) {
471+
void map() {
484472
// Update the internals of types (struct fields, signatures, etc.) to
485473
// refer to the merged types.
486-
auto newMapping = rebuildTypes(
487-
getSortedTypes(getPrivatePredecessors(additionalPrivateTypes)));
474+
auto newMapping = rebuildTypes(getSortedTypes(getPrivatePredecessors()));
488475

489476
// Compose the user-provided mapping from old types to other old types with
490477
// the new mapping from old types to new types. `newMapping` will become

0 commit comments

Comments
 (0)