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

Adding update to loop causes state edge to be unwrapped #171

Open
kirstenmg opened this issue Nov 12, 2023 · 2 comments
Open

Adding update to loop causes state edge to be unwrapped #171

kirstenmg opened this issue Nov 12, 2023 · 2 comments
Assignees

Comments

@kirstenmg
Copy link
Collaborator

Error:
thread 'main' panicked at 'Tried to unwrap state edge', src/rvsdg/to_cfg.rs:62:38

Program that fails:

# ARGS: 3
@main(n: int) {
    i: int = const 3;
    x: int = add n i;
.loop:
    c: int = const 7;
    one: int = const 2;

    cond: bool = lt i n;
    y: int = mul c i;
    print y;
    i: int = add i one;
    x: int = mul c i;     <-- without this line the program succeeds
    br cond .loop .done;
.done:
    print x;
    print i;
}
@ezrosent
Copy link
Collaborator

How do we reproduce this? The following code seems to pass, but I know there may be other ways to hit the codepath that this code doesn't exercise.

#[test]
fn rvsdg_state_edge_unwrap() {
    const PROGRAM: &str = r#"
    @main(n: int) {
        i: int = const 3;
        x: int = add n i;
    .loop:
        c: int = const 7;
        one: int = const 2;
    
        cond: bool = lt i n;
        y: int = mul c i;
        print y;
        i: int = add i one;
        x: int = mul c i;
        br cond .loop .done;
    .done:
        print x;
        print i;
    }"#;
    let prog = parse_from_string(PROGRAM);
    let cfg = program_to_cfg(&prog);
    let rvsdg = cfg_to_rvsdg(&cfg)
        .unwrap()
        .functions
        .into_iter()
        .next()
        .unwrap();
    let expr = rvsdg.to_egglog_expr();
    let mut termdag = TermDag::default();
    let term = termdag.expr_to_term(&expr);
    let _res_rvsdg = RvsdgFunction::egglog_term_to_function(term, &termdag);
}

@oflatt
Copy link
Member

oflatt commented Feb 14, 2024

Let's just add that test and close this
This is a pretty old test and it might have been fixed

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

No branches or pull requests

3 participants