diff options
author | Jérôme Vouillon <jerome.vouillon@gmail.com> | 2024-04-11 17:15:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 14:15:59 -0700 |
commit | d662d732ff471ea40eacc68cf62391acf27eec4e (patch) | |
tree | a129f4d274e16f9ef7f3aacc2d9d5676afb9cac4 /src/ir/module-utils.cpp | |
parent | 729f64c4212c338a9e7324cc55414ecc62a78893 (diff) | |
download | binaryen-d662d732ff471ea40eacc68cf62391acf27eec4e.tar.gz binaryen-d662d732ff471ea40eacc68cf62391acf27eec4e.tar.bz2 binaryen-d662d732ff471ea40eacc68cf62391acf27eec4e.zip |
Fixes regarding explicit names (#6466)
- Only write explicit function names.
- When merging modules, the name of types, globals and tags in all
modules but the first were lost.
- Set name as explicit when copying a function with a new name.
Diffstat (limited to 'src/ir/module-utils.cpp')
-rw-r--r-- | src/ir/module-utils.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ir/module-utils.cpp b/src/ir/module-utils.cpp index fdee4f869..8d9e88d18 100644 --- a/src/ir/module-utils.cpp +++ b/src/ir/module-utils.cpp @@ -48,6 +48,7 @@ Function* copyFunction(Function* func, std::optional<std::vector<Index>> fileIndexMap) { auto ret = std::make_unique<Function>(); ret->name = newName.is() ? newName : func->name; + ret->hasExplicitName = func->hasExplicitName; ret->type = func->type; ret->vars = func->vars; ret->localNames = func->localNames; @@ -77,6 +78,7 @@ Function* copyFunction(Function* func, Global* copyGlobal(Global* global, Module& out) { auto* ret = new Global(); ret->name = global->name; + ret->hasExplicitName = global->hasExplicitName; ret->type = global->type; ret->mutable_ = global->mutable_; ret->module = global->module; @@ -93,6 +95,7 @@ Global* copyGlobal(Global* global, Module& out) { Tag* copyTag(Tag* tag, Module& out) { auto* ret = new Tag(); ret->name = tag->name; + ret->hasExplicitName = tag->hasExplicitName; ret->sig = tag->sig; ret->module = tag->module; ret->base = tag->base; @@ -209,8 +212,17 @@ void copyModuleItems(const Module& in, Module& out) { for (auto& curr : in.dataSegments) { copyDataSegment(curr.get(), out); } + + for (auto& [type, names] : in.typeNames) { + if (!out.typeNames.count(type)) { + out.typeNames[type] = names; + } + } } +// TODO: merge this with copyModuleItems, and add options for copying +// exports and other things that are currently different between them, +// if we still need those differences. void copyModule(const Module& in, Module& out) { // we use names throughout, not raw pointers, so simple copying is fine // for everything *but* expressions @@ -222,7 +234,6 @@ void copyModule(const Module& in, Module& out) { out.customSections = in.customSections; out.debugInfoFileNames = in.debugInfoFileNames; out.features = in.features; - out.typeNames = in.typeNames; } void clearModule(Module& wasm) { |