From bc6dd69319d1e506282c059f48d87f3e62492cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 31 Jul 2024 11:46:58 +0200 Subject: [PATCH 01/33] Handle single-segment source mapping in source map header decoder --- src/wasm/wasm-binary.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 0a65fbadbf4..06e12b85ecb 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2939,13 +2939,20 @@ void WasmBinaryReader::readSourceMapHeader() { // investigation (if it does, it will assert in readBase64VLQ, so it // would not be a silent error at least). uint32_t position = readBase64VLQ(*sourceMap); - uint32_t fileIndex = readBase64VLQ(*sourceMap); - uint32_t lineNumber = - readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number - uint32_t columnNumber = readBase64VLQ(*sourceMap); nextDebugPos = position; - nextDebugLocation = {fileIndex, lineNumber, columnNumber}; - nextDebugLocationHasDebugInfo = true; + + auto peek = sourceMap->peek(); + if (peek == ',' || peek == '\"') { + // This is a 1-length entry, so the next location has no debug info. + nextDebugLocationHasDebugInfo = false; + } else { + uint32_t fileIndex = readBase64VLQ(*sourceMap); + uint32_t lineNumber = + readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number + uint32_t columnNumber = readBase64VLQ(*sourceMap); + nextDebugLocation = {fileIndex, lineNumber, columnNumber}; + nextDebugLocationHasDebugInfo = true; + } } void WasmBinaryReader::readNextDebugLocation() { From a12e4ad4e48c90fa8e0a755b447bbe536444df7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 31 Jul 2024 13:24:08 +0200 Subject: [PATCH 02/33] Support 5-segment source mappings --- src/parser/contexts.h | 2 +- src/wasm.h | 7 +++++-- src/wasm/wasm-binary.cpp | 44 ++++++++++++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 96a70663d15..cc8d76ea5db 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1788,7 +1788,7 @@ struct ParseDefsCtx : TypeParserCtx { wasm.debugInfoFileNames.push_back(std::string(file)); } irBuilder.setDebugLocation( - Function::DebugLocation({it->second, *line, *col})); + Function::DebugLocation({it->second, *line, *col, std::nullopt})); } Result<> makeBlock(Index pos, diff --git a/src/wasm.h b/src/wasm.h index 4a4ed561f91..b3e1c5009c4 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2029,9 +2029,10 @@ class Function : public Importable { // Source maps debugging info: map expression nodes to their file, line, col. struct DebugLocation { BinaryLocation fileIndex, lineNumber, columnNumber; + std::optional nameIndex; bool operator==(const DebugLocation& other) const { return fileIndex == other.fileIndex && lineNumber == other.lineNumber && - columnNumber == other.columnNumber; + columnNumber == other.columnNumber && nameIndex == other.nameIndex; } bool operator!=(const DebugLocation& other) const { return !(*this == other); @@ -2041,7 +2042,9 @@ class Function : public Importable { ? fileIndex < other.fileIndex : lineNumber != other.lineNumber ? lineNumber < other.lineNumber - : columnNumber < other.columnNumber; + : columnNumber != other.columnNumber + ? columnNumber < other.columnNumber + : nameIndex < other.nameIndex; } }; // One can explicitly set the debug location of an expression to diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 06e12b85ecb..fbb16a9388b 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1207,7 +1207,7 @@ void WasmBinaryWriter::writeSymbolMap() { } void WasmBinaryWriter::initializeDebugInfo() { - lastDebugLocation = {0, /* lineNumber = */ 1, 0}; + lastDebugLocation = {0, /* lineNumber = */ 1, 0, std::nullopt}; } void WasmBinaryWriter::writeSourceMapProlog() { @@ -1243,7 +1243,10 @@ static void writeBase64VLQ(std::ostream& out, int32_t n) { void WasmBinaryWriter::writeSourceMapEpilog() { // write source map entries size_t lastOffset = 0; - Function::DebugLocation lastLoc = {0, /* lineNumber = */ 1, 0}; + BinaryLocation lastFileIndex = 0; + BinaryLocation lastLineNumber = 1; + BinaryLocation lastColumnNumber = 0; + BinaryLocation lastNameIndex = 0; for (const auto& [offset, loc] : sourceMapLocations) { if (lastOffset > 0) { *sourceMap << ","; @@ -1251,13 +1254,21 @@ void WasmBinaryWriter::writeSourceMapEpilog() { writeBase64VLQ(*sourceMap, int32_t(offset - lastOffset)); lastOffset = offset; if (loc) { - // There is debug information for this location, so emit the next 3 - // fields and update lastLoc. - writeBase64VLQ(*sourceMap, int32_t(loc->fileIndex - lastLoc.fileIndex)); - writeBase64VLQ(*sourceMap, int32_t(loc->lineNumber - lastLoc.lineNumber)); + writeBase64VLQ(*sourceMap, int32_t(loc->fileIndex - lastFileIndex)); + lastFileIndex = loc->fileIndex; + + writeBase64VLQ(*sourceMap, int32_t(loc->lineNumber - lastLineNumber)); + lastLineNumber = loc->lineNumber; + writeBase64VLQ(*sourceMap, - int32_t(loc->columnNumber - lastLoc.columnNumber)); - lastLoc = *loc; + int32_t(loc->columnNumber - lastColumnNumber)); + lastColumnNumber = loc->columnNumber; + + if (loc->nameIndex) { + writeBase64VLQ(*sourceMap, + int32_t(*loc->nameIndex - lastNameIndex)); + lastNameIndex = *loc->nameIndex; + } } } *sourceMap << "\"}"; @@ -1708,7 +1719,7 @@ WasmBinaryReader::WasmBinaryReader(Module& wasm, FeatureSet features, const std::vector& input) : wasm(wasm), allocator(wasm.allocator), input(input), sourceMap(nullptr), - nextDebugPos(0), nextDebugLocation{0, 0, 0}, + nextDebugPos(0), nextDebugLocation{0, 0, 0, std::nullopt}, nextDebugLocationHasDebugInfo(false), debugLocation() { wasm.features = features; } @@ -2950,7 +2961,12 @@ void WasmBinaryReader::readSourceMapHeader() { uint32_t lineNumber = readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number uint32_t columnNumber = readBase64VLQ(*sourceMap); - nextDebugLocation = {fileIndex, lineNumber, columnNumber}; + std::optional nameIndex = std::nullopt; + peek = sourceMap->peek(); + if (!(peek == ',' || peek == '\"')) { + nameIndex = readBase64VLQ(*sourceMap); + } + nextDebugLocation = {fileIndex, lineNumber, columnNumber, nameIndex}; nextDebugLocationHasDebugInfo = true; } } @@ -3005,7 +3021,13 @@ void WasmBinaryReader::readNextDebugLocation() { int32_t columnNumberDelta = readBase64VLQ(*sourceMap); uint32_t columnNumber = nextDebugLocation.columnNumber + columnNumberDelta; - nextDebugLocation = {fileIndex, lineNumber, columnNumber}; + std::optional nameIndex = std::nullopt; + peek = sourceMap->peek(); + if (!(peek == ',' || peek == '\"')) { + nameIndex = readBase64VLQ(*sourceMap); + } + + nextDebugLocation = {fileIndex, lineNumber, columnNumber, nameIndex}; nextDebugLocationHasDebugInfo = true; } } From d8555c5e08db7b96896aa4a11fe768b7134ef0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 7 Aug 2024 09:14:54 +0200 Subject: [PATCH 03/33] Revert formatting change --- src/wasm/wasm-binary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 323ebb7aa43..91f54ac8bbc 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2961,7 +2961,7 @@ void WasmBinaryReader::readSourceMapHeader() { } else { uint32_t fileIndex = readBase64VLQ(*sourceMap); uint32_t lineNumber = - readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number + readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number uint32_t columnNumber = readBase64VLQ(*sourceMap); std::optional nameIndex = std::nullopt; peek = sourceMap->peek(); From 3b986eb7cb05c6b8dad484b60707ae6f412a5bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 7 Aug 2024 09:31:39 +0200 Subject: [PATCH 04/33] Fix formatting --- scripts/clang-format-diff.sh | 3 +++ src/wasm.h | 12 +++++------- src/wasm/wasm-binary.cpp | 12 +++++------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/scripts/clang-format-diff.sh b/scripts/clang-format-diff.sh index d0046e8cd55..d2f0c032dcf 100755 --- a/scripts/clang-format-diff.sh +++ b/scripts/clang-format-diff.sh @@ -3,6 +3,9 @@ set -o errexit set -o pipefail +set -e +set -x + if [ -n "$1" ]; then BRANCH="$1" elif [ -n "$GITHUB_BASE_REF" ]; then diff --git a/src/wasm.h b/src/wasm.h index b3e1c5009c4..7287dbacc13 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2038,13 +2038,11 @@ class Function : public Importable { return !(*this == other); } bool operator<(const DebugLocation& other) const { - return fileIndex != other.fileIndex - ? fileIndex < other.fileIndex - : lineNumber != other.lineNumber - ? lineNumber < other.lineNumber - : columnNumber != other.columnNumber - ? columnNumber < other.columnNumber - : nameIndex < other.nameIndex; + return fileIndex != other.fileIndex ? fileIndex < other.fileIndex + : lineNumber != other.lineNumber ? lineNumber < other.lineNumber + : columnNumber != other.columnNumber + ? columnNumber < other.columnNumber + : nameIndex < other.nameIndex; } }; // One can explicitly set the debug location of an expression to diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 91f54ac8bbc..4b5e9183829 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1261,14 +1261,12 @@ void WasmBinaryWriter::writeSourceMapEpilog() { writeBase64VLQ(*sourceMap, int32_t(loc->lineNumber - lastLineNumber)); lastLineNumber = loc->lineNumber; - writeBase64VLQ(*sourceMap, - int32_t(loc->columnNumber - lastColumnNumber)); + writeBase64VLQ(*sourceMap, int32_t(loc->columnNumber - lastColumnNumber)); lastColumnNumber = loc->columnNumber; if (loc->nameIndex) { - writeBase64VLQ(*sourceMap, - int32_t(*loc->nameIndex - lastNameIndex)); - lastNameIndex = *loc->nameIndex; + writeBase64VLQ(*sourceMap, int32_t(*loc->nameIndex - lastNameIndex)); + lastNameIndex = *loc->nameIndex; } } } @@ -2966,7 +2964,7 @@ void WasmBinaryReader::readSourceMapHeader() { std::optional nameIndex = std::nullopt; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { - nameIndex = readBase64VLQ(*sourceMap); + nameIndex = readBase64VLQ(*sourceMap); } nextDebugLocation = {fileIndex, lineNumber, columnNumber, nameIndex}; nextDebugLocationHasDebugInfo = true; @@ -3026,7 +3024,7 @@ void WasmBinaryReader::readNextDebugLocation() { std::optional nameIndex = std::nullopt; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { - nameIndex = readBase64VLQ(*sourceMap); + nameIndex = readBase64VLQ(*sourceMap); } nextDebugLocation = {fileIndex, lineNumber, columnNumber, nameIndex}; From 9465b2ec18cbd302b393bf1d7db6985c018a70fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Mon, 16 Sep 2024 10:55:58 +0200 Subject: [PATCH 05/33] Revert debug change --- scripts/clang-format-diff.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/clang-format-diff.sh b/scripts/clang-format-diff.sh index d2f0c032dcf..d0046e8cd55 100755 --- a/scripts/clang-format-diff.sh +++ b/scripts/clang-format-diff.sh @@ -3,9 +3,6 @@ set -o errexit set -o pipefail -set -e -set -x - if [ -n "$1" ]; then BRANCH="$1" elif [ -n "$GITHUB_BASE_REF" ]; then From 4076b7a80ff007108a6aca3cb0ba0570f782ea96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Thu, 19 Sep 2024 16:08:17 +0200 Subject: [PATCH 06/33] Apply suggestions from code review Co-authored-by: Alon Zakai --- src/wasm/wasm-binary.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 71c6f8e6e5a..522c3fd1a51 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -2912,7 +2912,7 @@ void WasmBinaryReader::readSourceMapHeader() { uint32_t lineNumber = readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number uint32_t columnNumber = readBase64VLQ(*sourceMap); - std::optional nameIndex = std::nullopt; + std::optional nameIndex; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { nameIndex = readBase64VLQ(*sourceMap); @@ -2972,7 +2972,7 @@ void WasmBinaryReader::readNextDebugLocation() { int32_t columnNumberDelta = readBase64VLQ(*sourceMap); uint32_t columnNumber = nextDebugLocation.columnNumber + columnNumberDelta; - std::optional nameIndex = std::nullopt; + std::optional nameIndex; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { nameIndex = readBase64VLQ(*sourceMap); From 6171fe9157b5a1daab1245fef2b0f6e295b48a72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 10:15:40 +0200 Subject: [PATCH 07/33] Add test --- test/lit/source-map.wast | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/lit/source-map.wast b/test/lit/source-map.wast index f8ef07c65cc..9d2d9de2c37 100644 --- a/test/lit/source-map.wast +++ b/test/lit/source-map.wast @@ -110,4 +110,17 @@ ;;@ src.cpp:3 (nop) ) + + ;; CHECK: (func $5_segment_mappings + ;; CHECK-NEXT: ;;@ /tmp/src.cpp:1:1:a + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ;;@ ../src.cpp:2:2:b + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $5_segment_mappings + ;;@ /tmp/src.cpp:1:1:a + (nop) + ;;@ ../src.cpp:2:2:b + (nop) + ) ) From 0a9d25130d718898d3905930d6998bb644f09214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 10:53:37 +0200 Subject: [PATCH 08/33] Implement parsing and printing --- src/binaryen-c.cpp | 16 ++++++++++++++++ src/ir/module-utils.cpp | 2 ++ src/parser/contexts.h | 13 +++++++++++++ src/passes/Print.cpp | 9 ++++++++- src/wasm-binary.h | 1 + src/wasm.h | 1 + src/wasm/wasm-binary.cpp | 34 ++++++++++++++++++++++++++++++---- src/wasm/wasm.cpp | 5 ++++- 8 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 64462c35465..4079d7926d0 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -5662,6 +5662,14 @@ void BinaryenModuleInterpret(BinaryenModuleRef module) { ModuleRunner instance(*(Module*)module, &interface, {}); } +BinaryenIndex BinaryenModuleAddDebugInfoSymbolName(BinaryenModuleRef module, + const char* symbolname) { + auto& debugInfoSymbolNames = ((Module*)module)->debugInfoSymbolNames; + BinaryenIndex index = debugInfoSymbolNames.size(); + debugInfoSymbolNames.push_back(symbolname); + return index; +} + BinaryenIndex BinaryenModuleAddDebugInfoFileName(BinaryenModuleRef module, const char* filename) { auto& debugInfoFileNames = ((Module*)module)->debugInfoFileNames; @@ -5670,6 +5678,14 @@ BinaryenIndex BinaryenModuleAddDebugInfoFileName(BinaryenModuleRef module, return index; } +const char* BinaryenModuleGetDebugInfoSymbolName(BinaryenModuleRef module, + BinaryenIndex index) { + const auto& debugInfoSymbolNames = ((Module*)module)->debugInfoSymbolNames; + return index < debugInfoSymbolNames.size() + ? debugInfoSymbolNames.at(index).c_str() + : nullptr; +} + const char* BinaryenModuleGetDebugInfoFileName(BinaryenModuleRef module, BinaryenIndex index) { const auto& debugInfoFileNames = ((Module*)module)->debugInfoFileNames; diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 490955866b0..d8c95a70f81 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -181,6 +181,7 @@ void copyModuleItems(const Module& in, Module& out) { // to map file name indices from this modules to file name indices in // the target module. std::optional> fileIndexMap; + // TODO: Update this with symbol names if (!in.debugInfoFileNames.empty()) { std::unordered_map debugInfoFileIndices; for (Index i = 0; i < out.debugInfoFileNames.size(); i++) { @@ -241,6 +242,7 @@ void copyModule(const Module& in, Module& out) { out.start = in.start; out.customSections = in.customSections; out.debugInfoFileNames = in.debugInfoFileNames; + out.debugInfoSymbolNames = in.debugInfoSymbolNames; out.features = in.features; } diff --git a/src/parser/contexts.h b/src/parser/contexts.h index c6027eccea4..dc252326750 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1398,6 +1398,7 @@ struct ParseDefsCtx : TypeParserCtx { typeNames; const std::unordered_map& implicitElemIndices; + std::unordered_map debugSymbolNameIndices; std::unordered_map debugFileIndices; // The index of the current module element. @@ -1783,6 +1784,18 @@ struct ParseDefsCtx : TypeParserCtx { return; } + std::optional nameIndex; + auto namePos = contents.find(':'); + if (namePos != contents.npos) { + auto name = contents.substr(namePos + 1); + auto [it, inserted] = + debugSymbolNameIndices.insert({name, debugSymbolNameIndices.size()}); + if (inserted) { + assert(wasm.debugInfoSymbolNames.size() == it->second); + wasm.debugInfoSymbolNames.push_back(std::string(file)); + } + } + // TODO: If we ever parallelize the parse, access to // `wasm.debugInfoFileNames` will have to be protected by a lock. auto [it, inserted] = diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 427bff32905..690776d10c8 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2504,7 +2504,14 @@ void PrintSExpression::printDebugLocation( } else { auto fileName = currModule->debugInfoFileNames[location->fileIndex]; o << ";;@ " << fileName << ":" << location->lineNumber << ":" - << location->columnNumber << '\n'; + << location->columnNumber; + + if (location->nameIndex.has_value()) { + auto symbolName = currModule->debugInfoSymbolNames[*(location->nameIndex)]; + o << ":" << symbolName; + } + + o << '\n'; } doIndent(o, indent); } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 5021b6a297f..3b23101bdf7 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1670,6 +1670,7 @@ class WasmBinaryReader { // Debug information reading helpers void setDebugLocations(std::istream* sourceMap_) { sourceMap = sourceMap_; } std::unordered_map debugInfoFileIndices; + std::unordered_map debugInfoSymbolNameIndices; void readNextDebugLocation(); void readSourceMapHeader(); diff --git a/src/wasm.h b/src/wasm.h index 394c8e795c4..b7946517a06 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2297,6 +2297,7 @@ class Module { // Source maps debug info. std::vector debugInfoFileNames; + std::vector debugInfoSymbolNames; // `features` are the features allowed to be used in this module and should be // respected regardless of the value of`hasFeaturesSection`. diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 023077a57eb..781c60f226a 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1221,7 +1221,17 @@ void WasmBinaryWriter::writeSourceMapProlog() { // TODO respect JSON string encoding, e.g. quotes and control chars. *sourceMap << "\"" << wasm->debugInfoFileNames[i] << "\""; } - *sourceMap << "],\"names\":[],\"mappings\":\""; + *sourceMap << "],\"names\":["; + + for (size_t i = 0; i < wasm->debugInfoSymbolNames.size(); i++) { + if (i > 0) { + *sourceMap << ","; + } + // TODO respect JSON string encoding, e.g. quotes and control chars. + *sourceMap << "\"" << wasm->debugInfoSymbolNames[i] << "\""; + } + + *sourceMap << "],\"mappings\":\""; } static void writeBase64VLQ(std::ostream& out, int32_t n) { @@ -1236,9 +1246,10 @@ static void writeBase64VLQ(std::ostream& out, int32_t n) { } // more VLG digit will follow -- add continuation bit (0x20), // base64 codes 'g'..'z', '0'..'9', '+', '/' - out << char(digit < 20 - ? 'g' + digit - : digit < 30 ? '0' + digit - 20 : digit == 30 ? '+' : '/'); + out << char(digit < 20 ? 'g' + digit + : digit < 30 ? '0' + digit - 20 + : digit == 30 ? '+' + : '/'); } } @@ -2886,6 +2897,21 @@ void WasmBinaryReader::readSourceMapHeader() { mustReadChar(']'); } + if (findField("names")) { + skipWhitespace(); + mustReadChar('['); + if (!maybeReadChar(']')) { + do { + std::string symbol; + readString(symbol); + Index index = wasm.debugInfoSymbolNames.size(); + wasm.debugInfoSymbolNames.push_back(symbol); + debugInfoSymbolNameIndices[symbol] = index; + } while (maybeReadChar(',')); + mustReadChar(']'); + } + } + if (!findField("mappings")) { throw MapParseException("cannot find the 'mappings' field in map"); } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 87ae6ac5a38..f81bef85595 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1859,6 +1859,9 @@ void Module::updateMaps() { assert(tagsMap.size() == tags.size()); } -void Module::clearDebugInfo() { debugInfoFileNames.clear(); } +void Module::clearDebugInfo() { + debugInfoFileNames.clear(); + debugInfoSymbolNames.clear(); +} } // namespace wasm From 6858dacce33dd47d7509ac159f23c6bf9fc91433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 10:57:36 +0200 Subject: [PATCH 09/33] Format --- src/parser/contexts.h | 14 +++++++------- src/passes/Print.cpp | 5 +++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index dc252326750..67bd8a98821 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1787,13 +1787,13 @@ struct ParseDefsCtx : TypeParserCtx { std::optional nameIndex; auto namePos = contents.find(':'); if (namePos != contents.npos) { - auto name = contents.substr(namePos + 1); - auto [it, inserted] = - debugSymbolNameIndices.insert({name, debugSymbolNameIndices.size()}); - if (inserted) { - assert(wasm.debugInfoSymbolNames.size() == it->second); - wasm.debugInfoSymbolNames.push_back(std::string(file)); - } + auto name = contents.substr(namePos + 1); + auto [it, inserted] = + debugSymbolNameIndices.insert({name, debugSymbolNameIndices.size()}); + if (inserted) { + assert(wasm.debugInfoSymbolNames.size() == it->second); + wasm.debugInfoSymbolNames.push_back(std::string(file)); + } } // TODO: If we ever parallelize the parse, access to diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 690776d10c8..f50e4033822 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2507,8 +2507,9 @@ void PrintSExpression::printDebugLocation( << location->columnNumber; if (location->nameIndex.has_value()) { - auto symbolName = currModule->debugInfoSymbolNames[*(location->nameIndex)]; - o << ":" << symbolName; + auto symbolName = + currModule->debugInfoSymbolNames[*(location->nameIndex)]; + o << ":" << symbolName; } o << '\n'; From 4111ce866d9a6c1a7d010ae382777d289ea7000c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 11:04:36 +0200 Subject: [PATCH 10/33] Fix parsing --- src/parser/contexts.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 67bd8a98821..2bf4905c520 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1784,7 +1784,7 @@ struct ParseDefsCtx : TypeParserCtx { return; } - std::optional nameIndex; + std::optional symbolNameIndex; auto namePos = contents.find(':'); if (namePos != contents.npos) { auto name = contents.substr(namePos + 1); @@ -1794,6 +1794,7 @@ struct ParseDefsCtx : TypeParserCtx { assert(wasm.debugInfoSymbolNames.size() == it->second); wasm.debugInfoSymbolNames.push_back(std::string(file)); } + *symbolNameIndex = it->second; } // TODO: If we ever parallelize the parse, access to @@ -1805,7 +1806,7 @@ struct ParseDefsCtx : TypeParserCtx { wasm.debugInfoFileNames.push_back(std::string(file)); } irBuilder.setDebugLocation( - Function::DebugLocation({it->second, *line, *col, std::nullopt})); + Function::DebugLocation({it->second, *line, *col, symbolNameIndex})); } Result<> makeBlock(Index pos, From f92899c584c4ed01bad86c3ceca99f092079999b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 11:36:14 +0200 Subject: [PATCH 11/33] Fixes? --- src/ir/module-utils.cpp | 42 +++++++++++++++++++++++++++++++++++----- src/ir/module-utils.h | 14 ++++++++------ src/passes/Print.cpp | 4 ++-- src/wasm.h | 6 +++--- src/wasm/wasm-binary.cpp | 21 ++++++++++---------- 5 files changed, 61 insertions(+), 26 deletions(-) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index d8c95a70f81..4d513e80aad 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -45,8 +45,10 @@ static void updateLocationSet(std::set& locations, Function* copyFunction(Function* func, Module& out, Name newName, - std::optional> fileIndexMap) { - auto ret = copyFunctionWithoutAdd(func, out, newName, fileIndexMap); + std::optional> fileIndexMap, + std::optional> symbolNameIndexMap) { + auto ret = copyFunctionWithoutAdd( + func, out, newName, fileIndexMap, symbolNameIndexMap); return out.addFunction(std::move(ret)); } @@ -54,7 +56,8 @@ std::unique_ptr copyFunctionWithoutAdd(Function* func, Module& out, Name newName, - std::optional> fileIndexMap) { + std::optional> fileIndexMap, + std::optional> symbolNameIndexMap) { auto ret = std::make_unique(); ret->name = newName.is() ? newName : func->name; ret->hasExplicitName = func->hasExplicitName; @@ -76,6 +79,17 @@ copyFunctionWithoutAdd(Function* func, updateLocationSet(ret->prologLocation, *fileIndexMap); updateLocationSet(ret->epilogLocation, *fileIndexMap); } + if (symbolNameIndexMap) { + for (auto& iter : ret->debugLocations) { + if (iter.second) { + if (iter.second->symbolNameIndex.has_value()) { + iter.second->symbolNameIndex = + (*symbolNameIndexMap)[*(iter.second->symbolNameIndex)]; + } + } + } + // TODO: Do we need something like updateLocationSet here? + } ret->module = func->module; ret->base = func->base; ret->noFullInline = func->noFullInline; @@ -181,7 +195,6 @@ void copyModuleItems(const Module& in, Module& out) { // to map file name indices from this modules to file name indices in // the target module. std::optional> fileIndexMap; - // TODO: Update this with symbol names if (!in.debugInfoFileNames.empty()) { std::unordered_map debugInfoFileIndices; for (Index i = 0; i < out.debugInfoFileNames.size(); i++) { @@ -200,8 +213,27 @@ void copyModuleItems(const Module& in, Module& out) { } } + std::optional> symbolNameIndexMap; + if (!in.debugInfoSymbolNames.empty()) { + std::unordered_map debugInfoSymbolNameIndices; + for (Index i = 0; i < out.debugInfoSymbolNames.size(); i++) { + debugInfoSymbolNameIndices[out.debugInfoSymbolNames[i]] = i; + } + symbolNameIndexMap.emplace(); + for (Index i = 0; i < in.debugInfoSymbolNames.size(); i++) { + std::string file = in.debugInfoSymbolNames[i]; + auto iter = debugInfoSymbolNameIndices.find(file); + if (iter == debugInfoSymbolNameIndices.end()) { + Index index = out.debugInfoSymbolNames.size(); + out.debugInfoSymbolNames.push_back(file); + debugInfoSymbolNameIndices[file] = index; + } + symbolNameIndexMap->push_back(debugInfoSymbolNameIndices[file]); + } + } + for (auto& curr : in.functions) { - copyFunction(curr.get(), out, Name(), fileIndexMap); + copyFunction(curr.get(), out, Name(), fileIndexMap, symbolNameIndexMap); } for (auto& curr : in.globals) { copyGlobal(curr.get(), out); diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 46e52416538..a4f3dfdaad4 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -28,18 +28,20 @@ namespace wasm::ModuleUtils { // name of the function (otherwise the original name is copied). If fileIndexMap // is specified, it is used to rename source map filename indices when copying // the function from one module to another one. -Function* -copyFunction(Function* func, - Module& out, - Name newName = Name(), - std::optional> fileIndexMap = std::nullopt); +Function* copyFunction( + Function* func, + Module& out, + Name newName = Name(), + std::optional> fileIndexMap = std::nullopt, + std::optional> symbolNameIndexMap = std::nullopt); // As above, but does not add the copy to the module. std::unique_ptr copyFunctionWithoutAdd( Function* func, Module& out, Name newName = Name(), - std::optional> fileIndexMap = std::nullopt); + std::optional> fileIndexMap = std::nullopt, + std::optional> symbolNameIndexMap = std::nullopt); Global* copyGlobal(Global* global, Module& out); diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index f50e4033822..65d28a1ead2 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2506,9 +2506,9 @@ void PrintSExpression::printDebugLocation( o << ";;@ " << fileName << ":" << location->lineNumber << ":" << location->columnNumber; - if (location->nameIndex.has_value()) { + if (location->symbolNameIndex.has_value()) { auto symbolName = - currModule->debugInfoSymbolNames[*(location->nameIndex)]; + currModule->debugInfoSymbolNames[*(location->symbolNameIndex)]; o << ":" << symbolName; } diff --git a/src/wasm.h b/src/wasm.h index b7946517a06..79e0495618b 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2072,10 +2072,10 @@ class Function : public Importable { // Source maps debugging info: map expression nodes to their file, line, col. struct DebugLocation { BinaryLocation fileIndex, lineNumber, columnNumber; - std::optional nameIndex; + std::optional symbolNameIndex; bool operator==(const DebugLocation& other) const { return fileIndex == other.fileIndex && lineNumber == other.lineNumber && - columnNumber == other.columnNumber && nameIndex == other.nameIndex; + columnNumber == other.columnNumber && symbolNameIndex == other.symbolNameIndex; } bool operator!=(const DebugLocation& other) const { return !(*this == other); @@ -2085,7 +2085,7 @@ class Function : public Importable { : lineNumber != other.lineNumber ? lineNumber < other.lineNumber : columnNumber != other.columnNumber ? columnNumber < other.columnNumber - : nameIndex < other.nameIndex; + : symbolNameIndex < other.symbolNameIndex; } }; // One can explicitly set the debug location of an expression to diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 781c60f226a..2f9c9f87e71 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1259,7 +1259,7 @@ void WasmBinaryWriter::writeSourceMapEpilog() { BinaryLocation lastFileIndex = 0; BinaryLocation lastLineNumber = 1; BinaryLocation lastColumnNumber = 0; - BinaryLocation lastNameIndex = 0; + BinaryLocation lastSymbolNameIndex = 0; for (const auto& [offset, loc] : sourceMapLocations) { if (lastOffset > 0) { *sourceMap << ","; @@ -1276,9 +1276,10 @@ void WasmBinaryWriter::writeSourceMapEpilog() { writeBase64VLQ(*sourceMap, int32_t(loc->columnNumber - lastColumnNumber)); lastColumnNumber = loc->columnNumber; - if (loc->nameIndex) { - writeBase64VLQ(*sourceMap, int32_t(*loc->nameIndex - lastNameIndex)); - lastNameIndex = *loc->nameIndex; + if (loc->symbolNameIndex) { + writeBase64VLQ(*sourceMap, + int32_t(*loc->symbolNameIndex - lastSymbolNameIndex)); + lastSymbolNameIndex = *loc->symbolNameIndex; } } } @@ -2938,12 +2939,12 @@ void WasmBinaryReader::readSourceMapHeader() { uint32_t lineNumber = readBase64VLQ(*sourceMap) + 1; // adjust zero-based line number uint32_t columnNumber = readBase64VLQ(*sourceMap); - std::optional nameIndex; + std::optional symbolNameIndex; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { - nameIndex = readBase64VLQ(*sourceMap); + symbolNameIndex = readBase64VLQ(*sourceMap); } - nextDebugLocation = {fileIndex, lineNumber, columnNumber, nameIndex}; + nextDebugLocation = {fileIndex, lineNumber, columnNumber, symbolNameIndex}; nextDebugLocationHasDebugInfo = true; } } @@ -2998,13 +2999,13 @@ void WasmBinaryReader::readNextDebugLocation() { int32_t columnNumberDelta = readBase64VLQ(*sourceMap); uint32_t columnNumber = nextDebugLocation.columnNumber + columnNumberDelta; - std::optional nameIndex; + std::optional symbolNameIndex; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { - nameIndex = readBase64VLQ(*sourceMap); + symbolNameIndex = readBase64VLQ(*sourceMap); } - nextDebugLocation = {fileIndex, lineNumber, columnNumber, nameIndex}; + nextDebugLocation = {fileIndex, lineNumber, columnNumber, symbolNameIndex}; nextDebugLocationHasDebugInfo = true; } } From 8675c238b6eb43a648e820c93c555685fe3d9b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 11:43:50 +0200 Subject: [PATCH 12/33] Revert lit test, wasm-opt doesn't generate symbol names --- test/lit/source-map.wast | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/lit/source-map.wast b/test/lit/source-map.wast index 9d2d9de2c37..f8ef07c65cc 100644 --- a/test/lit/source-map.wast +++ b/test/lit/source-map.wast @@ -110,17 +110,4 @@ ;;@ src.cpp:3 (nop) ) - - ;; CHECK: (func $5_segment_mappings - ;; CHECK-NEXT: ;;@ /tmp/src.cpp:1:1:a - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ;;@ ../src.cpp:2:2:b - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ) - (func $5_segment_mappings - ;;@ /tmp/src.cpp:1:1:a - (nop) - ;;@ ../src.cpp:2:2:b - (nop) - ) ) From 8a35d1675d01250a1b8582cca3e6d4fabcfdde80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 20 Sep 2024 11:44:19 +0200 Subject: [PATCH 13/33] Fix formatting --- src/wasm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wasm.h b/src/wasm.h index 79e0495618b..7e183bfc3ec 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2075,7 +2075,8 @@ class Function : public Importable { std::optional symbolNameIndex; bool operator==(const DebugLocation& other) const { return fileIndex == other.fileIndex && lineNumber == other.lineNumber && - columnNumber == other.columnNumber && symbolNameIndex == other.symbolNameIndex; + columnNumber == other.columnNumber && + symbolNameIndex == other.symbolNameIndex; } bool operator!=(const DebugLocation& other) const { return !(*this == other); From 56abcb580422c1168ddbe781d379d7002b73f729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 12:25:31 +0200 Subject: [PATCH 14/33] Fix wat parsing --- src/parser/contexts.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 2bf4905c520..8fa33cfaed3 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1778,16 +1778,26 @@ struct ParseDefsCtx : TypeParserCtx { } contents = contents.substr(lineSize + 1); - lexer = Lexer(contents); + auto colSize = contents.find(':'); + auto rest = std::string_view(); + if (colSize == contents.npos) { + colSize = contents.size(); + if (colSize == 0) { + return; + } + } else { + rest = contents.substr(colSize + 1); + } + lexer = Lexer(contents.substr(0, colSize)); auto col = lexer.takeU32(); - if (!col || !lexer.empty()) { + if (!col && !lexer.empty()) { return; } + contents = rest; std::optional symbolNameIndex; - auto namePos = contents.find(':'); - if (namePos != contents.npos) { - auto name = contents.substr(namePos + 1); + if (!contents.empty()) { + auto name = contents; auto [it, inserted] = debugSymbolNameIndices.insert({name, debugSymbolNameIndices.size()}); if (inserted) { From 70137075ecd2d5f998cf769a992618a231830b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 12:27:36 +0200 Subject: [PATCH 15/33] Fix wat parsing a little bit more --- src/parser/contexts.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 8fa33cfaed3..46f64796d5d 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1797,12 +1797,12 @@ struct ParseDefsCtx : TypeParserCtx { std::optional symbolNameIndex; if (!contents.empty()) { - auto name = contents; + auto symbolName = contents; auto [it, inserted] = - debugSymbolNameIndices.insert({name, debugSymbolNameIndices.size()}); + debugSymbolNameIndices.insert({symbolName, debugSymbolNameIndices.size()}); if (inserted) { assert(wasm.debugInfoSymbolNames.size() == it->second); - wasm.debugInfoSymbolNames.push_back(std::string(file)); + wasm.debugInfoSymbolNames.push_back(std::string(symbolName)); } *symbolNameIndex = it->second; } From cd2ac9d4775727697dd1a1e3f7a3a81c8a3e2514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 13:40:27 +0200 Subject: [PATCH 16/33] Fix wat parsing even more --- src/parser/contexts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 46f64796d5d..206dde43898 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1804,7 +1804,7 @@ struct ParseDefsCtx : TypeParserCtx { assert(wasm.debugInfoSymbolNames.size() == it->second); wasm.debugInfoSymbolNames.push_back(std::string(symbolName)); } - *symbolNameIndex = it->second; + symbolNameIndex = it->second; } // TODO: If we ever parallelize the parse, access to From f70be710a64674f48f2241869826995595e922f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 13:41:39 +0200 Subject: [PATCH 17/33] Update lit test --- test/lit/source-map.wast | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/lit/source-map.wast b/test/lit/source-map.wast index f8ef07c65cc..b342ef68651 100644 --- a/test/lit/source-map.wast +++ b/test/lit/source-map.wast @@ -110,4 +110,21 @@ ;;@ src.cpp:3 (nop) ) + + ;; CHECK: (func $symbolNames + ;; CHECK-NEXT: ;;@ /tmp/src.cpp:1:1:MyClass.myMethod + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ;;@ ../src.cpp:2:2:MyClass::myMethod + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ;;@ café.cpp:2:2:MyClass::myMethod + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $symbolNames + ;;@ /tmp/src.cpp:1:1:MyClass.myMethod + (nop) + ;;@ ../src.cpp:2:2:MyClass::myMethod + (nop) + ;;@ café.cpp:2:2:topLevelFunction + (nop) + ) ) From ef71d8152b5ef44086025e21e99a87910fa88001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 14:12:27 +0200 Subject: [PATCH 18/33] Fix symbol name index updates --- src/wasm/wasm-binary.cpp | 3 ++- test/lit/source-map.wast | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 2f9c9f87e71..207ba0742db 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -3002,7 +3002,8 @@ void WasmBinaryReader::readNextDebugLocation() { std::optional symbolNameIndex; peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { - symbolNameIndex = readBase64VLQ(*sourceMap); + int32_t symbolNameIndexDelta = readBase64VLQ(*sourceMap); + symbolNameIndex = nextDebugLocation.symbolNameIndex.value_or(0) + symbolNameIndexDelta; } nextDebugLocation = {fileIndex, lineNumber, columnNumber, symbolNameIndex}; diff --git a/test/lit/source-map.wast b/test/lit/source-map.wast index b342ef68651..54121b0f22f 100644 --- a/test/lit/source-map.wast +++ b/test/lit/source-map.wast @@ -116,7 +116,7 @@ ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ;;@ ../src.cpp:2:2:MyClass::myMethod ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ;;@ café.cpp:2:2:MyClass::myMethod + ;; CHECK-NEXT: ;;@ café.cpp:2:2:topLevelFunction ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $symbolNames From 7e284edfbf13cc684a21a656f607683ec452195b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 14:14:07 +0200 Subject: [PATCH 19/33] Improve test --- test/lit/source-map.wast | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/lit/source-map.wast b/test/lit/source-map.wast index 54121b0f22f..b4fc55374a5 100644 --- a/test/lit/source-map.wast +++ b/test/lit/source-map.wast @@ -112,19 +112,19 @@ ) ;; CHECK: (func $symbolNames - ;; CHECK-NEXT: ;;@ /tmp/src.cpp:1:1:MyClass.myMethod + ;; CHECK-NEXT: ;;@ /tmp/src.cpp:1:2:MyClass.myMethod ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ;;@ ../src.cpp:2:2:MyClass::myMethod + ;; CHECK-NEXT: ;;@ ../src.cpp:3:4:MyClass::myMethod ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ;;@ café.cpp:2:2:topLevelFunction + ;; CHECK-NEXT: ;;@ café.cpp:5:6:topLevelFunction ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) (func $symbolNames - ;;@ /tmp/src.cpp:1:1:MyClass.myMethod + ;;@ /tmp/src.cpp:1:2:MyClass.myMethod (nop) - ;;@ ../src.cpp:2:2:MyClass::myMethod + ;;@ ../src.cpp:3:4:MyClass::myMethod (nop) - ;;@ café.cpp:2:2:topLevelFunction + ;;@ café.cpp:5:6:topLevelFunction (nop) ) ) From c18d33900a20847fd56e013f281576660d5f8be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Wed, 25 Sep 2024 14:17:04 +0200 Subject: [PATCH 20/33] Formatting --- src/parser/contexts.h | 4 ++-- src/wasm/wasm-binary.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 206dde43898..a999e6f9d54 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1798,8 +1798,8 @@ struct ParseDefsCtx : TypeParserCtx { std::optional symbolNameIndex; if (!contents.empty()) { auto symbolName = contents; - auto [it, inserted] = - debugSymbolNameIndices.insert({symbolName, debugSymbolNameIndices.size()}); + auto [it, inserted] = debugSymbolNameIndices.insert( + {symbolName, debugSymbolNameIndices.size()}); if (inserted) { assert(wasm.debugInfoSymbolNames.size() == it->second); wasm.debugInfoSymbolNames.push_back(std::string(symbolName)); diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 207ba0742db..ac931bdc129 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -3003,7 +3003,8 @@ void WasmBinaryReader::readNextDebugLocation() { peek = sourceMap->peek(); if (!(peek == ',' || peek == '\"')) { int32_t symbolNameIndexDelta = readBase64VLQ(*sourceMap); - symbolNameIndex = nextDebugLocation.symbolNameIndex.value_or(0) + symbolNameIndexDelta; + symbolNameIndex = + nextDebugLocation.symbolNameIndex.value_or(0) + symbolNameIndexDelta; } nextDebugLocation = {fileIndex, lineNumber, columnNumber, symbolNameIndex}; From 7b5935832aada5e4755adebe214058a437d20386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Thu, 26 Sep 2024 13:53:56 +0200 Subject: [PATCH 21/33] Refactor weird code --- src/parser/contexts.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index a999e6f9d54..68bd600e5de 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1790,7 +1790,7 @@ struct ParseDefsCtx : TypeParserCtx { } lexer = Lexer(contents.substr(0, colSize)); auto col = lexer.takeU32(); - if (!col && !lexer.empty()) { + if (!col) { return; } contents = rest; From c96ad9a58d0d1263841a22d49b3ea00972b12d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Thu, 26 Sep 2024 13:57:43 +0200 Subject: [PATCH 22/33] Implement a TODO --- src/ir/module-utils.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 4d513e80aad..7710364f7bf 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -38,6 +38,20 @@ static void updateLocationSet(std::set& locations, std::swap(locations, updatedLocations); } +static void updateSymbolSet(std::set& locations, + std::vector& symbolIndexMap) { + std::set updatedLocations; + + for (auto iter : locations) { + if (iter.symbolNameIndex.has_value()) { + iter.symbolNameIndex = symbolIndexMap[*iter.symbolNameIndex]; + } + updatedLocations.insert(iter); + } + locations.clear(); + std::swap(locations, updatedLocations); +} + // Copies a function into a module. If newName is provided it is used as the // name of the function (otherwise the original name is copied). If fileIndexMap // is specified, it is used to rename source map filename indices when copying @@ -87,8 +101,9 @@ copyFunctionWithoutAdd(Function* func, (*symbolNameIndexMap)[*(iter.second->symbolNameIndex)]; } } + updateSymbolSet(ret->prologLocation, *symbolNameIndexMap); + updateSymbolSet(ret->epilogLocation, *symbolNameIndexMap); } - // TODO: Do we need something like updateLocationSet here? } ret->module = func->module; ret->base = func->base; From 25e1d80eceaf7b55a89ffff9518a2bf8b83ba0b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 27 Sep 2024 10:55:27 +0200 Subject: [PATCH 23/33] Update merge test --- test/lit/merge/sourcemap.wat | 22 +++++++++++----------- test/lit/merge/sourcemap.wat.second | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/test/lit/merge/sourcemap.wat b/test/lit/merge/sourcemap.wat index 8ccb373998d..1eec0bcbe8c 100644 --- a/test/lit/merge/sourcemap.wat +++ b/test/lit/merge/sourcemap.wat @@ -9,11 +9,11 @@ ;; Test that sourcemap information is preserved (module - ;;@ a:1:1 + ;;@ a:1:2 (func (export "f") - ;;@ a:2:1 + ;;@ a:3:4:myFunction (nop) - ;;@ a:3:1 + ;;@ a:5:6 ) ) ;; CHECK-TEXT: (type $0 (func)) @@ -23,15 +23,15 @@ ;; CHECK-TEXT: (export "g" (func $0_1)) ;; CHECK-TEXT: (func $0 -;; CHECK-TEXT-NEXT: ;;@ a:2:1 +;; CHECK-TEXT-NEXT: ;;@ a:3:4:myFunction ;; CHECK-TEXT-NEXT: (nop) -;; CHECK-TEXT-NEXT: ;;@ a:3:1 +;; CHECK-TEXT-NEXT: ;;@ a:5:6 ;; CHECK-TEXT-NEXT: ) ;; CHECK-TEXT: (func $0_1 -;; CHECK-TEXT-NEXT: ;;@ b:2:2 +;; CHECK-TEXT-NEXT: ;;@ b:9:10:MyClass::g ;; CHECK-TEXT-NEXT: (nop) -;; CHECK-TEXT-NEXT: ;;@ b:3:2 +;; CHECK-TEXT-NEXT: ;;@ b:11:12 ;; CHECK-TEXT-NEXT: ) ;; CHECK-BIN: (type $0 (func)) @@ -41,13 +41,13 @@ ;; CHECK-BIN: (export "g" (func $1)) ;; CHECK-BIN: (func $0 -;; CHECK-BIN-NEXT: ;;@ a:2:1 +;; CHECK-BIN-NEXT: ;;@ a:3:4:myFunction ;; CHECK-BIN-NEXT: (nop) -;; CHECK-BIN-NEXT: ;;@ a:3:1 +;; CHECK-BIN-NEXT: ;;@ a:5:6 ;; CHECK-BIN-NEXT: ) ;; CHECK-BIN: (func $1 -;; CHECK-BIN-NEXT: ;;@ b:2:2 +;; CHECK-BIN-NEXT: ;;@ b:9:10:MyClass::g ;; CHECK-BIN-NEXT: (nop) -;; CHECK-BIN-NEXT: ;;@ b:3:2 +;; CHECK-BIN-NEXT: ;;@ b:11:12 ;; CHECK-BIN-NEXT: ) diff --git a/test/lit/merge/sourcemap.wat.second b/test/lit/merge/sourcemap.wat.second index 0ea7c75fa03..3f1c110da8f 100644 --- a/test/lit/merge/sourcemap.wat.second +++ b/test/lit/merge/sourcemap.wat.second @@ -1,8 +1,8 @@ (module - ;;@ b:1:2 + ;;@ b:7:8 (func (export "g") - ;;@ b:2:2 + ;;@ b:9:10:MyClass::g (nop) - ;;@ b:3:2 + ;;@ b:11:12 ) ) From 95e24c760a4eff1b5bc9f22ac05ca2467cb44bcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 27 Sep 2024 10:57:37 +0200 Subject: [PATCH 24/33] Update metadce test --- test/lit/metadce/sourcemap.wat | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/lit/metadce/sourcemap.wat b/test/lit/metadce/sourcemap.wat index 8a73a01da57..0190fe557da 100644 --- a/test/lit/metadce/sourcemap.wat +++ b/test/lit/metadce/sourcemap.wat @@ -7,20 +7,20 @@ ;; Test that sourcemap information is preserved (module - ;;@ a:1:1 + ;;@ a:1:2 ;; TXT: (type $0 (func)) ;; TXT: (export "f" (func $f)) ;; TXT: (func $f - ;; TXT-NEXT: ;;@ a:2:1 + ;; TXT-NEXT: ;;@ a:7:8:someSymbol ;; TXT-NEXT: (nop) - ;; TXT-NEXT: ;;@ a:3:1 + ;; TXT-NEXT: ;;@ a:9:10 ;; TXT-NEXT: ) (func $f (export "f") - ;;@ a:2:1 + ;;@ a:7:8:someSymbol (nop) - ;;@ a:3:1 + ;;@ a:9:10 ) ) ;; BIN: (type $0 (func)) @@ -28,7 +28,7 @@ ;; BIN: (export "f" (func $0)) ;; BIN: (func $0 -;; BIN-NEXT: ;;@ a:2:1 +;; BIN-NEXT: ;;@ a:7:8:someSymbol ;; BIN-NEXT: (nop) -;; BIN-NEXT: ;;@ a:3:1 +;; BIN-NEXT: ;;@ a:9:10 ;; BIN-NEXT: ) From 5dac139e0d61c9fc8acd0e8004ee405570e1a360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 27 Sep 2024 11:31:57 +0200 Subject: [PATCH 25/33] Add inlining test --- test/lit/passes/inlining_source-maps.wast | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test/lit/passes/inlining_source-maps.wast diff --git a/test/lit/passes/inlining_source-maps.wast b/test/lit/passes/inlining_source-maps.wast new file mode 100644 index 00000000000..9dcaab144f2 --- /dev/null +++ b/test/lit/passes/inlining_source-maps.wast @@ -0,0 +1,40 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; RUN: foreach %s %t wasm-opt --inlining --all-features -S -o - | filecheck %s + +(module + ;; CHECK: (type $0 (func)) + + ;; CHECK: (start $2) + (start $2) + + (func $0 + ;;@ foo.cpp:1:2 + (nop) + ) + + (func $1 + ;;@ bar.cpp:3:4:MyFunction + (nop) + ) + + ;; CHECK: (func $2 (type $0) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (block $__inlined_func$0 + ;; CHECK-NEXT: ;;@ foo.cpp:1:2 + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ;;@ + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (block $__inlined_func$1$1 + ;; CHECK-NEXT: ;;@ bar.cpp:3:4:MyFunction + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $2 + (call $0) + (call $1) + ) +) From 836d387446f28f9824da1c629d1ba49c8ecbf00a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 27 Sep 2024 11:40:14 +0200 Subject: [PATCH 26/33] Revert formatting change --- src/wasm/wasm-binary.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 08440a1ca99..b339421e2b5 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1246,10 +1246,9 @@ static void writeBase64VLQ(std::ostream& out, int32_t n) { } // more VLG digit will follow -- add continuation bit (0x20), // base64 codes 'g'..'z', '0'..'9', '+', '/' - out << char(digit < 20 ? 'g' + digit - : digit < 30 ? '0' + digit - 20 - : digit == 30 ? '+' - : '/'); + out << char(digit < 20 + ? 'g' + digit + : digit < 30 ? '0' + digit - 20 : digit == 30 ? '+' : '/'); } } From 1c4157cffe33ff63e7d52144b5ac63b85f8f9edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Fri, 27 Sep 2024 12:02:43 +0200 Subject: [PATCH 27/33] Update lit output --- test/lit/passes/inlining_source-maps.wast | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/test/lit/passes/inlining_source-maps.wast b/test/lit/passes/inlining_source-maps.wast index 9dcaab144f2..5b5549986b9 100644 --- a/test/lit/passes/inlining_source-maps.wast +++ b/test/lit/passes/inlining_source-maps.wast @@ -19,18 +19,14 @@ ) ;; CHECK: (func $2 (type $0) - ;; CHECK-NEXT: (block - ;; CHECK-NEXT: (block $__inlined_func$0 - ;; CHECK-NEXT: ;;@ foo.cpp:1:2 - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $__inlined_func$0 + ;; CHECK-NEXT: ;;@ foo.cpp:1:2 + ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ;;@ - ;; CHECK-NEXT: (block - ;; CHECK-NEXT: (block $__inlined_func$1$1 - ;; CHECK-NEXT: ;;@ bar.cpp:3:4:MyFunction - ;; CHECK-NEXT: (nop) - ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $__inlined_func$1$1 + ;; CHECK-NEXT: ;;@ bar.cpp:3:4:MyFunction + ;; CHECK-NEXT: (nop) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $2 From 0098182219fb9fba66db9b96c12d902cf67f9c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 1 Oct 2024 09:48:02 +0200 Subject: [PATCH 28/33] Address some of the comments --- src/ir/module-utils.cpp | 4 +++- src/ir/module-utils.h | 6 +++--- src/passes/Print.cpp | 2 +- src/wasm.h | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 7710364f7bf..45d915a4603 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -38,12 +38,14 @@ static void updateLocationSet(std::set& locations, std::swap(locations, updatedLocations); } +// Update the symbol name indices when moving a set of debug locations from one +// module to another. static void updateSymbolSet(std::set& locations, std::vector& symbolIndexMap) { std::set updatedLocations; for (auto iter : locations) { - if (iter.symbolNameIndex.has_value()) { + if (iter.symbolNameIndex) { iter.symbolNameIndex = symbolIndexMap[*iter.symbolNameIndex]; } updatedLocations.insert(iter); diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index a4f3dfdaad4..7cb3492c61b 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -25,9 +25,9 @@ namespace wasm::ModuleUtils { // Copies a function into a module. If newName is provided it is used as the -// name of the function (otherwise the original name is copied). If fileIndexMap -// is specified, it is used to rename source map filename indices when copying -// the function from one module to another one. +// name of the function (otherwise the original name is copied). When specified, +// fileIndexMap and symbolNameIndexMap are used to rename source map filename +// and symbol name indices when copying the function from one module to another one. Function* copyFunction( Function* func, Module& out, diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 3c3239cc737..106beac39be 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2518,7 +2518,7 @@ void PrintSExpression::printDebugLocation( o << ";;@ " << fileName << ":" << location->lineNumber << ":" << location->columnNumber; - if (location->symbolNameIndex.has_value()) { + if (location->symbolNameIndex) { auto symbolName = currModule->debugInfoSymbolNames[*(location->symbolNameIndex)]; o << ":" << symbolName; diff --git a/src/wasm.h b/src/wasm.h index 3cbdc21f76f..4901723fd59 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -2073,7 +2073,8 @@ class Function : public Importable { std::unordered_map localNames; std::unordered_map localIndices; - // Source maps debugging info: map expression nodes to their file, line, col. + // Source maps debugging info: map expression nodes to their file, line, col, + // symbol name. struct DebugLocation { BinaryLocation fileIndex, lineNumber, columnNumber; std::optional symbolNameIndex; From 415bb882a185b07d6ce656faf05d952207a61905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 1 Oct 2024 10:02:35 +0200 Subject: [PATCH 29/33] Formatting --- src/ir/module-utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ir/module-utils.h b/src/ir/module-utils.h index 7cb3492c61b..bb8b6ae439d 100644 --- a/src/ir/module-utils.h +++ b/src/ir/module-utils.h @@ -27,7 +27,8 @@ namespace wasm::ModuleUtils { // Copies a function into a module. If newName is provided it is used as the // name of the function (otherwise the original name is copied). When specified, // fileIndexMap and symbolNameIndexMap are used to rename source map filename -// and symbol name indices when copying the function from one module to another one. +// and symbol name indices when copying the function from one module to another +// one. Function* copyFunction( Function* func, Module& out, From 2f8cf687134d7b0f6b1c6e1319e5d68981a61c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 1 Oct 2024 10:23:14 +0200 Subject: [PATCH 30/33] Remove local --- src/parser/contexts.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/parser/contexts.h b/src/parser/contexts.h index 68bd600e5de..b0cd1458bb6 100644 --- a/src/parser/contexts.h +++ b/src/parser/contexts.h @@ -1779,24 +1779,21 @@ struct ParseDefsCtx : TypeParserCtx { contents = contents.substr(lineSize + 1); auto colSize = contents.find(':'); - auto rest = std::string_view(); if (colSize == contents.npos) { colSize = contents.size(); if (colSize == 0) { return; } - } else { - rest = contents.substr(colSize + 1); } lexer = Lexer(contents.substr(0, colSize)); auto col = lexer.takeU32(); if (!col) { return; } - contents = rest; std::optional symbolNameIndex; - if (!contents.empty()) { + if (colSize != contents.size()) { + contents = contents.substr(colSize + 1); auto symbolName = contents; auto [it, inserted] = debugSymbolNameIndices.insert( {symbolName, debugSymbolNameIndices.size()}); From 8a9ee2d24bd96ef0d18d304138a94dd34b4c44fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 1 Oct 2024 22:05:37 +0200 Subject: [PATCH 31/33] Revert C API changes --- src/binaryen-c.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 4079d7926d0..64462c35465 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -5662,14 +5662,6 @@ void BinaryenModuleInterpret(BinaryenModuleRef module) { ModuleRunner instance(*(Module*)module, &interface, {}); } -BinaryenIndex BinaryenModuleAddDebugInfoSymbolName(BinaryenModuleRef module, - const char* symbolname) { - auto& debugInfoSymbolNames = ((Module*)module)->debugInfoSymbolNames; - BinaryenIndex index = debugInfoSymbolNames.size(); - debugInfoSymbolNames.push_back(symbolname); - return index; -} - BinaryenIndex BinaryenModuleAddDebugInfoFileName(BinaryenModuleRef module, const char* filename) { auto& debugInfoFileNames = ((Module*)module)->debugInfoFileNames; @@ -5678,14 +5670,6 @@ BinaryenIndex BinaryenModuleAddDebugInfoFileName(BinaryenModuleRef module, return index; } -const char* BinaryenModuleGetDebugInfoSymbolName(BinaryenModuleRef module, - BinaryenIndex index) { - const auto& debugInfoSymbolNames = ((Module*)module)->debugInfoSymbolNames; - return index < debugInfoSymbolNames.size() - ? debugInfoSymbolNames.at(index).c_str() - : nullptr; -} - const char* BinaryenModuleGetDebugInfoFileName(BinaryenModuleRef module, BinaryenIndex index) { const auto& debugInfoFileNames = ((Module*)module)->debugInfoFileNames; From c54b226a7b45819ae8937a9f46a0cacd16780792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 1 Oct 2024 22:40:19 +0200 Subject: [PATCH 32/33] Update comment --- src/ir/module-utils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index 45d915a4603..b3ea37bd15f 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -57,6 +57,8 @@ static void updateSymbolSet(std::set& locations, // Copies a function into a module. If newName is provided it is used as the // name of the function (otherwise the original name is copied). If fileIndexMap // is specified, it is used to rename source map filename indices when copying +// the function from one module to another one. If symbolNameINdexMap is +// specified, it is used to rename source map symbol name indices when copying // the function from one module to another one. Function* copyFunction(Function* func, Module& out, From a721d7238c6b2a49850b41c7af7cd6d4a2a7241f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Tue, 1 Oct 2024 22:40:35 +0200 Subject: [PATCH 33/33] Fix typo --- src/ir/module-utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index b3ea37bd15f..2f26cfa779c 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -57,7 +57,7 @@ static void updateSymbolSet(std::set& locations, // Copies a function into a module. If newName is provided it is used as the // name of the function (otherwise the original name is copied). If fileIndexMap // is specified, it is used to rename source map filename indices when copying -// the function from one module to another one. If symbolNameINdexMap is +// the function from one module to another one. If symbolNameIndexMap is // specified, it is used to rename source map symbol name indices when copying // the function from one module to another one. Function* copyFunction(Function* func,