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

feat(ssa): Pass to preprocess functions #7072

Merged
merged 51 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
98dc167
Add pass to preprocess 'serialize'
aakoshh Jan 15, 2025
6943765
Simplify a CFG and run DIE as well
aakoshh Jan 15, 2025
ed56da8
Merge branch 'master' into af/ssa-preprocess-fns
TomAFrench Jan 15, 2025
850fc11
Add docstrings to inlining
aakoshh Jan 15, 2025
e5c49af
See what happens if we go bottom up
aakoshh Jan 15, 2025
ea4633c
Merge branch 'af/ssa-preprocess-fns' of github.com:noir-lang/noir int…
aakoshh Jan 15, 2025
13b42f2
Use a cutoff weight to skip processing large functions
aakoshh Jan 16, 2025
a9d754f
Merge remote-tracking branch 'origin/master' into af/ssa-preprocess-fns
aakoshh Jan 16, 2025
8f7eb9c
Add CLI option to turn off preprocessing
aakoshh Jan 16, 2025
02cb856
Don't call DIE, to fix the tests
aakoshh Jan 16, 2025
5aa3db7
Fix field name
aakoshh Jan 16, 2025
3c3e215
Remove restore_on_error from unrolling
aakoshh Jan 16, 2025
1b9ffde
Remove prints
aakoshh Jan 16, 2025
1e07b7a
Fix clippy
aakoshh Jan 16, 2025
de5176a
Do not inline self-recursive entries
aakoshh Jan 16, 2025
deaa311
Rename pass to Preprocess from Pre-process
aakoshh Jan 16, 2025
80872e5
Fix inlining recursion test
aakoshh Jan 16, 2025
f337a04
Refactor to use InlineInfo
aakoshh Jan 16, 2025
ca7ba9e
Fix remove unreachable functions to remove uncalled Brillig
aakoshh Jan 16, 2025
64841c4
Fix defunctionalization to inherit runtime of caller
aakoshh Jan 17, 2025
e9f7bad
Refactor defunctionalization to not create intermediate blocks before…
aakoshh Jan 17, 2025
8cf44ad
Merge branch 'master' into af/ssa-preprocess-fns
aakoshh Jan 17, 2025
da1fe6a
Create test to show defunctionalization not handling runtime
aakoshh Jan 17, 2025
7f2cdef
Fix SSA parser to handle function as value
aakoshh Jan 17, 2025
bd4f90b
Fix defunctionalization to inherit runtime of caller
aakoshh Jan 17, 2025
cfdbcad
Add another test to check 2 runtimes are created
aakoshh Jan 17, 2025
0532794
Merge branch 'master' into fix-defunctionalize-runtime
aakoshh Jan 17, 2025
1b7dc2e
fix: Simplify defunctionalize return (#7101)
aakoshh Jan 17, 2025
8102dd2
.
TomAFrench Jan 17, 2025
1405733
Add test with expected SSA
aakoshh Jan 17, 2025
f206178
.
TomAFrench Jan 17, 2025
939cf84
chore: fix tests
TomAFrench Jan 17, 2025
fc36f52
Add flag to tell the DIE not to remove STORE yet
aakoshh Jan 17, 2025
c00613e
Merge branch '7104-fix-die-mut-ref-param' into af/ssa-preprocess-fns
aakoshh Jan 17, 2025
d6c2318
Merge branch 'af/ssa-preprocess-fns' of github.com:noir-lang/noir int…
aakoshh Jan 17, 2025
dd34547
Re-enable the DIE
aakoshh Jan 17, 2025
9ec8d62
Merge remote-tracking branch 'origin/master' into af/ssa-preprocess-fns
aakoshh Jan 17, 2025
c868745
Call loop invariant motion
aakoshh Jan 17, 2025
b6cb13f
Improve comment
aakoshh Jan 17, 2025
ce7e412
Rewrite compute_times_called in to use the output of compute_callers
aakoshh Jan 17, 2025
a46c3e5
Reword comment
aakoshh Jan 17, 2025
4826682
Update compiler/noirc_evaluator/src/ssa/opt/inlining.rs
aakoshh Jan 17, 2025
44dbfd2
Merge remote-tracking branch 'origin/fix-defunctionalize-runtime' int…
aakoshh Jan 17, 2025
382280d
Merge branch 'af/ssa-preprocess-fns' of github.com:noir-lang/noir int…
aakoshh Jan 17, 2025
b7183a8
Merge remote-tracking branch 'origin/master' into af/ssa-preprocess-fns
aakoshh Jan 17, 2025
04c8395
Simplify loop
aakoshh Jan 18, 2025
64e50f8
Add test for order, tweak weights so the results on the test make sense
aakoshh Jan 20, 2025
915bf25
Remove unused after preprocessing
aakoshh Jan 20, 2025
ed8b10b
Remove --skip-preprocess-fns
aakoshh Jan 20, 2025
8f0fcc9
Do not skip heavy functions unless it mostly comes from its own weight
aakoshh Jan 20, 2025
a506fab
Merge branch 'master' into af/ssa-preprocess-fns
aakoshh Jan 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,19 @@ pub(crate) fn optimize_into_acir(
/// Run all SSA passes.
fn optimize_all(builder: SsaBuilder, options: &SsaEvaluatorOptions) -> Result<Ssa, RuntimeError> {
Ok(builder
.run_pass(Ssa::remove_unreachable_functions, "Removing Unreachable Functions")
.run_pass(Ssa::remove_unreachable_functions, "Removing Unreachable Functions (1st)")
.run_pass(Ssa::defunctionalize, "Defunctionalization")
.run_pass(Ssa::remove_paired_rc, "Removing Paired rc_inc & rc_decs")
.run_pass(
|ssa| ssa.preprocess_functions(options.inliner_aggressiveness),
"Preprocessing Functions",
)
.run_pass(|ssa| ssa.inline_functions(options.inliner_aggressiveness), "Inlining (1st)")
// Run mem2reg with the CFG separated into blocks
.run_pass(Ssa::mem2reg, "Mem2Reg (1st)")
.run_pass(Ssa::simplify_cfg, "Simplifying (1st)")
.run_pass(Ssa::as_slice_optimization, "`as_slice` optimization")
.run_pass(Ssa::remove_unreachable_functions, "Removing Unreachable Functions")
.run_pass(Ssa::remove_unreachable_functions, "Removing Unreachable Functions (2nd)")
.try_run_pass(
Ssa::evaluate_static_assert_and_assert_constant,
"`static_assert` and `assert_constant`",
Expand Down Expand Up @@ -188,7 +192,7 @@ fn optimize_all(builder: SsaBuilder, options: &SsaEvaluatorOptions) -> Result<Ss
.run_pass(Ssa::fold_constants_using_constraints, "Constraint Folding")
.run_pass(Ssa::make_constrain_not_equal_instructions, "Adding constrain not equal")
.run_pass(Ssa::dead_instruction_elimination, "Dead Instruction Elimination (1st)")
.run_pass(Ssa::simplify_cfg, "Simplifying:")
.run_pass(Ssa::simplify_cfg, "Simplifying (3rd):")
.run_pass(Ssa::array_set_optimization, "Array Set Optimizations")
.finish())
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/defunctionalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ fn create_apply_function(
let mut function_builder = FunctionBuilder::new("apply".to_string(), id);
function_builder.set_globals(globals);

// We want to push for apply functions to be inlined more aggressively.
// We want to push for apply functions to be inlined more aggressively;
// they are expected to be optimized away by constants visible at the call site.
let runtime = match caller_runtime {
RuntimeType::Acir(_) => RuntimeType::Acir(InlineType::InlineAlways),
RuntimeType::Brillig(_) => RuntimeType::Brillig(InlineType::InlineAlways),
Expand Down
Loading
Loading