diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2020-12-17 22:35:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 19:35:16 -0800 |
commit | ae16f5cb995e3756ccb2093749bc5595fd86a2df (patch) | |
tree | 069128aa05216685bb7866de4a90a84c3b68bfa5 /src/ir/module-splitting.cpp | |
parent | cad723a3827913f53ecfa7189b011be389d28ae7 (diff) | |
download | binaryen-ae16f5cb995e3756ccb2093749bc5595fd86a2df.tar.gz binaryen-ae16f5cb995e3756ccb2093749bc5595fd86a2df.tar.bz2 binaryen-ae16f5cb995e3756ccb2093749bc5595fd86a2df.zip |
[module-splitting] Fix a crash when a function is exported twice (#3455)
`ModuleSplitter::thunkExportedSecondaryFunctions` creates a thunk for each
secondary function that needs to be exported from the main module. Previously,
if a secondary function was exported twice, this code would try to create two
thunks for it rather than just making one thunk and exporting it twice. This
caused a fatal error because the second thunk had the same name as the first
thunk and therefore could not be added to the module. This PR fixes the issue by
creating no more than one thunk per function.
Diffstat (limited to 'src/ir/module-splitting.cpp')
-rw-r--r-- | src/ir/module-splitting.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ir/module-splitting.cpp b/src/ir/module-splitting.cpp index f4f00c9af..1f33b44ac 100644 --- a/src/ir/module-splitting.cpp +++ b/src/ir/module-splitting.cpp @@ -345,6 +345,10 @@ void ModuleSplitter::thunkExportedSecondaryFunctions() { continue; } Name secondaryFunc = ex->value; + if (primary.getFunctionOrNull(secondaryFunc)) { + // We've already created a thunk for this function + continue; + } auto tableSlot = tableManager.getSlot(secondaryFunc); auto func = std::make_unique<Function>(); |