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

fix: Prevent dead instruction elimination of brillig functions which may contain side-effects #2340

Merged
merged 6 commits into from
Aug 16, 2023

Conversation

TomAFrench
Copy link
Member

Description

Problem*

Resolves #2333

Summary*

This PR updates Instruction::has_side_effects(&self) to return true for any function call. When we perform DIE the only function calls remaining should be brillig function calls, as these may contain assert statements or foreign calls then we must assume they have sideeffects.

We could inspect the called function more closely to determine whether it contains side-effects but we'd need to pass through a lot more information and this is a good quick-fix in the meantime.

Draft until #2339 is merged

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

sirasistant
sirasistant previously approved these changes Aug 16, 2023
Copy link
Contributor

@sirasistant sirasistant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TomAFrench
Copy link
Member Author

Test failures are from #2339 and are being fixed in there.

…deeffects

* integration-test-cleanup:
  chore: revert change to `compile_failure` tests
Base automatically changed from integration-test-cleanup to master August 16, 2023 12:44
@TomAFrench TomAFrench dismissed sirasistant’s stale review August 16, 2023 12:44

The base branch was changed.

@TomAFrench TomAFrench marked this pull request as ready for review August 16, 2023 12:45
@TomAFrench TomAFrench added this pull request to the merge queue Aug 16, 2023
Merged via the queue into master with commit ba8ffd8 Aug 16, 2023
17 checks passed
@TomAFrench TomAFrench deleted the assume-functions-have-sideeffects branch August 16, 2023 13:15
TomAFrench added a commit that referenced this pull request Aug 16, 2023
* master:
  fix: Display warning if last expression of block is unused (#2314)
  chore(noir): Release 0.10.2 (#2343)
  fix: Prevent dead instruction elimination of brillig functions which may contain side-effects (#2340)
  chore: Separate integration tests for contracts and programs (#2339)
TomAFrench added a commit that referenced this pull request Aug 17, 2023
* master: (25 commits)
  chore: update noir-source-resolver from `1.1.2` to `^1.1.3` (#2349)
  chore(ci): Avoid writing to cache in workflows triggered by the merge queue (#2341)
  chore(noir): Release 0.10.3 (#2344)
  feat(lsp): Add `Execute` code lens for `main` functions (#2330)
  feat(lsp): Add `Compile` code lens for `main` function and contracts (#2309)
  feat: Allow calling higher-order functions with closures (#2335)
  fix: Display warning if last expression of block is unused (#2314)
  chore(noir): Release 0.10.2 (#2343)
  fix: Prevent dead instruction elimination of brillig functions which may contain side-effects (#2340)
  chore: Separate integration tests for contracts and programs (#2339)
  chore: move orphaned integration tests to new directory (#2331)
  chore(noir): Release 0.10.1 (#2328)
  feat(ssa): Switch mem2reg pass to be per function rather than per block (#2243)
  feat(ssa): Perform dead instruction elimination on intrinsic functions (#2276)
  feat: Add full call stacks to runtime errors (#2310)
  chore(ci): fix mismatched input name to publish workflow (#2327)
  chore: add README for integration test structure (#2277)
  feat: Improved error message for unexpected return type (#2302)
  feat(stdlib): Implement `str` `as_bytes` and `into_bytes` function (#2298)
  chore(ci): automatically convert changelog entries to sentence case (#2325)
  ...
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

Successfully merging this pull request may close these issues.

2 participants