Skip to content

Optimizing functions with try runs into assertions #2447

@dcodeIO

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

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