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

Bugs with vector example #133

Open
mhyee opened this issue May 30, 2017 · 1 comment
Open

Bugs with vector example #133

mhyee opened this issue May 30, 2017 · 1 comment
Labels

Comments

@mhyee
Copy link
Member

mhyee commented May 30, 2017

The vector example is still in progress. The unoptimized version works, but running some of the passes reveals bugs. I ran these on top of #132.

Some of these bugs may be related, or may be masking each other. Many of these bugs were found when attempting to reduce the first few examples.

    var obj
    branch (obj == nil) error l1
  l1:
    branch true error done
  done:
    return true
  error:
    return false
$ ./sourir examples/mwe.sou --quiet --opt min_live
Scope error in the optimized program (min_live):
Error in function main version anon version anon
     0 | var obj = nil
     1 | branch (obj == nil) error l1
     2 |l1:
     3 | drop obj
     4 | branch true error done
     5 |done:
     6 | return true
     7 |error:
     8 | return false
At instruction 7,
the scope coming from instruction 4 and
the scope coming from instruction 1
are incompatible:
  - the latter declares {var obj} and the former does not

    call a = '_args_check (5)
    stop 0

function _args_check (var len)
    var arrlen = 1
  checklen:
    arrlen <- 2
    branch (arrlen < len) error loop
  loop:
    branch true error loop
  error:
    return false
$ ./sourir examples/mwe.sou --quiet --opt prune,hoist_assign
Fatal error: exception Eval.Unbound_variable("arrlen_1")

    var map
    branch false error l1
  l1:
    map <- nil
  begin:
    branch true error loop
  loop:
    goto begin
  error:
    return nil
$ ./sourir examples/mwe.sou --quiet --opt prune,hoist_assign,min_live
Fatal error: exception Eval.Unbound_variable("map_1")

    array v[2]
    call a = '_args_check ()
    stop 0

function _args_check ()
    var x
    branch true error loop
  loop:
    branch (x == nil) error loop
  error:
    return false
$ ./sourir examples/mwe.sou --quiet --opt prune,hoist_assign,min_live
Scope error in the optimized program (prune, hoist_assign, min_live):
Error in function main version anon line 1: Variable v is not declared.

    call a = '_args_check ()
    stop 0

function _args_check ()
    goto error
    goto loop
  loop:
  error:
    return false
$ ./sourir examples/mwe.sou --quiet --opt prune,hoist_assign,min_live
Fatal error: exception Assert_failure("transform_assumption.ml", 26, 21)

    array v[2]
    stop 0

function _obj_find_helper ()
    var map
    var obj
  l1:
    map <- obj[1]
  begin:
    branch true done next
  next:
    map <- map[2]
  done:
    return map
$ ./sourir examples/mwe.sou --quiet --opt prune,hoist_assign,min_live
Optimization Failure on the following program:
[elided]
Fatal error: exception Scope.UndeclaredVariable(_, 0)
@mhyee mhyee added the bug label May 30, 2017
@mhyee mhyee mentioned this issue May 31, 2017
@mhyee
Copy link
Member Author

mhyee commented Jun 6, 2017

I confirm that the above bugs have been fixed. The examples are no longer valid, due to changes in the parser (requiring $ to prefix branch labels) and the constraint that branch labels cannot have multiple predecessors. But the corrected examples no longer trigger the bugs.

I don't remember the exact PRs that fixed these bugs, but #143, #144 seem to be the most relevant.

However, I found a new bug. I was trying to fix the vector example, and was getting a misleading error message. Here's the MWE:

    branch true $loop_4a $loop_8a
  $loop_4a:
    goto loop_4
  loop_4:
    goto loop_8
  $l7:
  # Commented out to trigger bug
  #  goto loop_8
  $loop_8a:
    goto loop_8
  loop_8:
    return nil
$ ./sourir examples/mwe.sou
Error in function main version anon: label at line 8 is used more than once

But the actual error is a fallthrough, and no (branch) labels are used more than once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant