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

Add a --show-monomorphized flag to output the monomorphized IR #4067

Closed
jfecher opened this issue Jan 17, 2024 · 0 comments
Closed

Add a --show-monomorphized flag to output the monomorphized IR #4067

jfecher opened this issue Jan 17, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jfecher
Copy link
Contributor

jfecher commented Jan 17, 2024

Problem

Very commonly when debugging I add a println!("{program}"); on line 391 of noirc_driver/src/lib.rs: https://github.com/noir-lang/noir/blob/master/compiler/noirc_driver/src/lib.rs#L390. This shows the monomorphized output of the program and can be helpful in debugging certain frontend / codegen issues since it is more terse and closer to the source program than the SSA is.

Happy Case

We should add a flag such as --show-monomorphized or similar to show the monomorphized output of a program.

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@jfecher jfecher added enhancement New feature or request good first issue Good for newcomers labels Jan 17, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jan 17, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 22, 2024
# Description

Debugging optimizations often requires inspecting the monomorphized
program. This adds an option to enable this.

## Problem\*

#4067

## Summary\*

Example usage:

```bash
❯ (cd test_programs/compile_success_contract/simple_contract && cargo run compile --show-monomorphized)
   Compiling nargo_cli v0.23.0 (/Users/michaelklein/Coding/rust/noir/tooling/nargo_cli)
    Finished dev [optimized + debuginfo] target(s) in 1.79s
     Running `/Users/michaelklein/Coding/rust/noir/target/debug/nargo compile --show-monomorphized`
Monomorphized AST for program with hash: 18020856208726922572
fn triple$f0(x$l0: Field) -> Field {
    (x$l0 * 3)
}

Monomorphized AST for program with hash: 9305131916264092540
fn skibbidy$f0(x$l0: Field) -> Field {
    (x$l0 * 5)
}

Monomorphized AST for program with hash: 17799031513160233728
fn double$f0(x$l0: Field) -> Field {
    (x$l0 * 2)
}

Monomorphized AST for program with hash: 16417890415031598568
fn quadruple$f0(x$l0: Field) -> Field {
    (x$l0 * 4)
}
```

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed. (hidden option)
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.

---------

Co-authored-by: jfecher <jake@aztecprotocol.com>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Archived in project
Development

No branches or pull requests

2 participants