From 9c7a9cd8c0cfd76a235a3e47fa4aa6fb9bc395ac Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2019 11:51:14 -0800 Subject: [PATCH 1/3] Reland "Fix renaming in FixInvokeFunctionNamesWalker (#2513)" In the previous iteration of this change we were not calling `renameFunctions` for each of the functions we removed. The problem manifested itself when we rename the imported function to `emscripten_longjmp_jmpbuf` to `emscripten_longjmp`. In this case the import of `emscripten_longjmp` already exists so we remove the import of `emscripten_longjmp_jmpbuf` but we were not correclty calling renameFunctions to handle the rename of all the uses. Add an additional test case to cover the failures that we saw on the emscripten tree. --- scripts/test/generate_lld_tests.py | 16 ++- scripts/test/shared.py | 7 +- src/wasm/wasm-emscripten.cpp | 40 ++++-- test/lld/longjmp.c | 17 +++ test/lld/longjmp.wat | 136 ++++++++++++++++++ test/lld/longjmp.wat.out | 223 +++++++++++++++++++++++++++++ test/lld/shared_longjmp.wat | 48 +++---- test/lld/shared_longjmp.wat.out | 46 +++--- 8 files changed, 461 insertions(+), 72 deletions(-) create mode 100644 test/lld/longjmp.c create mode 100644 test/lld/longjmp.wat create mode 100644 test/lld/longjmp.wat.out diff --git a/scripts/test/generate_lld_tests.py b/scripts/test/generate_lld_tests.py index 64fcff2ac01..9bfafcb4242 100755 --- a/scripts/test/generate_lld_tests.py +++ b/scripts/test/generate_lld_tests.py @@ -30,8 +30,8 @@ def files_with_extensions(path, extensions): yield file, ext -def generate_wast_files(llvm_bin, emscripten_root): - print('\n[ building wast files from C sources... ]\n') +def generate_wat_files(llvm_bin, emscripten_root): + print('\n[ building wat files from C sources... ]\n') lld_path = os.path.join(shared.options.binaryen_test, 'lld') for src_file, ext in files_with_extensions(lld_path, ['.c', '.cpp']): @@ -42,11 +42,11 @@ def generate_wast_files(llvm_bin, emscripten_root): obj_path = os.path.join(lld_path, obj_file) wasm_file = src_file.replace(ext, '.wasm') - wast_file = src_file.replace(ext, '.wast') + wat_file = src_file.replace(ext, '.wat') obj_path = os.path.join(lld_path, obj_file) wasm_path = os.path.join(lld_path, wasm_file) - wast_path = os.path.join(lld_path, wast_file) + wat_path = os.path.join(lld_path, wat_file) is_shared = 'shared' in src_file compile_cmd = [ @@ -70,6 +70,10 @@ def generate_wast_files(llvm_bin, emscripten_root): '--export', '__data_end', '--global-base=568', ] + # We had a regression where this test only worked if debug names + # were included. + if 'longjmp' in src_file: + link_cmd.append('--strip-debug') if is_shared: compile_cmd.append('-fPIC') compile_cmd.append('-fvisibility=default') @@ -80,7 +84,7 @@ def generate_wast_files(llvm_bin, emscripten_root): try: support.run_command(compile_cmd) support.run_command(link_cmd) - support.run_command(shared.WASM_DIS + [wasm_path, '-o', wast_path]) + support.run_command(shared.WASM_DIS + [wasm_path, '-o', wat_path]) finally: # Don't need the .o or .wasm files, don't leave them around shared.delete_from_orbit(obj_path) @@ -91,4 +95,4 @@ def generate_wast_files(llvm_bin, emscripten_root): if len(shared.options.positional_args) != 2: print('Usage: generate_lld_tests.py [llvm/bin/dir] [path/to/emscripten]') sys.exit(1) - generate_wast_files(*shared.options.positional_args) + generate_wat_files(*shared.options.positional_args) diff --git a/scripts/test/shared.py b/scripts/test/shared.py index 1ec42bc59d2..44a8dcc5204 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -87,6 +87,7 @@ def parse_args(args): options = parse_args(sys.argv[1:]) requested = options.positional_args +script_dir = os.path.dirname(os.path.abspath(__file__)) num_failures = 0 warnings = [] @@ -123,8 +124,7 @@ def warn(text): # Locate Binaryen source directory if not specified. if not options.binaryen_root: - path_parts = os.path.abspath(__file__).split(os.path.sep) - options.binaryen_root = os.path.sep.join(path_parts[:-3]) + options.binaryen_root = os.path.dirname(os.path.dirname(script_dir)) options.binaryen_test = os.path.join(options.binaryen_root, 'test') @@ -207,8 +207,7 @@ def wrap_with_valgrind(cmd): def in_binaryen(*args): - __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) - return os.path.join(__rootpath__, *args) + return os.path.join(options.binaryen_root, *args) os.environ['BINARYEN'] = in_binaryen() diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index f069e558def..e52f24767ff 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -993,11 +993,11 @@ struct FixInvokeFunctionNamesWalker : public PostWalker { Module& wasm; std::map importRenames; - std::vector toRemove; - std::set newImports; + std::map functionReplace; std::set invokeSigs; + ImportInfo imports; - FixInvokeFunctionNamesWalker(Module& _wasm) : wasm(_wasm) {} + FixInvokeFunctionNamesWalker(Module& _wasm) : wasm(_wasm), imports(wasm) {} // Converts invoke wrapper names generated by LLVM backend to real invoke // wrapper names that are expected by JavaScript glue code. @@ -1052,27 +1052,37 @@ struct FixInvokeFunctionNamesWalker return; } - assert(importRenames.count(curr->name) == 0); - BYN_TRACE("renaming: " << curr->name << " -> " << newname << "\n"); - importRenames[curr->name] = newname; - // Either rename or remove the existing import - if (wasm.getFunctionOrNull(newname) || !newImports.insert(newname).second) { - toRemove.push_back(curr->name); + BYN_TRACE("renaming import: " << curr->module << "." << curr->base << " (" + << curr->name << ") -> " << newname << "\n"); + assert(importRenames.count(curr->base) == 0); + importRenames[curr->base] = newname; + // Either rename the import, or replace it with an existing one + Function* existingFunc = imports.getImportedFunction(curr->module, newname); + if (existingFunc) { + BYN_TRACE("replacing with an existing import: " << existingFunc->name << "\n"); + functionReplace[curr->name] = existingFunc->name; } else { + BYN_TRACE("renaming the import in place\n"); curr->base = newname; - curr->name = newname; } } void visitModule(Module* curr) { - for (auto importName : toRemove) { - wasm.removeFunction(importName); + // For each replaced function first remove the function itself then + // rename all uses to the point to the new function. + for (auto& pair : functionReplace) { + BYN_TRACE("removeFunction " << pair.first << "\n"); + wasm.removeFunction(pair.first); } - ModuleUtils::renameFunctions(wasm, importRenames); - ImportInfo imports(wasm); + // Rename all uses of the removed functions + ModuleUtils::renameFunctions(wasm, functionReplace); + + // For imports that for renamed, update any associated GOT.func imports. for (auto& pair : importRenames) { - // Update any associated GOT.func import. + BYN_TRACE("looking for: GOT.func." << pair.first << "\n"); if (auto g = imports.getImportedGlobal("GOT.func", pair.first)) { + BYN_TRACE("renaming corresponding GOT entry: " << g->base << " -> " + << pair.second << "\n"); g->base = pair.second; } } diff --git a/test/lld/longjmp.c b/test/lld/longjmp.c new file mode 100644 index 00000000000..1df54f6f291 --- /dev/null +++ b/test/lld/longjmp.c @@ -0,0 +1,17 @@ +typedef struct jmp_buf_buf { + int thing; +} jmp_buf; + +void longjmp(jmp_buf env, int val); +int setjmp(jmp_buf env); + +int __THREW__; +int __threwValue; + +int main() { + jmp_buf jmp; + if (setjmp(jmp) == 0) { + longjmp(jmp, 1); + } + return 0; +} diff --git a/test/lld/longjmp.wat b/test/lld/longjmp.wat new file mode 100644 index 00000000000..7241a298be0 --- /dev/null +++ b/test/lld/longjmp.wat @@ -0,0 +1,136 @@ +(module + (type $i32_=>_none (func (param i32))) + (type $i32_i32_=>_none (func (param i32 i32))) + (type $none_=>_i32 (func (result i32))) + (type $none_=>_none (func)) + (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) + (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) + (import "env" "malloc" (func $fimport$0 (param i32) (result i32))) + (import "env" "saveSetjmp" (func $fimport$1 (param i32 i32 i32 i32) (result i32))) + (import "env" "getTempRet0" (func $fimport$2 (result i32))) + (import "env" "emscripten_longjmp_jmpbuf" (func $fimport$3 (param i32 i32))) + (import "env" "__invoke_void_i32_i32" (func $fimport$4 (param i32 i32 i32))) + (import "env" "testSetjmp" (func $fimport$5 (param i32 i32 i32) (result i32))) + (import "env" "setTempRet0" (func $fimport$6 (param i32))) + (import "env" "free" (func $fimport$7 (param i32))) + (import "env" "emscripten_longjmp" (func $fimport$8 (param i32 i32))) + (memory $0 2) + (table $0 2 2 funcref) + (elem (i32.const 1) $fimport$3) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 576)) + (export "memory" (memory $0)) + (export "__wasm_call_ctors" (func $0)) + (export "main" (func $2)) + (export "__data_end" (global $global$1)) + (func $0 (; 9 ;) + ) + (func $1 (; 10 ;) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (i32.store + (local.tee $0 + (call $fimport$0 + (i32.const 40) + ) + ) + (i32.const 0) + ) + (local.set $1 + (call $fimport$1 + (local.get $0) + (i32.const 1) + (local.get $0) + (i32.const 4) + ) + ) + (local.set $2 + (call $fimport$2) + ) + (local.set $0 + (i32.const 0) + ) + (block $label$1 + (block $label$2 + (loop $label$3 + (br_if $label$2 + (local.get $0) + ) + (i32.store offset=568 + (i32.const 0) + (i32.const 0) + ) + (call $fimport$4 + (i32.const 1) + (local.get $0) + (i32.const 1) + ) + (local.set $0 + (i32.load offset=568 + (i32.const 0) + ) + ) + (i32.store offset=568 + (i32.const 0) + (i32.const 0) + ) + (block $label$4 + (br_if $label$4 + (i32.eqz + (local.get $0) + ) + ) + (br_if $label$4 + (i32.eqz + (local.tee $3 + (i32.load offset=572 + (i32.const 0) + ) + ) + ) + ) + (br_if $label$1 + (i32.eqz + (call $fimport$5 + (i32.load + (local.get $0) + ) + (local.get $1) + (local.get $2) + ) + ) + ) + (call $fimport$6 + (local.get $3) + ) + ) + (local.set $0 + (call $fimport$2) + ) + (br $label$3) + ) + ) + (call $fimport$7 + (local.get $1) + ) + (return + (i32.const 0) + ) + ) + (call $fimport$8 + (local.get $0) + (local.get $3) + ) + (unreachable) + ) + (func $2 (; 11 ;) (param $0 i32) (param $1 i32) (result i32) + (call $1) + ) + ;; custom section "producers", size 112 +) + diff --git a/test/lld/longjmp.wat.out b/test/lld/longjmp.wat.out new file mode 100644 index 00000000000..1b6bbd34127 --- /dev/null +++ b/test/lld/longjmp.wat.out @@ -0,0 +1,223 @@ +(module + (type $i32_=>_none (func (param i32))) + (type $none_=>_i32 (func (result i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $i32_i32_=>_none (func (param i32 i32))) + (type $i32_i32_i32_=>_none (func (param i32 i32 i32))) + (type $none_=>_none (func)) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32))) + (type $i32_i32_i32_i32_=>_i32 (func (param i32 i32 i32 i32) (result i32))) + (import "env" "malloc" (func $fimport$0 (param i32) (result i32))) + (import "env" "saveSetjmp" (func $fimport$1 (param i32 i32 i32 i32) (result i32))) + (import "env" "getTempRet0" (func $fimport$2 (result i32))) + (import "env" "invoke_vii" (func $fimport$4 (param i32 i32 i32))) + (import "env" "testSetjmp" (func $fimport$5 (param i32 i32 i32) (result i32))) + (import "env" "setTempRet0" (func $fimport$6 (param i32))) + (import "env" "free" (func $fimport$7 (param i32))) + (import "env" "emscripten_longjmp" (func $fimport$8 (param i32 i32))) + (memory $0 2) + (table $0 2 2 funcref) + (elem (i32.const 1) $fimport$8) + (global $global$0 (mut i32) (i32.const 66112)) + (global $global$1 i32 (i32.const 576)) + (export "memory" (memory $0)) + (export "__wasm_call_ctors" (func $0)) + (export "main" (func $2)) + (export "__data_end" (global $global$1)) + (export "dynCall_vii" (func $dynCall_vii)) + (export "stackSave" (func $stackSave)) + (export "stackAlloc" (func $stackAlloc)) + (export "stackRestore" (func $stackRestore)) + (export "__growWasmMemory" (func $__growWasmMemory)) + (func $0 (; 8 ;) + (nop) + ) + (func $1 (; 9 ;) (result i32) + (local $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (i32.store + (local.tee $0 + (call $fimport$0 + (i32.const 40) + ) + ) + (i32.const 0) + ) + (local.set $1 + (call $fimport$1 + (local.get $0) + (i32.const 1) + (local.get $0) + (i32.const 4) + ) + ) + (local.set $2 + (call $fimport$2) + ) + (local.set $0 + (i32.const 0) + ) + (block $label$1 + (block $label$2 + (loop $label$3 + (br_if $label$2 + (local.get $0) + ) + (i32.store offset=568 + (i32.const 0) + (i32.const 0) + ) + (call $fimport$4 + (i32.const 1) + (local.get $0) + (i32.const 1) + ) + (local.set $0 + (i32.load offset=568 + (i32.const 0) + ) + ) + (i32.store offset=568 + (i32.const 0) + (i32.const 0) + ) + (block $label$4 + (br_if $label$4 + (i32.eqz + (local.get $0) + ) + ) + (br_if $label$4 + (i32.eqz + (local.tee $3 + (i32.load offset=572 + (i32.const 0) + ) + ) + ) + ) + (br_if $label$1 + (i32.eqz + (call $fimport$5 + (i32.load + (local.get $0) + ) + (local.get $1) + (local.get $2) + ) + ) + ) + (call $fimport$6 + (local.get $3) + ) + ) + (local.set $0 + (call $fimport$2) + ) + (br $label$3) + ) + ) + (call $fimport$7 + (local.get $1) + ) + (return + (i32.const 0) + ) + ) + (call $fimport$8 + (local.get $0) + (local.get $3) + ) + (unreachable) + ) + (func $2 (; 10 ;) (param $0 i32) (param $1 i32) (result i32) + (call $1) + ) + (func $dynCall_vii (; 11 ;) (param $fptr i32) (param $0 i32) (param $1 i32) + (call_indirect (type $i32_i32_=>_none) + (local.get $0) + (local.get $1) + (local.get $fptr) + ) + ) + (func $stackSave (; 12 ;) (result i32) + (global.get $global$0) + ) + (func $stackAlloc (; 13 ;) (param $0 i32) (result i32) + (local $1 i32) + (global.set $global$0 + (local.tee $1 + (i32.and + (i32.sub + (global.get $global$0) + (local.get $0) + ) + (i32.const -16) + ) + ) + ) + (local.get $1) + ) + (func $stackRestore (; 14 ;) (param $0 i32) + (global.set $global$0 + (local.get $0) + ) + ) + (func $__growWasmMemory (; 15 ;) (param $newSize i32) (result i32) + (memory.grow + (local.get $newSize) + ) + ) +) +(; +--BEGIN METADATA -- +{ + "staticBump": 8, + "tableSize": 2, + "initializers": [ + "__wasm_call_ctors" + ], + "declares": [ + "malloc", + "saveSetjmp", + "getTempRet0", + "testSetjmp", + "setTempRet0", + "free", + "emscripten_longjmp" + ], + "externs": [ + ], + "implementedFunctions": [ + "___wasm_call_ctors", + "_main", + "_dynCall_vii", + "_stackSave", + "_stackAlloc", + "_stackRestore", + "___growWasmMemory" + ], + "exports": [ + "__wasm_call_ctors", + "main", + "dynCall_vii", + "stackSave", + "stackAlloc", + "stackRestore", + "__growWasmMemory" + ], + "namedGlobals": { + "__data_end" : "576" + }, + "invokeFuncs": [ + "invoke_vii" + ], + "features": [ + ], + "mainReadsParams": 0 +} +-- END METADATA -- +;) diff --git a/test/lld/shared_longjmp.wat b/test/lld/shared_longjmp.wat index 235e1fadf14..b5179676ccf 100644 --- a/test/lld/shared_longjmp.wat +++ b/test/lld/shared_longjmp.wat @@ -15,41 +15,41 @@ (import "GOT.mem" "__THREW__" (global $gimport$13 (mut i32))) (import "GOT.func" "emscripten_longjmp_jmpbuf" (global $gimport$14 (mut i32))) (import "GOT.mem" "__threwValue" (global $gimport$15 (mut i32))) - (import "env" "malloc" (func $malloc (param i32) (result i32))) - (import "env" "saveSetjmp" (func $saveSetjmp (param i32 i32 i32 i32) (result i32))) - (import "env" "getTempRet0" (func $getTempRet0 (result i32))) - (import "env" "emscripten_longjmp_jmpbuf" (func $emscripten_longjmp_jmpbuf (param i32 i32))) - (import "env" "__invoke_void_i32_i32" (func $__invoke_void_i32_i32 (param i32 i32 i32))) - (import "env" "testSetjmp" (func $testSetjmp (param i32 i32 i32) (result i32))) - (import "env" "setTempRet0" (func $setTempRet0 (param i32))) - (import "env" "free" (func $free (param i32))) - (import "env" "emscripten_longjmp" (func $emscripten_longjmp (param i32 i32))) + (import "env" "malloc" (func $fimport$4 (param i32) (result i32))) + (import "env" "saveSetjmp" (func $fimport$5 (param i32 i32 i32 i32) (result i32))) + (import "env" "getTempRet0" (func $fimport$6 (result i32))) + (import "env" "emscripten_longjmp_jmpbuf" (func $fimport$7 (param i32 i32))) + (import "env" "__invoke_void_i32_i32" (func $fimport$8 (param i32 i32 i32))) + (import "env" "testSetjmp" (func $fimport$9 (param i32 i32 i32) (result i32))) + (import "env" "setTempRet0" (func $fimport$10 (param i32))) + (import "env" "free" (func $fimport$11 (param i32))) + (import "env" "emscripten_longjmp" (func $fimport$12 (param i32 i32))) (global $global$0 i32 (i32.const 0)) (global $global$1 i32 (i32.const 4)) - (export "__wasm_call_ctors" (func $__wasm_call_ctors)) - (export "_start" (func $_start)) + (export "__wasm_call_ctors" (func $0)) + (export "_start" (func $2)) (export "__THREW__" (global $global$0)) (export "__threwValue" (global $global$1)) - (func $__wasm_call_ctors (; 9 ;) (type $7) - (call $__wasm_apply_relocs) + (func $0 (; 9 ;) (type $7) + (call $1) ) - (func $__wasm_apply_relocs (; 10 ;) (type $7) + (func $1 (; 10 ;) (type $7) ) - (func $_start (; 11 ;) (type $7) + (func $2 (; 11 ;) (type $7) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (i32.store (local.tee $0 - (call $malloc + (call $fimport$4 (i32.const 40) ) ) (i32.const 0) ) (local.set $1 - (call $saveSetjmp + (call $fimport$5 (local.get $0) (i32.const 1) (local.get $0) @@ -57,7 +57,7 @@ ) ) (local.set $2 - (call $getTempRet0) + (call $fimport$6) ) (local.set $0 (i32.const 0) @@ -74,7 +74,7 @@ ) (i32.const 0) ) - (call $__invoke_void_i32_i32 + (call $fimport$8 (global.get $gimport$14) (local.get $0) (i32.const 1) @@ -108,7 +108,7 @@ ) (br_if $label$1 (i32.eqz - (call $testSetjmp + (call $fimport$9 (i32.load (local.get $3) ) @@ -117,22 +117,22 @@ ) ) ) - (call $setTempRet0 + (call $fimport$10 (local.get $0) ) ) (local.set $0 - (call $getTempRet0) + (call $fimport$6) ) (br $label$3) ) ) - (call $free + (call $fimport$11 (local.get $1) ) (return) ) - (call $emscripten_longjmp + (call $fimport$12 (local.get $3) (local.get $0) ) diff --git a/test/lld/shared_longjmp.wat.out b/test/lld/shared_longjmp.wat.out index 083fcb3ccd9..871e26b27ee 100644 --- a/test/lld/shared_longjmp.wat.out +++ b/test/lld/shared_longjmp.wat.out @@ -12,14 +12,14 @@ (import "env" "table" (table $0 0 funcref)) (import "env" "__memory_base" (global $gimport$2 i32)) (import "env" "__table_base" (global $gimport$3 i32)) - (import "env" "malloc" (func $malloc (param i32) (result i32))) - (import "env" "saveSetjmp" (func $saveSetjmp (param i32 i32 i32 i32) (result i32))) - (import "env" "getTempRet0" (func $getTempRet0 (result i32))) - (import "env" "invoke_vii" (func $invoke_vii (param i32 i32 i32))) - (import "env" "testSetjmp" (func $testSetjmp (param i32 i32 i32) (result i32))) - (import "env" "setTempRet0" (func $setTempRet0 (param i32))) - (import "env" "free" (func $free (param i32))) - (import "env" "emscripten_longjmp" (func $emscripten_longjmp (param i32 i32))) + (import "env" "malloc" (func $fimport$4 (param i32) (result i32))) + (import "env" "saveSetjmp" (func $fimport$5 (param i32 i32 i32 i32) (result i32))) + (import "env" "getTempRet0" (func $fimport$6 (result i32))) + (import "env" "invoke_vii" (func $fimport$8 (param i32 i32 i32))) + (import "env" "testSetjmp" (func $fimport$9 (param i32 i32 i32) (result i32))) + (import "env" "setTempRet0" (func $fimport$10 (param i32))) + (import "env" "free" (func $fimport$11 (param i32))) + (import "env" "emscripten_longjmp" (func $fimport$12 (param i32 i32))) (import "env" "g$__THREW__" (func $g$__THREW__ (result i32))) (import "env" "g$__threwValue" (func $g$__threwValue (result i32))) (import "env" "fp$emscripten_longjmp$vii" (func $fp$emscripten_longjmp$vii (result i32))) @@ -28,32 +28,32 @@ (global $gimport$15 (mut i32) (i32.const 0)) (global $global$0 i32 (i32.const 0)) (global $global$1 i32 (i32.const 4)) - (export "_start" (func $_start)) + (export "_start" (func $2)) (export "__THREW__" (global $global$0)) (export "__threwValue" (global $global$1)) (export "dynCall_vii" (func $dynCall_vii)) (export "__post_instantiate" (func $__post_instantiate)) - (func $__wasm_call_ctors (; 11 ;) - (call $__wasm_apply_relocs) + (func $0 (; 11 ;) + (call $1) ) - (func $__wasm_apply_relocs (; 12 ;) + (func $1 (; 12 ;) (nop) ) - (func $_start (; 13 ;) + (func $2 (; 13 ;) (local $0 i32) (local $1 i32) (local $2 i32) (local $3 i32) (i32.store (local.tee $0 - (call $malloc + (call $fimport$4 (i32.const 40) ) ) (i32.const 0) ) (local.set $1 - (call $saveSetjmp + (call $fimport$5 (local.get $0) (i32.const 1) (local.get $0) @@ -61,7 +61,7 @@ ) ) (local.set $2 - (call $getTempRet0) + (call $fimport$6) ) (local.set $0 (i32.const 0) @@ -78,7 +78,7 @@ ) (i32.const 0) ) - (call $invoke_vii + (call $fimport$8 (global.get $gimport$14) (local.get $0) (i32.const 1) @@ -112,7 +112,7 @@ ) (br_if $label$1 (i32.eqz - (call $testSetjmp + (call $fimport$9 (i32.load (local.get $3) ) @@ -121,22 +121,22 @@ ) ) ) - (call $setTempRet0 + (call $fimport$10 (local.get $0) ) ) (local.set $0 - (call $getTempRet0) + (call $fimport$6) ) (br $label$3) ) ) - (call $free + (call $fimport$11 (local.get $1) ) (return) ) - (call $emscripten_longjmp + (call $fimport$12 (local.get $3) (local.get $0) ) @@ -151,7 +151,7 @@ ) (func $__post_instantiate (; 15 ;) (call $__assign_got_enties) - (call $__wasm_call_ctors) + (call $0) ) (func $__assign_got_enties (; 16 ;) (global.set $gimport$13 From 66facd85b54b9ebc6cf624f22400f75b874fec0e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 19 Dec 2019 16:52:32 -0800 Subject: [PATCH 2/3] flake8 --- scripts/test/generate_lld_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test/generate_lld_tests.py b/scripts/test/generate_lld_tests.py index 9bfafcb4242..1f9324a88b4 100755 --- a/scripts/test/generate_lld_tests.py +++ b/scripts/test/generate_lld_tests.py @@ -72,7 +72,7 @@ def generate_wat_files(llvm_bin, emscripten_root): ] # We had a regression where this test only worked if debug names # were included. - if 'longjmp' in src_file: + if 'longjmp' in src_file: link_cmd.append('--strip-debug') if is_shared: compile_cmd.append('-fPIC') From 70427d25a136186bb81999f32e20e0401415d8d8 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 20 Dec 2019 12:38:20 -0800 Subject: [PATCH 3/3] clang-format --- src/wasm/wasm-emscripten.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index e52f24767ff..3d65f9de28d 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -1059,7 +1059,8 @@ struct FixInvokeFunctionNamesWalker // Either rename the import, or replace it with an existing one Function* existingFunc = imports.getImportedFunction(curr->module, newname); if (existingFunc) { - BYN_TRACE("replacing with an existing import: " << existingFunc->name << "\n"); + BYN_TRACE("replacing with an existing import: " << existingFunc->name + << "\n"); functionReplace[curr->name] = existingFunc->name; } else { BYN_TRACE("renaming the import in place\n");