From e5c1673b3fdc6b082e88af49f57305d957fb5f08 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 30 Jun 2026 17:22:46 -0700 Subject: [PATCH 1/5] Fix escaping of names in IR The binary reader (but not the text parser) would previous escape names read from the names section and use those escaped names in the IR. But there is no reason to escape names in the IR; we can use the unmodified byte sequences instead. Remove this unnecessary escaping and always store names unescaped in the IR. The binary writer was further escaping names when writing them back to the names section. Remove this escaping so that we simply preserve whatever names were present in the input, modulo any deduplication we might have done. Asyncify and wasm-split read function names as input from the command line and from manifest files and would previously escape these names on reading so they would match up with the escaped names in the IR. Now that the IR does not store escaped names, fix Asyncify and wasm-split to no longer escape these names. As a follow-on change we might consider _unescaping_ these names instead, which would allow users to more easily pass names containing unprintable characters. As a drive-by, fix the printing in MinimizeImportsAndExports to properly use JSON escaping. --- src/passes/Asyncify.cpp | 19 ++-- src/passes/MinifyImportsAndExports.cpp | 10 +- src/tools/wasm-split/wasm-split.cpp | 2 +- src/wasm-binary.h | 2 - src/wasm/wasm-binary.cpp | 105 +++--------------- test/complexBinaryNames.wasm.fromBinary | 4 +- test/finalize/shared_add_to_table.wasm.out | 6 +- test/lit/basic/complexTextNames.wast | 7 +- .../wasm-split/multi-split-escape-names.wast | 78 ++++++------- test/passes/dwarf_with_exceptions.bin.txt | 28 ++--- test/passes/fannkuch0_dwarf.bin.txt | 8 +- test/passes/fannkuch3_dwarf.bin.txt | 4 +- test/passes/fannkuch3_manyopts_dwarf.bin.txt | 4 +- test/passes/ignore_missing_func_dwarf.bin.txt | 8 +- test/passes/inlined_to_start_dwarf.bin.txt | 4 +- test/unit/input/asyncify-pure.wat | 2 +- 16 files changed, 106 insertions(+), 185 deletions(-) diff --git a/src/passes/Asyncify.cpp b/src/passes/Asyncify.cpp index feea9adf7c2..c839f26c61d 100644 --- a/src/passes/Asyncify.cpp +++ b/src/passes/Asyncify.cpp @@ -475,32 +475,29 @@ class PatternMatcher { std::set names; std::set patterns; std::set patternsMatched; - std::map unescaped; PatternMatcher(std::string designation, Module& module, const String::Split& list) : designation(designation) { // The lists contain human-readable strings. Turn them into the - // internal escaped names for later comparisons + // internal names for later comparisons. for (auto& name : list) { - auto escaped = WasmBinaryReader::escape(name); - unescaped[escaped.toString()] = name; if (name.find('*') != std::string::npos) { - patterns.insert(escaped.toString()); + patterns.insert(name); } else { - auto* func = module.getFunctionOrNull(escaped); + auto* func = module.getFunctionOrNull(name); if (!func) { std::cerr << "warning: Asyncify " << designation - << "list contained a non-existing function name: " << name - << " (" << escaped << ")\n"; + << "list contained a non-existing function name: '" << name + << "'\n"; } else if (func->imported()) { Fatal() << "Asyncify " << designation << "list contained an imported function name (use the import " "list for imports): " << name << '\n'; } - names.insert(escaped.str); + names.insert(name); } } } @@ -523,8 +520,8 @@ class PatternMatcher { for (auto& pattern : patterns) { if (!patternsMatched.contains(pattern)) { std::cerr << "warning: Asyncify " << designation - << "list contained a non-matching pattern: " - << unescaped[pattern] << " (" << pattern << ")\n"; + << "list contained a non-matching pattern: '" << pattern + << "'\n"; } } } diff --git a/src/passes/MinifyImportsAndExports.cpp b/src/passes/MinifyImportsAndExports.cpp index 8c43ee694c3..be756cf7ec0 100644 --- a/src/passes/MinifyImportsAndExports.cpp +++ b/src/passes/MinifyImportsAndExports.cpp @@ -112,9 +112,9 @@ struct MinifyImportsAndExports : public Pass { std::cout << ','; } std::cout << "\n ["; - String::printEscaped(std::cout, key.first.view()) << ", "; - String::printEscaped(std::cout, key.second.view()) << ", "; - String::printEscaped(std::cout, new_.view()) << "]"; + String::printEscapedJSON(std::cout, key.first.view()) << ", "; + String::printEscapedJSON(std::cout, key.second.view()) << ", "; + String::printEscapedJSON(std::cout, new_.view()) << "]"; } } std::cout << "\n ],\n\"exports\": ["; @@ -127,8 +127,8 @@ struct MinifyImportsAndExports : public Pass { std::cout << ','; } std::cout << "\n ["; - String::printEscaped(std::cout, key.second.view()) << ", "; - String::printEscaped(std::cout, new_.view()) << "]"; + String::printEscapedJSON(std::cout, key.second.view()) << ", "; + String::printEscapedJSON(std::cout, new_.view()) << "]"; } } std::cout << "\n ]\n"; diff --git a/src/tools/wasm-split/wasm-split.cpp b/src/tools/wasm-split/wasm-split.cpp index 14293b779af..5497f6e33ed 100644 --- a/src/tools/wasm-split/wasm-split.cpp +++ b/src/tools/wasm-split/wasm-split.cpp @@ -433,7 +433,7 @@ void multiSplitModule(const WasmSplitOptions& options) { } continue; } - Name name = WasmBinaryReader::escape(line); + Name name = line; if (newSection) { if (name.endsWith(":")) { name = name.substr(0, name.size() - 1); diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 1dd4898a9ce..ab5aba63fda 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1489,7 +1489,6 @@ class WasmBinaryWriter { // helpers void writeInlineString(std::string_view name); - void writeEscapedName(std::string_view name); void writeInlineBuffer(const char* data, size_t size); void writeData(const char* data, size_t size); @@ -1780,7 +1779,6 @@ class WasmBinaryReader { void readTags(); - static Name escape(Name name); void readNames(size_t sectionPos, size_t payloadLen); void readFeatures(size_t sectionPos, size_t payloadLen); void readDylink(size_t payloadLen); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 1e4e3f78b98..65b7823261f 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -917,7 +917,7 @@ void WasmBinaryWriter::writeNames() { if (emitModuleName && wasm->name.is()) { auto substart = startSubsection(BinaryConsts::CustomSections::Subsection::NameModule); - writeEscapedName(wasm->name.view()); + writeInlineString(wasm->name.view()); finishSubsection(substart); } @@ -946,7 +946,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(functionsWithNames.size()); for (auto& [index, global] : functionsWithNames) { o << U32LEB(index); - writeEscapedName(global->name.view()); + writeInlineString(global->name.view()); } finishSubsection(substart); } @@ -1006,7 +1006,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(localsWithNames.size()); for (auto& [indexInBinary, name] : localsWithNames) { o << U32LEB(indexInBinary); - writeEscapedName(name.view()); + writeInlineString(name.view()); } emitted++; } @@ -1029,7 +1029,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(namedTypes.size()); for (auto type : namedTypes) { o << U32LEB(indexedTypes.indices[type]); - writeEscapedName(wasm->typeNames[type].name.view()); + writeInlineString(wasm->typeNames[type].name.view()); } finishSubsection(substart); } @@ -1056,7 +1056,7 @@ void WasmBinaryWriter::writeNames() { for (auto& [index, table] : tablesWithNames) { o << U32LEB(index); - writeEscapedName(table->name.view()); + writeInlineString(table->name.view()); } finishSubsection(substart); @@ -1082,7 +1082,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(memoriesWithNames.size()); for (auto& [index, memory] : memoriesWithNames) { o << U32LEB(index); - writeEscapedName(memory->name.view()); + writeInlineString(memory->name.view()); } finishSubsection(substart); } @@ -1107,7 +1107,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(globalsWithNames.size()); for (auto& [index, global] : globalsWithNames) { o << U32LEB(index); - writeEscapedName(global->name.view()); + writeInlineString(global->name.view()); } finishSubsection(substart); } @@ -1132,7 +1132,7 @@ void WasmBinaryWriter::writeNames() { for (auto& [index, elem] : elemsWithNames) { o << U32LEB(index); - writeEscapedName(elem->name.view()); + writeInlineString(elem->name.view()); } finishSubsection(substart); @@ -1156,7 +1156,7 @@ void WasmBinaryWriter::writeNames() { auto& seg = wasm->dataSegments[i]; if (seg->hasExplicitName) { o << U32LEB(i); - writeEscapedName(seg->name.view()); + writeInlineString(seg->name.view()); } } finishSubsection(substart); @@ -1187,7 +1187,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(fieldNames.size()); for (auto& [index, name] : fieldNames) { o << U32LEB(index); - writeEscapedName(name.view()); + writeInlineString(name.view()); } } finishSubsection(substart); @@ -1213,7 +1213,7 @@ void WasmBinaryWriter::writeNames() { o << U32LEB(tagsWithNames.size()); for (auto& [index, tag] : tagsWithNames) { o << U32LEB(index); - writeEscapedName(tag->name.view()); + writeInlineString(tag->name.view()); } finishSubsection(substart); } @@ -1846,37 +1846,6 @@ void WasmBinaryWriter::writeInlineString(std::string_view name) { o.writeInlineString(name); } -static bool isHexDigit(char ch) { - return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || - (ch >= 'A' && ch <= 'F'); -} - -static int decodeHexNibble(char ch) { - return ch <= '9' ? ch & 15 : (ch & 15) + 9; -} - -void WasmBinaryWriter::writeEscapedName(std::string_view name) { - if (name.find('\\') == std::string_view::npos) { - writeInlineString(name); - return; - } - // decode escaped by escapeName (see below) function names - std::string unescaped; - for (size_t i = 0; i < name.size();) { - char ch = name[i++]; - // support only `\xx` escapes; ignore invalid or unsupported escapes - if (ch != '\\' || i + 1 >= name.size() || !isHexDigit(name[i]) || - !isHexDigit(name[i + 1])) { - unescaped.push_back(ch); - continue; - } - unescaped.push_back( - char((decodeHexNibble(name[i]) << 4) | decodeHexNibble(name[i + 1]))); - i += 2; - } - writeInlineString({unescaped.data(), unescaped.size()}); -} - void WasmBinaryWriter::writeInlineBuffer(const char* data, size_t size) { o << U32LEB(size); writeData(data, size); @@ -5308,64 +5277,22 @@ void WasmBinaryReader::readTags() { } } -static bool isIdChar(char ch) { - return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || - (ch >= 'a' && ch <= 'z') || ch == '!' || ch == '#' || ch == '$' || - ch == '%' || ch == '&' || ch == '\'' || ch == '*' || ch == '+' || - ch == '-' || ch == '.' || ch == '/' || ch == ':' || ch == '<' || - ch == '=' || ch == '>' || ch == '?' || ch == '@' || ch == '^' || - ch == '_' || ch == '`' || ch == '|' || ch == '~'; -} - -static char formatNibble(int nibble) { - return nibble < 10 ? '0' + nibble : 'a' - 10 + nibble; -} - -Name WasmBinaryReader::escape(Name name) { - bool allIdChars = true; - for (char c : name.view()) { - if (!(allIdChars = isIdChar(c))) { - break; - } - } - if (allIdChars) { - return name; - } - // encode name, if at least one non-idchar (per WebAssembly spec) was found - std::string escaped; - for (char c : name.view()) { - if (isIdChar(c)) { - escaped.push_back(c); - continue; - } - // replace non-idchar with `\xx` escape - escaped.push_back('\\'); - escaped.push_back(formatNibble((unsigned char)c >> 4)); - escaped.push_back(formatNibble((unsigned char)c & 15)); - } - return escaped; -} - namespace { // Performs necessary processing of names from the name section before using -// them. Specifically it escapes and deduplicates them. +// them. Specifically it deduplicates them. class NameProcessor { public: - // Returns a unique, escaped name. Notes that name for the items to follow to + // Returns a unique name. Notes that name for the items to follow to // keep them unique as well. Name process(Name name) { - return deduplicate(WasmBinaryReader::escape(name)); + name = Names::getValidNameGivenExisting(name, usedNames); + usedNames.insert(name); + return name; } private: std::unordered_set usedNames; - - Name deduplicate(Name base) { - auto name = Names::getValidNameGivenExisting(base, usedNames); - usedNames.insert(name); - return name; - } }; } // anonymous namespace diff --git a/test/complexBinaryNames.wasm.fromBinary b/test/complexBinaryNames.wasm.fromBinary index 33f3d621da7..f9c4846bf0e 100644 --- a/test/complexBinaryNames.wasm.fromBinary +++ b/test/complexBinaryNames.wasm.fromBinary @@ -1,11 +1,11 @@ (module (type $0 (func)) (export "$zoo (.bar)" (func $1)) - (func $foo\20\28.bar\29 + (func $"foo (.bar)" (nop) ) (func $1 - (call $foo\20\28.bar\29) + (call $"foo (.bar)") ) ) diff --git a/test/finalize/shared_add_to_table.wasm.out b/test/finalize/shared_add_to_table.wasm.out index 556c162285f..2154f9043f4 100644 --- a/test/finalize/shared_add_to_table.wasm.out +++ b/test/finalize/shared_add_to_table.wasm.out @@ -12,13 +12,13 @@ (import "GOT.func" "_Z14waka_func_minei" (global $gimport$4 (mut i32))) (import "GOT.mem" "waka_mine" (global $gimport$5 (mut i32))) (import "GOT.mem" "waka_others" (global $gimport$6 (mut i32))) - (import "env" "_Z16waka_func_theirsi" (func $waka_func_theirs\28int\29 (param i32) (result i32))) + (import "env" "_Z16waka_func_theirsi" (func $"waka_func_theirs(int)" (param i32) (result i32))) (global $global$0 i32 (i32.const 0)) (global $global$1 i32 (i32.const 0)) (data $0 (global.get $gimport$1) "*\00\00\00") (export "__wasm_call_ctors" (func $__wasm_call_ctors)) (export "__wasm_apply_relocs" (func $__wasm_apply_relocs)) - (export "_Z14waka_func_minei" (func $waka_func_mine\28int\29)) + (export "_Z14waka_func_minei" (func $"waka_func_mine(int)")) (export "__original_main" (func $__original_main)) (export "waka_mine" (global $global$0)) (export "main" (func $main)) @@ -28,7 +28,7 @@ ) (func $__wasm_apply_relocs ) - (func $waka_func_mine\28int\29 (param $0 i32) (result i32) + (func $"waka_func_mine(int)" (param $0 i32) (result i32) (i32.add (local.get $0) (i32.const 1) diff --git a/test/lit/basic/complexTextNames.wast b/test/lit/basic/complexTextNames.wast index 16c19aadf9a..c7cbee514c1 100644 --- a/test/lit/basic/complexTextNames.wast +++ b/test/lit/basic/complexTextNames.wast @@ -23,12 +23,11 @@ ;; CHECK-TEXT: (func $"zoo (.bar)" (type $0) ;; CHECK-TEXT-NEXT: (call $foo\20\28.bar\29) ;; CHECK-TEXT-NEXT: ) + ;; CHECK-BIN: (func $"zoo (.bar)" (type $0) + ;; CHECK-BIN-NEXT: (call $foo\20\28.bar\29) + ;; CHECK-BIN-NEXT: ) (func $"zoo (.bar)" (call $foo\20\28.bar\29)) ) -;; CHECK-BIN: (func $zoo\20\28.bar\29 (type $0) -;; CHECK-BIN-NEXT: (call $foo\20\28.bar\29) -;; CHECK-BIN-NEXT: ) - ;; CHECK-BIN-NODEBUG: (type $0 (func)) ;; CHECK-BIN-NODEBUG: (func $0 (type $0) diff --git a/test/lit/wasm-split/multi-split-escape-names.wast b/test/lit/wasm-split/multi-split-escape-names.wast index f3d5acbe2e9..214dad5b49f 100644 --- a/test/lit/wasm-split/multi-split-escape-names.wast +++ b/test/lit/wasm-split/multi-split-escape-names.wast @@ -24,44 +24,44 @@ ;; MOD1: (import "primary" "table" (table $timport$0 3 funcref)) - ;; MOD1: (import "primary" "trampoline_std::operator<<\\28std::__2::basic_ostream>&\\2c\\20wasm::Module&\\29" (func $trampoline_std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29 (exact (result f32)))) + ;; MOD1: (import "primary" "trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (func $"trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (exact (result f32)))) - ;; MOD1: (import "primary" "trampoline_wasm::Literal::Literal\\28std::__2::array\\20const&\\29" (func $trampoline_wasm::Literal::Literal\28std::__2::array\20const&\29 (exact (result i64)))) + ;; MOD1: (import "primary" "trampoline_wasm::Literal::Literal(std::__2::array const&)" (func $"trampoline_wasm::Literal::Literal(std::__2::array const&)" (exact (result i64)))) - ;; MOD1: (elem $0 (i32.const 2) $wasm::Type::getFeatures\28\29\20const) + ;; MOD1: (elem $0 (i32.const 2) $"wasm::Type::getFeatures() const") - ;; MOD1: (func $wasm::Type::getFeatures\28\29\20const (result i32) + ;; MOD1: (func $"wasm::Type::getFeatures() const" (result i32) ;; MOD1-NEXT: (drop ;; MOD1-NEXT: (call_ref $2 - ;; MOD1-NEXT: (ref.func $wasm::Type::getFeatures\28\29\20const) + ;; MOD1-NEXT: (ref.func $"wasm::Type::getFeatures() const") ;; MOD1-NEXT: ) ;; MOD1-NEXT: ) ;; MOD1-NEXT: (drop ;; MOD1-NEXT: (call_ref $1 - ;; MOD1-NEXT: (ref.func $trampoline_wasm::Literal::Literal\28std::__2::array\20const&\29) + ;; MOD1-NEXT: (ref.func $"trampoline_wasm::Literal::Literal(std::__2::array const&)") ;; MOD1-NEXT: ) ;; MOD1-NEXT: ) ;; MOD1-NEXT: (drop ;; MOD1-NEXT: (call_ref $0 - ;; MOD1-NEXT: (ref.func $trampoline_std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + ;; MOD1-NEXT: (ref.func $"trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") ;; MOD1-NEXT: ) ;; MOD1-NEXT: ) ;; MOD1-NEXT: (i32.const 0) ;; MOD1-NEXT: ) - (func $wasm::Type::getFeatures\28\29\20const (type $ret-i32) (result i32) + (func $"wasm::Type::getFeatures() const" (type $ret-i32) (result i32) (drop (call_ref $ret-i32 - (ref.func $wasm::Type::getFeatures\28\29\20const) + (ref.func $"wasm::Type::getFeatures() const") ) ) (drop (call_ref $ret-i64 - (ref.func $wasm::Literal::Literal\28std::__2::array\20const&\29) + (ref.func $"wasm::Literal::Literal(std::__2::array const&)") ) ) (drop (call_ref $ret-f32 - (ref.func $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + (ref.func $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") ) ) (i32.const 0) @@ -75,44 +75,44 @@ ;; MOD2: (import "primary" "table" (table $timport$0 3 funcref)) - ;; MOD2: (import "primary" "trampoline_std::operator<<\\28std::__2::basic_ostream>&\\2c\\20wasm::Module&\\29" (func $trampoline_std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29 (exact (result f32)))) + ;; MOD2: (import "primary" "trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (func $"trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (exact (result f32)))) - ;; MOD2: (import "primary" "trampoline_wasm::Type::getFeatures\\28\\29\\20const" (func $trampoline_wasm::Type::getFeatures\28\29\20const (exact (result i32)))) + ;; MOD2: (import "primary" "trampoline_wasm::Type::getFeatures() const" (func $"trampoline_wasm::Type::getFeatures() const" (exact (result i32)))) - ;; MOD2: (elem $0 (i32.const 0) $wasm::Literal::Literal\28std::__2::array\20const&\29) + ;; MOD2: (elem $0 (i32.const 0) $"wasm::Literal::Literal(std::__2::array const&)") - ;; MOD2: (func $wasm::Literal::Literal\28std::__2::array\20const&\29 (result i64) + ;; MOD2: (func $"wasm::Literal::Literal(std::__2::array const&)" (result i64) ;; MOD2-NEXT: (drop ;; MOD2-NEXT: (call_ref $1 - ;; MOD2-NEXT: (ref.func $trampoline_wasm::Type::getFeatures\28\29\20const) + ;; MOD2-NEXT: (ref.func $"trampoline_wasm::Type::getFeatures() const") ;; MOD2-NEXT: ) ;; MOD2-NEXT: ) ;; MOD2-NEXT: (drop ;; MOD2-NEXT: (call_ref $2 - ;; MOD2-NEXT: (ref.func $wasm::Literal::Literal\28std::__2::array\20const&\29) + ;; MOD2-NEXT: (ref.func $"wasm::Literal::Literal(std::__2::array const&)") ;; MOD2-NEXT: ) ;; MOD2-NEXT: ) ;; MOD2-NEXT: (drop ;; MOD2-NEXT: (call_ref $0 - ;; MOD2-NEXT: (ref.func $trampoline_std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + ;; MOD2-NEXT: (ref.func $"trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") ;; MOD2-NEXT: ) ;; MOD2-NEXT: ) ;; MOD2-NEXT: (i64.const 0) ;; MOD2-NEXT: ) - (func $wasm::Literal::Literal\28std::__2::array\20const&\29 (type $ret-i64) (result i64) + (func $"wasm::Literal::Literal(std::__2::array const&)" (type $ret-i64) (result i64) (drop (call_ref $ret-i32 - (ref.func $wasm::Type::getFeatures\28\29\20const) + (ref.func $"wasm::Type::getFeatures() const") ) ) (drop (call_ref $ret-i64 - (ref.func $wasm::Literal::Literal\28std::__2::array\20const&\29) + (ref.func $"wasm::Literal::Literal(std::__2::array const&)") ) ) (drop (call_ref $ret-f32 - (ref.func $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + (ref.func $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") ) ) (i64.const 0) @@ -126,44 +126,44 @@ ;; MOD3: (import "primary" "table" (table $timport$0 3 funcref)) - ;; MOD3: (import "primary" "trampoline_wasm::Literal::Literal\\28std::__2::array\\20const&\\29" (func $trampoline_wasm::Literal::Literal\28std::__2::array\20const&\29 (exact (result i64)))) + ;; MOD3: (import "primary" "trampoline_wasm::Literal::Literal(std::__2::array const&)" (func $"trampoline_wasm::Literal::Literal(std::__2::array const&)" (exact (result i64)))) - ;; MOD3: (import "primary" "trampoline_wasm::Type::getFeatures\\28\\29\\20const" (func $trampoline_wasm::Type::getFeatures\28\29\20const (exact (result i32)))) + ;; MOD3: (import "primary" "trampoline_wasm::Type::getFeatures() const" (func $"trampoline_wasm::Type::getFeatures() const" (exact (result i32)))) - ;; MOD3: (elem $0 (i32.const 1) $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + ;; MOD3: (elem $0 (i32.const 1) $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") - ;; MOD3: (func $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29 (result f32) + ;; MOD3: (func $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (result f32) ;; MOD3-NEXT: (drop ;; MOD3-NEXT: (call_ref $1 - ;; MOD3-NEXT: (ref.func $trampoline_wasm::Type::getFeatures\28\29\20const) + ;; MOD3-NEXT: (ref.func $"trampoline_wasm::Type::getFeatures() const") ;; MOD3-NEXT: ) ;; MOD3-NEXT: ) ;; MOD3-NEXT: (drop ;; MOD3-NEXT: (call_ref $0 - ;; MOD3-NEXT: (ref.func $trampoline_wasm::Literal::Literal\28std::__2::array\20const&\29) + ;; MOD3-NEXT: (ref.func $"trampoline_wasm::Literal::Literal(std::__2::array const&)") ;; MOD3-NEXT: ) ;; MOD3-NEXT: ) ;; MOD3-NEXT: (drop ;; MOD3-NEXT: (call_ref $2 - ;; MOD3-NEXT: (ref.func $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + ;; MOD3-NEXT: (ref.func $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") ;; MOD3-NEXT: ) ;; MOD3-NEXT: ) ;; MOD3-NEXT: (f32.const 0) ;; MOD3-NEXT: ) - (func $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29 (type $ret-f32) (result f32) + (func $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (type $ret-f32) (result f32) (drop (call_ref $ret-i32 - (ref.func $wasm::Type::getFeatures\28\29\20const) + (ref.func $"wasm::Type::getFeatures() const") ) ) (drop (call_ref $ret-i64 - (ref.func $wasm::Literal::Literal\28std::__2::array\20const&\29) + (ref.func $"wasm::Literal::Literal(std::__2::array const&)") ) ) (drop (call_ref $ret-f32 - (ref.func $std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29) + (ref.func $"std::operator<<(std::__2::basic_ostream>&, wasm::Module&)") ) ) (f32.const 0) @@ -179,27 +179,27 @@ ;; PRIMARY: (elem $0 (i32.const 0) $placeholder_0 $placeholder_1 $placeholder_2) -;; PRIMARY: (export "trampoline_std::operator<<\\28std::__2::basic_ostream>&\\2c\\20wasm::Module&\\29" (func $trampoline_std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29)) +;; PRIMARY: (export "trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (func $"trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)")) -;; PRIMARY: (export "trampoline_wasm::Literal::Literal\\28std::__2::array\\20const&\\29" (func $trampoline_wasm::Literal::Literal\28std::__2::array\20const&\29)) +;; PRIMARY: (export "trampoline_wasm::Literal::Literal(std::__2::array const&)" (func $"trampoline_wasm::Literal::Literal(std::__2::array const&)")) -;; PRIMARY: (export "trampoline_wasm::Type::getFeatures\\28\\29\\20const" (func $trampoline_wasm::Type::getFeatures\28\29\20const)) +;; PRIMARY: (export "trampoline_wasm::Type::getFeatures() const" (func $"trampoline_wasm::Type::getFeatures() const")) ;; PRIMARY: (export "table" (table $0)) -;; PRIMARY: (func $trampoline_wasm::Literal::Literal\28std::__2::array\20const&\29 (result i64) +;; PRIMARY: (func $"trampoline_wasm::Literal::Literal(std::__2::array const&)" (result i64) ;; PRIMARY-NEXT: (call_indirect (type $ret-i64) ;; PRIMARY-NEXT: (i32.const 0) ;; PRIMARY-NEXT: ) ;; PRIMARY-NEXT: ) -;; PRIMARY: (func $trampoline_std::operator<<\28std::__2::basic_ostream>&\2c\20wasm::Module&\29 (result f32) +;; PRIMARY: (func $"trampoline_std::operator<<(std::__2::basic_ostream>&, wasm::Module&)" (result f32) ;; PRIMARY-NEXT: (call_indirect (type $ret-f32) ;; PRIMARY-NEXT: (i32.const 1) ;; PRIMARY-NEXT: ) ;; PRIMARY-NEXT: ) -;; PRIMARY: (func $trampoline_wasm::Type::getFeatures\28\29\20const (result i32) +;; PRIMARY: (func $"trampoline_wasm::Type::getFeatures() const" (result i32) ;; PRIMARY-NEXT: (call_indirect (type $ret-i32) ;; PRIMARY-NEXT: (i32.const 2) ;; PRIMARY-NEXT: ) diff --git a/test/passes/dwarf_with_exceptions.bin.txt b/test/passes/dwarf_with_exceptions.bin.txt index f6a40099430..843414145d4 100644 --- a/test/passes/dwarf_with_exceptions.bin.txt +++ b/test/passes/dwarf_with_exceptions.bin.txt @@ -2,17 +2,17 @@ (type $0 (func)) (type $1 (func (param i32))) (type $2 (func (param i32) (result i32))) - (import "env" "_Z3foov" (func $foo\28\29)) + (import "env" "_Z3foov" (func $"foo()")) (import "env" "__cxa_begin_catch" (func $__cxa_begin_catch (param i32) (result i32))) (import "env" "__cxa_end_catch" (func $__cxa_end_catch)) - (import "env" "_ZSt9terminatev" (func $std::terminate\28\29)) + (import "env" "_ZSt9terminatev" (func $"std::terminate()")) (global $__stack_pointer (mut i32) (i32.const 66560)) (memory $0 2) (tag $tag$0 (type $1) (param i32)) (export "memory" (memory $0)) (func $__wasm_call_ctors ) - (func $dwarf_with_exceptions\28\29 + (func $"dwarf_with_exceptions()" (local $0 i32) (local $1 i32) ;; code offset: 0xe @@ -24,7 +24,7 @@ (try (do ;; code offset: 0x12 - (call $foo\28\29) + (call $"foo()") ) ;; code offset: 0x18 (catch $tag$0 @@ -49,7 +49,7 @@ (try $label (do ;; code offset: 0x33 - (call $foo\28\29) + (call $"foo()") ;; code offset: 0x3b (global.set $__stack_pointer ;; code offset: 0x39 @@ -86,7 +86,7 @@ ;; code offset: 0x63 (catch_all ;; code offset: 0x64 - (call $std::terminate\28\29) + (call $"std::terminate()") ;; code offset: 0x6a (unreachable) ) @@ -110,7 +110,7 @@ ) ) ;; code offset: 0x82 - (call $std::terminate\28\29) + (call $"std::terminate()") ;; code offset: 0x88 (unreachable) ) @@ -408,17 +408,17 @@ file_names[ 1]: (type $0 (func)) (type $1 (func (param i32))) (type $2 (func (param i32) (result i32))) - (import "env" "_Z3foov" (func $foo\28\29)) + (import "env" "_Z3foov" (func $"foo()")) (import "env" "__cxa_begin_catch" (func $__cxa_begin_catch (param i32) (result i32))) (import "env" "__cxa_end_catch" (func $__cxa_end_catch)) - (import "env" "_ZSt9terminatev" (func $std::terminate\28\29)) + (import "env" "_ZSt9terminatev" (func $"std::terminate()")) (global $__stack_pointer (mut i32) (i32.const 66560)) (memory $0 2) (tag $tag$0 (type $1) (param i32)) (export "memory" (memory $0)) (func $__wasm_call_ctors ) - (func $dwarf_with_exceptions\28\29 + (func $"dwarf_with_exceptions()" (local $0 i32) (local $1 i32) ;; code offset: 0xc @@ -430,7 +430,7 @@ file_names[ 1]: (try (do ;; code offset: 0x10 - (call $foo\28\29) + (call $"foo()") ) ;; code offset: 0x12 (catch $tag$0 @@ -455,7 +455,7 @@ file_names[ 1]: (try $label (do ;; code offset: 0x21 - (call $foo\28\29) + (call $"foo()") ;; code offset: 0x25 (global.set $__stack_pointer ;; code offset: 0x23 @@ -492,7 +492,7 @@ file_names[ 1]: ;; code offset: 0x39 (catch_all ;; code offset: 0x3a - (call $std::terminate\28\29) + (call $"std::terminate()") ;; code offset: 0x3c (unreachable) ) @@ -516,7 +516,7 @@ file_names[ 1]: ) ) ;; code offset: 0x4c - (call $std::terminate\28\29) + (call $"std::terminate()") ;; code offset: 0x4e (unreachable) ) diff --git a/test/passes/fannkuch0_dwarf.bin.txt b/test/passes/fannkuch0_dwarf.bin.txt index 9e9bb853743..99bea9dd3a0 100644 --- a/test/passes/fannkuch0_dwarf.bin.txt +++ b/test/passes/fannkuch0_dwarf.bin.txt @@ -5209,7 +5209,7 @@ file_names[ 3]: (export "__data_end" (global $global$1)) (func $__wasm_call_ctors ) - (func $fannkuch_worker\28void*\29 (param $0 i32) (result i32) + (func $"fannkuch_worker(void*)" (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -8117,7 +8117,7 @@ file_names[ 3]: ;; code offset: 0xb83 (local.set $31 ;; code offset: 0xb81 - (call $fannkuch\28int\29 + (call $"fannkuch(int)" ;; code offset: 0xb7f (local.get $30) ) @@ -8198,7 +8198,7 @@ file_names[ 3]: (local.get $34) ) ) - (func $fannkuch\28int\29 (param $0 i32) (result i32) + (func $"fannkuch(int)" (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -10004,7 +10004,7 @@ file_names[ 3]: ;; code offset: 0x12ac (local.set $164 ;; code offset: 0x12aa - (call $fannkuch_worker\28void*\29 + (call $"fannkuch_worker(void*)" ;; code offset: 0x12a7 (local.get $163) ) diff --git a/test/passes/fannkuch3_dwarf.bin.txt b/test/passes/fannkuch3_dwarf.bin.txt index b2e61acfa7d..add01a9c539 100644 --- a/test/passes/fannkuch3_dwarf.bin.txt +++ b/test/passes/fannkuch3_dwarf.bin.txt @@ -4812,7 +4812,7 @@ file_names[ 4]: (export "__data_end" (global $global$1)) (func $__wasm_call_ctors ) - (func $fannkuch_worker\28void*\29 (param $0 i32) (result i32) + (func $"fannkuch_worker(void*)" (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -6925,7 +6925,7 @@ file_names[ 4]: ;; code offset: 0x667 (local.set $1 ;; code offset: 0x665 - (call $fannkuch_worker\28void*\29 + (call $"fannkuch_worker(void*)" ;; code offset: 0x663 (local.get $3) ) diff --git a/test/passes/fannkuch3_manyopts_dwarf.bin.txt b/test/passes/fannkuch3_manyopts_dwarf.bin.txt index 78fd4ed1193..61a83f3aa28 100644 --- a/test/passes/fannkuch3_manyopts_dwarf.bin.txt +++ b/test/passes/fannkuch3_manyopts_dwarf.bin.txt @@ -4693,7 +4693,7 @@ file_names[ 4]: (export "__data_end" (global $global$1)) (func $__wasm_call_ctors ) - (func $fannkuch_worker\28void*\29 (param $0 i32) (result i32) + (func $"fannkuch_worker(void*)" (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -6759,7 +6759,7 @@ file_names[ 4]: ;; code offset: 0x61e (local.set $1 ;; code offset: 0x61c - (call $fannkuch_worker\28void*\29 + (call $"fannkuch_worker(void*)" ;; code offset: 0x61a (local.get $4) ) diff --git a/test/passes/ignore_missing_func_dwarf.bin.txt b/test/passes/ignore_missing_func_dwarf.bin.txt index 6cc13c97762..a18e2b455b0 100644 --- a/test/passes/ignore_missing_func_dwarf.bin.txt +++ b/test/passes/ignore_missing_func_dwarf.bin.txt @@ -14,7 +14,7 @@ (export "__data_end" (global $global$1)) (func $__wasm_call_ctors ) - (func $used\28int\29 (param $0 i32) (result i32) + (func $"used(int)" (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -183,7 +183,7 @@ ;; code offset: 0x95 (local.set $5 ;; code offset: 0x8f - (call $used\28int\29 + (call $"used(int)" ;; code offset: 0x8d (local.get $3) ) @@ -837,7 +837,7 @@ file_names[ 1]: (export "__data_end" (global $global$1)) (func $__wasm_call_ctors ) - (func $used\28int\29 (param $0 i32) (result i32) + (func $"used(int)" (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1006,7 +1006,7 @@ file_names[ 1]: ;; code offset: 0xab (local.set $5 ;; code offset: 0xa9 - (call $used\28int\29 + (call $"used(int)" ;; code offset: 0xa7 (local.get $3) ) diff --git a/test/passes/inlined_to_start_dwarf.bin.txt b/test/passes/inlined_to_start_dwarf.bin.txt index 16c68c2ca5e..9c67a04608a 100644 --- a/test/passes/inlined_to_start_dwarf.bin.txt +++ b/test/passes/inlined_to_start_dwarf.bin.txt @@ -429,7 +429,7 @@ file_names[ 1]: (export "__data_end" (global $global$1)) (func $__wasm_call_ctors ) - (func $dsquare\28int\2c\20int\29 (param $0 i32) (param $1 i32) (result i32) + (func $"dsquare(int, int)" (param $0 i32) (param $1 i32) (result i32) ;; code offset: 0x10 (i32.add ;; code offset: 0xa @@ -450,7 +450,7 @@ file_names[ 1]: ) (func $main (param $0 i32) (param $1 i32) (result i32) ;; code offset: 0x18 - (call $dsquare\28int\2c\20int\29 + (call $"dsquare(int, int)" ;; code offset: 0x14 (i32.const 6) ;; code offset: 0x16 diff --git a/test/unit/input/asyncify-pure.wat b/test/unit/input/asyncify-pure.wat index be9743df84b..c2ac8fbd874 100644 --- a/test/unit/input/asyncify-pure.wat +++ b/test/unit/input/asyncify-pure.wat @@ -60,6 +60,6 @@ (call $print (i32.const 500)) ) ;; interesting escaped name - (func $DOS_ReadFile\28unsigned\20short\2c\20unsigned\20char*\2c\20unsigned\20short*\2c\20bool\29 (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) + (func $"DOS_ReadFile\28unsigned\20short\2c\20unsigned\20char*\2c\20unsigned\20short*\2c\20bool\29" (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) ) ) From 8f1303293ff0ba46adf9cf775a204c37fd91bcb3 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 30 Jun 2026 20:26:55 -0700 Subject: [PATCH 2/5] undo MinifyImportsAndExports change --- src/passes/MinifyImportsAndExports.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/passes/MinifyImportsAndExports.cpp b/src/passes/MinifyImportsAndExports.cpp index be756cf7ec0..8c43ee694c3 100644 --- a/src/passes/MinifyImportsAndExports.cpp +++ b/src/passes/MinifyImportsAndExports.cpp @@ -112,9 +112,9 @@ struct MinifyImportsAndExports : public Pass { std::cout << ','; } std::cout << "\n ["; - String::printEscapedJSON(std::cout, key.first.view()) << ", "; - String::printEscapedJSON(std::cout, key.second.view()) << ", "; - String::printEscapedJSON(std::cout, new_.view()) << "]"; + String::printEscaped(std::cout, key.first.view()) << ", "; + String::printEscaped(std::cout, key.second.view()) << ", "; + String::printEscaped(std::cout, new_.view()) << "]"; } } std::cout << "\n ],\n\"exports\": ["; @@ -127,8 +127,8 @@ struct MinifyImportsAndExports : public Pass { std::cout << ','; } std::cout << "\n ["; - String::printEscapedJSON(std::cout, key.second.view()) << ", "; - String::printEscapedJSON(std::cout, new_.view()) << "]"; + String::printEscaped(std::cout, key.second.view()) << ", "; + String::printEscaped(std::cout, new_.view()) << "]"; } } std::cout << "\n ]\n"; From f9c003ae5f9712b7f11db3c55d4a5cb26f537cf1 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 30 Jun 2026 20:44:44 -0700 Subject: [PATCH 3/5] update binaryen.js tests --- test/binaryen.js/debug-names.js.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/binaryen.js/debug-names.js.txt b/test/binaryen.js/debug-names.js.txt index 34de198cd22..e538ceb15b9 100644 --- a/test/binaryen.js/debug-names.js.txt +++ b/test/binaryen.js/debug-names.js.txt @@ -26,7 +26,7 @@ (memory $lo 0 0) (table $wor 0 0 funcref) (func $of (param $js i32) - (local $!#$%&'*+-./:<=>?@\5c^_`|~ f64) + (local $!#$%&'*+-./:<=>?@\^_`|~ f64) ) ) @@ -37,7 +37,7 @@ (memory $lo 0 0) (table $wor 0 0 funcref) (func $of (param $js i32) - (local $!#$%&'*+-./:<=>?@\5c^_`|~ f64) + (local $!#$%&'*+-./:<=>?@\^_`|~ f64) ) ) From 3069f222cd56ecc2740f1043e60d29980c004829 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Tue, 30 Jun 2026 20:46:28 -0700 Subject: [PATCH 4/5] remove old escape code --- src/ir/names.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/src/ir/names.cpp b/src/ir/names.cpp index de76d6b895e..b9256626a31 100644 --- a/src/ir/names.cpp +++ b/src/ir/names.cpp @@ -70,44 +70,6 @@ std::string MinifiedNameGenerator::getName() { return name; } -static bool isIdChar(char ch) { - return (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || - (ch >= 'a' && ch <= 'z') || ch == '!' || ch == '#' || ch == '$' || - ch == '%' || ch == '&' || ch == '\'' || ch == '*' || ch == '+' || - ch == '-' || ch == '.' || ch == '/' || ch == ':' || ch == '<' || - ch == '=' || ch == '>' || ch == '?' || ch == '@' || ch == '^' || - ch == '_' || ch == '`' || ch == '|' || ch == '~'; -} - -static char formatNibble(int nibble) { - return nibble < 10 ? '0' + nibble : 'a' - 10 + nibble; -} - -Name escape(Name name) { - bool allIdChars = true; - for (char c : name.view()) { - if (!(allIdChars = isIdChar(c))) { - break; - } - } - if (allIdChars) { - return name; - } - // encode name, if at least one non-idchar (per WebAssembly spec) was found - std::string escaped; - for (char c : name.view()) { - if (isIdChar(c)) { - escaped.push_back(c); - continue; - } - // replace non-idchar with `\xx` escape - escaped.push_back('\\'); - escaped.push_back(formatNibble((unsigned char)c >> 4)); - escaped.push_back(formatNibble((unsigned char)c & 15)); - } - return escaped; -} - // TODO: consolidate this with other string parsing code in string.cpp and // lexer.h. std::string unescape(Name name) { From c76396ffd06fdc612175b8b65e11a27d19690e05 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Wed, 1 Jul 2026 10:44:54 -0700 Subject: [PATCH 5/5] remove wasm-split --unescape option --- src/ir/names.cpp | 19 ------------------- src/ir/names.h | 4 ---- src/tools/wasm-split/split-options.cpp | 6 ------ src/tools/wasm-split/split-options.h | 1 - src/tools/wasm-split/wasm-split.cpp | 4 +--- test/lit/help/wasm-split.test | 3 --- test/lit/wasm-split/print-profile.wast | 13 ++++--------- 7 files changed, 5 insertions(+), 45 deletions(-) diff --git a/src/ir/names.cpp b/src/ir/names.cpp index b9256626a31..fc5ed9e58cc 100644 --- a/src/ir/names.cpp +++ b/src/ir/names.cpp @@ -70,23 +70,4 @@ std::string MinifiedNameGenerator::getName() { return name; } -// TODO: consolidate this with other string parsing code in string.cpp and -// lexer.h. -std::string unescape(Name name) { - std::string output; - std::string_view input = name.view(); - for (size_t i = 0; i < input.length(); i++) { - if ((input[i] == '\\') && (i + 2 < input.length()) && - isxdigit(input[i + 1]) && isxdigit(input[i + 2])) { - std::string byte = std::string(input.substr(i + 1, 2)); - i += 2; - char chr = (char)(int)strtol(byte.c_str(), nullptr, 16); - output.push_back(chr); - } else { - output.push_back(input[i]); - } - } - return output; -} - } // namespace wasm::Names diff --git a/src/ir/names.h b/src/ir/names.h index 89e3b1fa5c0..083a54f0ef5 100644 --- a/src/ir/names.h +++ b/src/ir/names.h @@ -138,10 +138,6 @@ class MinifiedNameGenerator { std::string getName(); }; -// Unescapes a WebAssembly identifier back into its original human-readable -// string. -std::string unescape(Name name); - } // namespace wasm::Names #endif // wasm_ir_names_h diff --git a/src/tools/wasm-split/split-options.cpp b/src/tools/wasm-split/split-options.cpp index d20b57f6cd7..8a51f2621db 100644 --- a/src/tools/wasm-split/split-options.cpp +++ b/src/tools/wasm-split/split-options.cpp @@ -365,12 +365,6 @@ WasmSplitOptions::WasmSplitOptions() {Mode::Instrument, Mode::MergeProfiles, Mode::MultiSplit}, Options::Arguments::One, [&](Options* o, const std::string& argument) { output = argument; }) - .add("--unescape", - "-u", - "Un-escape function names (in print-profile output)", - WasmSplitOption, - Options::Arguments::Zero, - [&](Options* o, const std::string& argument) { unescape = true; }) .add("--verbose", "-v", "Verbose output mode. Prints the functions that will be kept " diff --git a/src/tools/wasm-split/split-options.h b/src/tools/wasm-split/split-options.h index 25b681a95f1..1b391a5fa65 100644 --- a/src/tools/wasm-split/split-options.h +++ b/src/tools/wasm-split/split-options.h @@ -45,7 +45,6 @@ struct WasmSplitOptions : ToolOptions { StorageKind storageKind = StorageKind::InGlobals; bool usePlaceholders = true; - bool unescape = false; bool verbose = false; bool emitBinary = true; bool symbolMap = false; diff --git a/src/tools/wasm-split/wasm-split.cpp b/src/tools/wasm-split/wasm-split.cpp index 45c263775de..112a001dd01 100644 --- a/src/tools/wasm-split/wasm-split.cpp +++ b/src/tools/wasm-split/wasm-split.cpp @@ -586,9 +586,7 @@ void printReadableProfile(const WasmSplitOptions& options) { auto printFnSet = [&](auto funcs, std::string prefix) { for (auto it = funcs.begin(); it != funcs.end(); ++it) { - std::cout << prefix << " " - << (options.unescape ? Names::unescape(*it) : it->toString()) - << std::endl; + std::cout << prefix << " " << it->toString() << std::endl; } }; diff --git a/test/lit/help/wasm-split.test b/test/lit/help/wasm-split.test index c39cf69e534..e7304d3f618 100644 --- a/test/lit/help/wasm-split.test +++ b/test/lit/help/wasm-split.test @@ -150,9 +150,6 @@ ;; CHECK-NEXT: --output,-o [instrument, merge-profiles, multi-split] ;; CHECK-NEXT: Output file. ;; CHECK-NEXT: -;; CHECK-NEXT: --unescape,-u Un-escape function names (in -;; CHECK-NEXT: print-profile output) -;; CHECK-NEXT: ;; CHECK-NEXT: --verbose,-v Verbose output mode. Prints the functions ;; CHECK-NEXT: that will be kept and split out when ;; CHECK-NEXT: splitting a module. diff --git a/test/lit/wasm-split/print-profile.wast b/test/lit/wasm-split/print-profile.wast index ec37858bdf9..f0a46f7b761 100644 --- a/test/lit/wasm-split/print-profile.wast +++ b/test/lit/wasm-split/print-profile.wast @@ -5,24 +5,19 @@ ;; RUN: node %S/call_exports.mjs %t.instrumented.wasm %t.foo.prof foo ;; Print profile -;; RUN: wasm-split %s --print-profile=%t.foo.prof | filecheck %s --check-prefix=ESCAPED +;; RUN: wasm-split %s --print-profile=%t.foo.prof | filecheck %s -;; Print profile + unescape function names -;; RUN: wasm-split %s --print-profile=%t.foo.prof --unescape | filecheck %s --check-prefix=UNESCAPED - -;; ESCAPED: - bar\28double\5b3\5d\29 - -;; UNESCAPED: - bar(double[3]) +;; CHECK: - bar(double[3]) (module (memory $m 0 0) (export "memory" (memory $m)) (export "foo" (func $foo)) - (export "bar" (func $bar\28double\5b3\5d\29)) + (export "bar" (func $"bar\28double\5b3\5d\29")) (func $foo (nop) ) - (func $bar\28double\5b3\5d\29 + (func $"bar\28double\5b3\5d\29" (nop) ) )