File tree Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -1179,14 +1179,14 @@ EvalCtorOutcome evalCtor(EvallingModuleRunner& instance,
11791179 }
11801180 }
11811181
1182- // If we have return-called to a different function, have precomputed values
1183- // for the current return-called function (even if it is the same as the
1184- // original function), or have partially computed the current function, then
1185- // we can replace the export with a new function that does less work than
1186- // the original.
1187- if (func->name != funcName ||
1188- (localExprs. size () && func->getParams () != Type::none) ||
1189- (successes > 0 && successes < block-> list . size ( ))) {
1182+ // If we have not fully evaluated the current function, but we have
1183+ // evaluated part of it, have return-called to a different function, or have
1184+ // precomputed values for the current return-called function, then we can
1185+ // replace the export with a new function that does less work than the
1186+ // original.
1187+ if (( func->imported () || successes < block-> list . size ()) &&
1188+ (successes > 0 || func->name != funcName ||
1189+ (localExprs. size () && func-> getParams () != Type::none ))) {
11901190 auto originalFuncType = wasm.getFunction (funcName)->type ;
11911191 auto copyName = Names::getValidFunctionName (wasm, funcName);
11921192 wasm.getExport (exportName)->value = copyName;
Original file line number Diff line number Diff line change 11;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
22;; RUN: foreach %s %t wasm-ctor-eval --ctors=test --kept-exports=test --ignore-external-input --quiet -all -g -S -o - | filecheck %s
33
4+ (module
5+ ;; Simplest possible return call.
6+
7+ (func $test (export " test" ) (result i32 )
8+ (return_call $test2 )
9+ )
10+
11+ (func $test2 (result i32 )
12+ (i32.const 42 )
13+ )
14+ )
15+
16+ ;; CHECK: (type $0 (func (result i32)))
17+
18+ ;; CHECK: (export "test" (func $test_2))
19+
20+ ;; CHECK: (func $test_2 (type $0) (result i32)
21+ ;; CHECK-NEXT: (i32.const 42)
22+ ;; CHECK-NEXT: )
423(module
524 ;; Basic return call (followed by unreachable import call, setting global as proof it was executed)
625
3453
3554;; CHECK: (export "g2" (global $g2))
3655
37- ;; CHECK: (export "test" (func $test_3_4 ))
56+ ;; CHECK: (export "test" (func $test_3 ))
3857
39- ;; CHECK: (func $test_3_4 (type $0)
58+ ;; CHECK: (func $test_3 (type $0)
4059;; CHECK-NEXT: (nop)
4160;; CHECK-NEXT: )
4261(module
129148
130149;; CHECK: (export "g2" (global $g2))
131150
132- ;; CHECK: (export "test" (func $test_3_4 ))
151+ ;; CHECK: (export "test" (func $test_3 ))
133152
134- ;; CHECK: (func $test_3_4 (type $f)
153+ ;; CHECK: (func $test_3 (type $f)
135154;; CHECK-NEXT: (nop)
136155;; CHECK-NEXT: )
137156(module
You can’t perform that action at this time.
0 commit comments