Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringLowering #6271

Merged
merged 47 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d35493e
start
kripken Jan 29, 2024
77d5646
werk
kripken Jan 29, 2024
5ebd0a1
work
kripken Jan 29, 2024
3049a99
work
kripken Jan 30, 2024
56f940e
buid
kripken Jan 30, 2024
83dd068
test
kripken Jan 30, 2024
48089e0
work
kripken Jan 30, 2024
7859d8c
work
kripken Jan 30, 2024
955bbe6
progress
kripken Jan 30, 2024
01c7868
work?
kripken Jan 30, 2024
f00ca07
cleanup
kripken Jan 30, 2024
9dae0b3
father
kripken Jan 30, 2024
ba75182
work
kripken Jan 30, 2024
5adfed4
ment
kripken Jan 30, 2024
2c7779a
work
kripken Jan 30, 2024
9b70621
test
kripken Jan 30, 2024
d20f8d5
format
kripken Jan 30, 2024
c252831
rename
kripken Jan 30, 2024
3397899
rename
kripken Jan 30, 2024
883eba4
rename
kripken Jan 30, 2024
d93ca57
work
kripken Jan 30, 2024
07ce36a
work
kripken Jan 30, 2024
4670f8e
update
kripken Jan 30, 2024
b8fb866
work
kripken Jan 30, 2024
3bb6e3d
work
kripken Jan 31, 2024
3a5ad66
work
kripken Jan 31, 2024
e4d0b77
work
kripken Jan 31, 2024
90fbb25
work
kripken Jan 31, 2024
1a3dc63
work
kripken Jan 31, 2024
8fc15f1
work
kripken Jan 31, 2024
694ef94
test
kripken Jan 31, 2024
4ea57ee
test
kripken Jan 31, 2024
86517b0
format
kripken Jan 31, 2024
b2895ca
yolo
kripken Jan 31, 2024
ae3871e
Update src/passes/StringLowering.cpp
kripken Jan 31, 2024
a8cf56a
feedback: simplify to avoid reverse index map
kripken Jan 31, 2024
a2155ed
feedback: fix name
kripken Jan 31, 2024
2c88536
Merge branch 'string.gathering' into string.lowering
kripken Jan 31, 2024
aad2278
Update src/passes/StringLowering.cpp
kripken Jan 31, 2024
9f6bff7
comment
kripken Jan 31, 2024
0e601ea
Merge remote-tracking branch 'myself/string.gathering' into string.ga…
kripken Jan 31, 2024
7d1969f
Merge branch 'string.gathering' into string.lowering
kripken Jan 31, 2024
d5cc29e
fix
kripken Feb 1, 2024
e31cb73
Merge remote-tracking branch 'origin/main' into string.lowering
kripken Feb 1, 2024
0c9c942
Merge remote-tracking branch 'origin/main' into string.lowering
kripken Feb 2, 2024
65fc8d8
clean
kripken Feb 2, 2024
66746ee
update help test
kripken Feb 5, 2024
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
Prev Previous commit
Next Next commit
format
  • Loading branch information
kripken committed Jan 30, 2024
commit d20f8d52ccd0da9cee06d65ad5e77088af9f2a67
15 changes: 10 additions & 5 deletions src/passes/StringLowering.cpp
Original file line number Diff line number Diff line change
@@ -150,18 +150,23 @@ struct StringLowering : public Pass {
}

auto& string = strings[i];
auto name = Names::getValidGlobalName(*module, std::string("string.const_") + std::string(string.str));
auto name = Names::getValidGlobalName(
*module, std::string("string.const_") + std::string(string.str));
globalName = name;
newNames.insert(name);
auto* stringConst = builder.makeStringConst(string);
auto global = builder.makeGlobal(name, nnstringref, stringConst, Builder::Immutable);
auto global =
builder.makeGlobal(name, nnstringref, stringConst, Builder::Immutable);
module->addGlobal(std::move(global));
}

// Sort our new globals to the start, as others may use them.
std::stable_sort(module->globals.begin(), module->globals.end(), [&](const std::unique_ptr<Global>& a, const std::unique_ptr<Global>& b) {
return newNames.count(a->name) && !newNames.count(b->name);
});
std::stable_sort(
module->globals.begin(),
module->globals.end(),
[&](const std::unique_ptr<Global>& a, const std::unique_ptr<Global>& b) {
return newNames.count(a->name) && !newNames.count(b->name);
});
}

void replaceStrings(Module* module) {
5 changes: 3 additions & 2 deletions src/passes/pass.cpp
Original file line number Diff line number Diff line change
@@ -475,8 +475,9 @@ void PassRegistry::registerPasses() {
"ssa-nomerge",
"ssa-ify variables so that they have a single assignment, ignoring merges",
createSSAifyNoMergePass);
registerPass(
"string-lowering", "lower wasm strings to imports", createStringLoweringPass);
registerPass("string-lowering",
"lower wasm strings to imports",
createStringLoweringPass);
registerPass(
"strip", "deprecated; same as strip-debug", createStripDebugPass);
registerPass("stack-check",