Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing functions with try runs into assertions #2447

Closed
dcodeIO opened this issue Nov 18, 2019 · 1 comment · Fixed by #2451
Closed

Optimizing functions with try runs into assertions #2447

dcodeIO opened this issue Nov 18, 2019 · 1 comment · Fixed by #2451
Assignees

Comments

@dcodeIO
Copy link
Contributor

dcodeIO commented Nov 18, 2019

Found another assertion while testing try and throw instructions with the following module

(module
  (event $exception (attr 0) (param i32))
  (func $test
    (local $0 exnref)
    (try
      (throw $exception
        (i32.const 1)
      )
      (catch
        (local.set $0
          (exnref.pop)
        )
        (drop
          (block $catch|0 (result i32)
            (rethrow
              (br_on_exn $catch|0 $exception
                (local.get $0)
              )
            )
          )
        )
      )
    )
  )
  (export $test $test)
)

representing a try { throw 1; } catch { }, which yields

Fatal: IR must be flat: run --flatten beforehand (instructions must only have const, local.get, or unreachable as children, in $test)

if optimizeLevel == 4 (prepending flatten before default passes doesn't help) respectively

abort(Assertion failed: values.size() > 0, at: ./src/passes/StackIR.cpp,146,local2Stack).

if optimizeLevel > 2.

Again, I'm not sure how important it is at this point, so just putting it here :)

@aheejin
Copy link
Member

aheejin commented Nov 18, 2019

Optimization support for exception handling is patchy for now, so there might be remaining bugs for unhandled passes. But looking at the error message, that looks like its not directly related to EH itself but more about the reference type thing (because EH uses exnref). So I guess this also will be solved by the reference type support patch, which is coming (hopefully in a few days).

aheejin added a commit that referenced this issue Dec 31, 2019
This adds support for the reference type proposal. This includes support
for all reference types (`anyref`, `funcref`(=`anyfunc`), and `nullref`)
and four new instructions: `ref.null`, `ref.is_null`, `ref.func`, and
new typed `select`. This also adds subtype relationship support between
reference types.

This does not include table instructions yet. This also does not include
wasm2js support.

Fixes #2444 and fixes #2447.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants