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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ pub fn compile_no_check(
|| options.print_acir
|| options.show_brillig
|| options.force_brillig
|| options.count_array_copies
|| options.show_ssa
|| !options.show_ssa_pass.is_empty()
|| options.emit_ssa
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ impl<F: AcirField + DebugToString, Registers: RegisterAllocator> BrilligContext<
self.deallocate_single_addr(const_register);
}
}

pub(crate) fn codegen_increment_array_copy_counter(&mut self) {
let array_copy_counter = self.array_copy_counter_address();
self.codegen_usize_op(array_copy_counter, array_copy_counter, BrilligBinaryOp::Add, 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,7 @@

// Increase our array copy counter if that flag is set
if ctx.count_arrays_copied {
let array_copy_counter = BrilligVariable::SingleAddr(SingleAddrVariable {
address: ctx.array_copy_counter_address(),
bit_size: 32,
});

let counter_register = array_copy_counter.extract_register();
ctx.codegen_usize_op(counter_register, counter_register, BrilligBinaryOp::Add, 1);
ctx.codegen_increment_array_copy_counter();
}
}
});
Expand All @@ -97,8 +91,8 @@
const ARRAY_COPY_COUNTER_MESSAGE: &str = "Total arrays copied: {}";

/// The metadata string needed to tell `print` to print out a u32
const PRINT_U32_TYPE_STRING: &str = "{\"kind\":\"unsignedinteger\",\"width\":32}";

Check warning on line 94 in compiler/noirc_evaluator/src/brillig/brillig_ir/procedures/array_copy.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (unsignedinteger)
// "{\"kind\":\"array\",\"length\":2,\"type\":{\"kind\":\"unsignedinteger\",\"width\":32}}";

Check warning on line 95 in compiler/noirc_evaluator/src/brillig/brillig_ir/procedures/array_copy.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (unsignedinteger)

// Create and return the string `PRINT_U32_TYPE_STRING`
fn literal_string_to_value<F: AcirField + DebugToString, Registers: RegisterAllocator>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ pub(crate) fn reallocate_vector_for_insertion<
.mov_instruction(target_vector.pointer, source_vector.pointer);
brillig_context.codegen_update_vector_length(target_vector, target_size);
} else {
// Increase our array copy counter if that flag is set
if brillig_context.count_arrays_copied {
brillig_context.codegen_increment_array_copy_counter();
}

brillig_context.codegen_initialize_vector(
target_vector,
target_size,
Expand All @@ -202,6 +207,12 @@ pub(crate) fn reallocate_vector_for_insertion<
target_size,
Some(double_size),
);

// Increase our array copy counter if that flag is set
if brillig_context.count_arrays_copied {
brillig_context.codegen_increment_array_copy_counter();
}

brillig_context.deallocate_single_addr(double_size);
}
},
Expand Down
Loading