summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2023-01-30 12:04:30 -0600
committerGitHub <noreply@github.com>2023-01-30 10:04:30 -0800
commitd19c31b371aab47dedd166c2d056f1c583c6a9a0 (patch)
tree3b6ba21c677ea4ebc1fdd2f988c4290f03d02015
parent332efd044b4ef0c60d2bd7fa8eea44c245e75671 (diff)
downloadbinaryen-d19c31b371aab47dedd166c2d056f1c583c6a9a0.tar.gz
binaryen-d19c31b371aab47dedd166c2d056f1c583c6a9a0.tar.bz2
binaryen-d19c31b371aab47dedd166c2d056f1c583c6a9a0.zip
[NFC] Improve debug printing for type canonicalization (#5465)
Use an `IndexedTypeNameGenerator` to give types stable names for the entire `dump` method rather than generating fresh type names every time a single type is printed. This makes it possible to understand the relationships between the types in the debug output.
-rw-r--r--src/wasm/wasm-type.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp
index e5493c8d1..2c26f0e21 100644
--- a/src/wasm/wasm-type.cpp
+++ b/src/wasm/wasm-type.cpp
@@ -2490,13 +2490,14 @@ struct CanonicalizationState {
#if TRACE_CANONICALIZATION
void dump() {
+ IndexedTypeNameGenerator print(results);
std::cerr << "Results:\n";
for (size_t i = 0; i < results.size(); ++i) {
- std::cerr << i << ": " << results[i] << "\n";
+ std::cerr << i << ": " << print(results[i]) << "\n";
}
std::cerr << "NewInfos:\n";
for (size_t i = 0; i < newInfos.size(); ++i) {
- std::cerr << asHeapType(newInfos[i]) << "\n";
+ std::cerr << print(asHeapType(newInfos[i])) << "\n";
}
std::cerr << '\n';
}