diff options
author | Heejin Ahn <aheejin@gmail.com> | 2021-10-14 12:53:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-14 12:53:19 -0700 |
commit | 57e616595c158437b1739dbedb07c86c35d37b26 (patch) | |
tree | 52b9f400674534f730c64c70a8c25215ea5cb077 /src | |
parent | 805534eee318012ce0c26d323335e5a9cb132267 (diff) | |
download | binaryen-57e616595c158437b1739dbedb07c86c35d37b26.tar.gz binaryen-57e616595c158437b1739dbedb07c86c35d37b26.tar.bz2 binaryen-57e616595c158437b1739dbedb07c86c35d37b26.zip |
[wasm-metadce] Don't add null names to roots (#4246)
Not sure why the current code tries to add the name even when it is
null, but it causes `dump()` to behave strangely and pollute stdout when
it tries to print `root.str`.
Also this changes code printing `Name.str` to printing just `Name`; when
`Name.str` is null, it prints `(null Name)` instead of polluting stdout,
and it is the recommended way of printing `Name` anyway.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/wasm-metadce.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/tools/wasm-metadce.cpp b/src/tools/wasm-metadce.cpp index 026b6ad32..23a2d0fcc 100644 --- a/src/tools/wasm-metadce.cpp +++ b/src/tools/wasm-metadce.cpp @@ -209,9 +209,7 @@ struct MetaDCEGraph { // it's an import. dceName = parent->importIdToDCENode[parent->getGlobalImportId(name)]; } - if (parentDceName.isNull()) { - parent->roots.insert(parentDceName); - } else { + if (!parentDceName.isNull()) { parent->nodes[parentDceName].reaches.push_back(dceName); } } @@ -368,7 +366,7 @@ public: void dump() { std::cout << "=== graph ===\n"; for (auto root : roots) { - std::cout << "root: " << root.str << '\n'; + std::cout << "root: " << root << '\n'; } std::map<Name, ImportId> importMap; for (auto& pair : importIdToDCENode) { @@ -379,12 +377,12 @@ public: for (auto& pair : nodes) { auto name = pair.first; auto& node = pair.second; - std::cout << "node: " << name.str << '\n'; + std::cout << "node: " << name << '\n'; if (importMap.find(name) != importMap.end()) { std::cout << " is import " << importMap[name] << '\n'; } if (DCENodeToExport.find(name) != DCENodeToExport.end()) { - std::cout << " is export " << DCENodeToExport[name].str << ", " + std::cout << " is export " << DCENodeToExport[name] << ", " << wasm.getExport(DCENodeToExport[name])->value << '\n'; } if (DCENodeToFunction.find(name) != DCENodeToFunction.end()) { @@ -397,7 +395,7 @@ public: std::cout << " is tag " << DCENodeToTag[name] << '\n'; } for (auto target : node.reaches) { - std::cout << " reaches: " << target.str << '\n'; + std::cout << " reaches: " << target << '\n'; } } std::cout << "=============\n"; |