Skip to content

Optimizing functions with try runs into assertions #2447

Closed

Description

@dcodeIO

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 :)

Activity

  1. self-assigned this
    on Nov 18, 2019
  2. aheejin commented on Nov 18, 2019

    @aheejin
    Member

    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).

  3. added a commit that references this issue on Dec 31, 2019
    bcc7614
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions