Skip to content

Commit e7987f6

Browse files
authored
[wasm-split] Use Name() for nonexistent global base (NFC) (#8704)
Rather than using an empty string, this uses `Name()` when an active table does not have a base global. This allows us to check for the existence of the global by just ```cpp if (tableManager.activeBase.global) ``` rather than ```cpp if (tableManager.activeBase.global.size()) ```
1 parent 2458c41 commit e7987f6

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/ir/module-splitting.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace {
8787

8888
template<class F> void forEachElement(Module& module, F f) {
8989
ModuleUtils::iterActiveElementSegments(module, [&](ElementSegment* segment) {
90-
Name base = "";
90+
Name base;
9191
Index offset = 0;
9292
if (auto* c = segment->offset->dynCast<Const>()) {
9393
offset = c->value.getInteger();
@@ -134,7 +134,7 @@ Expression* TableSlotManager::Slot::makeExpr(Module& module) {
134134
auto makeIndex = [&]() {
135135
return builder.makeConst(Literal::makeFromInt32(index, table->addressType));
136136
};
137-
if (global.size()) {
137+
if (global) {
138138
Expression* getBase = builder.makeGlobalGet(global, table->addressType);
139139
auto addOp = table->is64() ? AddInt64 : AddInt32;
140140
return index == 0 ? getBase
@@ -191,7 +191,7 @@ TableSlotManager::TableSlotManager(Module& module) : module(module) {
191191
if (activeTableSegments.empty()) {
192192
// There are no active segments, so we will lazily create one and start
193193
// filling it at index 0.
194-
activeBase = {activeTable->name, "", 0};
194+
activeBase = {activeTable->name, Name(), 0};
195195
} else if (activeTableSegments.size() == 1 &&
196196
activeTableSegments[0]->type == funcref &&
197197
!activeTableSegments[0]->offset->is<Const>()) {
@@ -218,7 +218,7 @@ TableSlotManager::TableSlotManager(Module& module) : module(module) {
218218
if (segmentBase + segment->data.size() >= maxIndex) {
219219
maxIndex = segmentBase + segment->data.size();
220220
activeSegment = segment;
221-
activeBase = {activeTable->name, "", segmentBase};
221+
activeBase = {activeTable->name, Name(), segmentBase};
222222
}
223223
}
224224
}
@@ -257,7 +257,7 @@ TableSlotManager::Slot TableSlotManager::getSlot(Name func, HeapType type) {
257257
if (activeSegment == nullptr) {
258258
if (activeTable == nullptr) {
259259
activeTable = makeTable();
260-
activeBase = {activeTable->name, "", 0};
260+
activeBase = {activeTable->name, Name(), 0};
261261
}
262262

263263
// None of the existing segments should refer to the active table
@@ -737,7 +737,7 @@ void ModuleSplitter::shareImportableItems() {
737737
if (tableManager.activeTable) {
738738
primaryUsed.tables.insert(tableManager.activeTable->name);
739739
}
740-
if (tableManager.activeBase.global.size()) {
740+
if (tableManager.activeBase.global) {
741741
primaryUsed.globals.insert(tableManager.activeBase.global);
742742
}
743743

@@ -1116,7 +1116,7 @@ void ModuleSplitter::setupTablePatching() {
11161116
ExternalKind::Table);
11171117
}
11181118

1119-
if (tableManager.activeBase.global.size()) {
1119+
if (tableManager.activeBase.global) {
11201120
// Import and export the active table's base global if necessary. Unless
11211121
// the base global was already being used elsewhere in secondaries,
11221122
// shareImportableItems wasn't able to mark it as used in secondaries, so

0 commit comments

Comments
 (0)