Skip to content

Commit

Permalink
chore: Remove nested slices SSA and ACIR codegen (#4021)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #4019 

## Summary\*

This removes the relevant code introduced for nested slices. This may be
temporarily removed, but ultimately isn't too bad of a change as most of
the code is contained to the fill internal slices pass with some extra
logic in ACIR gen.

## Additional Context

See issue for extra context.

## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
vezenovm authored Jan 17, 2024
1 parent 8bb4ddf commit 555a4a5
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 1,073 deletions.
13 changes: 4 additions & 9 deletions compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub(crate) fn optimize_into_acir(

let ssa_gen_span = span!(Level::TRACE, "ssa_generation");
let ssa_gen_span_guard = ssa_gen_span.enter();
let ssa_builder = SsaBuilder::new(program, print_ssa_passes)?
let ssa = SsaBuilder::new(program, print_ssa_passes)?
.run_pass(Ssa::defunctionalize, "After Defunctionalization:")
.run_pass(Ssa::inline_functions, "After Inlining:")
// Run mem2reg with the CFG separated into blocks
Expand All @@ -62,16 +62,11 @@ pub(crate) fn optimize_into_acir(
// Run mem2reg once more with the flattened CFG to catch any remaining loads/stores
.run_pass(Ssa::mem2reg, "After Mem2Reg:")
.run_pass(Ssa::fold_constants, "After Constant Folding:")
.run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:");
.run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:")
.finish();

let brillig = ssa_builder.to_brillig(print_brillig_trace);
let brillig = ssa.to_brillig(print_brillig_trace);

// Split off any passes the are not necessary for Brillig generation but are necessary for ACIR generation.
// We only need to fill out nested slices as we need to have a known length when dealing with memory operations
// in ACIR gen while this is not necessary in the Brillig IR.
let ssa = ssa_builder
.run_pass(Ssa::fill_internal_slices, "After Fill Internal Slice Dummy Data:")
.finish();
drop(ssa_gen_span_guard);

let last_array_uses = ssa.find_last_array_uses();
Expand Down
353 changes: 57 additions & 296 deletions compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/ir/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl Type {
}

pub(crate) fn is_nested_slice(&self) -> bool {
if let Type::Slice(element_types) = self {
if let Type::Slice(element_types) | Type::Array(element_types, _) = self {
element_types.as_ref().iter().any(|typ| typ.contains_slice_element())
} else {
false
Expand Down
765 changes: 0 additions & 765 deletions compiler/noirc_evaluator/src/ssa/opt/fill_internal_slices.rs

This file was deleted.

1 change: 0 additions & 1 deletion compiler/noirc_evaluator/src/ssa/opt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ mod assert_constant;
mod constant_folding;
mod defunctionalize;
mod die;
mod fill_internal_slices;
pub(crate) mod flatten_cfg;
mod inlining;
mod mem2reg;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "nested_slice_dynamic"
name = "nested_array_in_slice"
type = "bin"
authors = [""]
[dependencies]

0 comments on commit 555a4a5

Please sign in to comment.