Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 1 addition & 8 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,23 +687,16 @@ pub fn compile_no_check(
force_compile: bool,
) -> Result<CompiledProgram, CompileError> {
let force_unconstrained = options.force_brillig;
let experimental_ownership = options.unstable_features.contains(&UnstableFeature::Ownership);

let program = if options.instrument_debug {
monomorphize_debug(
main_function,
&mut context.def_interner,
&context.debug_instrumenter,
force_unconstrained,
experimental_ownership,
)?
} else {
monomorphize(
main_function,
&mut context.def_interner,
force_unconstrained,
experimental_ownership,
)?
monomorphize(main_function, &mut context.def_interner, force_unconstrained)?
};

if options.show_monomorphized {
Expand Down
16 changes: 2 additions & 14 deletions compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,23 +138,15 @@ pub fn monomorphize(
main: node_interner::FuncId,
interner: &mut NodeInterner,
force_unconstrained: bool,
enable_ownership: bool,
) -> Result<Program, MonomorphizationError> {
monomorphize_debug(
main,
interner,
&DebugInstrumenter::default(),
force_unconstrained,
enable_ownership,
)
monomorphize_debug(main, interner, &DebugInstrumenter::default(), force_unconstrained)
}

pub fn monomorphize_debug(
main: node_interner::FuncId,
interner: &mut NodeInterner,
debug_instrumenter: &DebugInstrumenter,
force_unconstrained: bool,
experimental_ownership: bool,
) -> Result<Program, MonomorphizationError> {
let debug_type_tracker = DebugTypeTracker::build_from_debug_instrumenter(debug_instrumenter);
let mut monomorphizer = Monomorphizer::new(interner, debug_type_tracker);
Expand Down Expand Up @@ -211,11 +203,7 @@ pub fn monomorphize_debug(
debug_functions,
debug_types,
);
Ok(program.handle_ownership(
monomorphizer.next_local_id,
monomorphizer.next_ident_id,
experimental_ownership,
))
Ok(program.handle_ownership())
}

impl<'interner> Monomorphizer<'interner> {
Expand Down
43 changes: 0 additions & 43 deletions compiler/noirc_frontend/src/ownership/last_uses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,46 +428,3 @@ impl LastUseContext {
}
}
}

#[cfg(test)]
mod test {
use crate::{
monomorphization::ast::{IdentId, LocalId},
test_utils::get_monomorphized,
};

#[test]
fn smoke_test() {
let src = "
fn main(d: [Field; 2]) {
if len(d) == 2 { // use 1 of d
if len(d) == 2 { // use 2 of d
assert(eq(d, [5, 6])); // use 3 of d
}
} else {
assert(eq(d, [5, 6])); // use 4 of d
}
}

fn eq(lhs: [Field; 2], rhs: [Field; 2]) -> bool {
(lhs[0] == rhs[0]) & (lhs[1] == rhs[1])
}

fn len(arr: [Field; 2]) -> u32 {
2
}
";

let program = get_monomorphized(src, None, crate::test_utils::Expect::Success).unwrap();

let function = program.main();
let last_uses = super::Context::find_last_uses_of_variables(function);

let d_local_id = LocalId(0);
let d_last_uses = &last_uses[&d_local_id];

// We should improve testing of this pass so that it is more clear where these ids
// correspond to.
assert_eq!(*d_last_uses, &[IdentId(7), IdentId(10)]);
}
}
Loading
Loading