Skip to content

Commit

Permalink
Generates memory block for return_data
Browse files Browse the repository at this point in the history
  • Loading branch information
guipublic committed May 22, 2024
1 parent 904f5eb commit 70b2a26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions acvm-repo/acir/src/circuit/opcodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ pub enum BlockType {
ReturnData,
}

impl BlockType {
pub fn is_databus(&self) -> bool {
matches!(self, BlockType::CallData | BlockType::ReturnData)
}
}

#[allow(clippy::large_enum_variant)]
#[derive(Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum Opcode {
Expand Down
5 changes: 3 additions & 2 deletions acvm-repo/acvm/src/compiler/optimizers/unused_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ impl UnusedMemoryOptimizer {
let mut optimized_opcodes = Vec::with_capacity(self.circuit.opcodes.len());
for (idx, opcode) in self.circuit.opcodes.into_iter().enumerate() {
match opcode {
Opcode::MemoryInit { block_id, .. }
if self.unused_memory_initializations.contains(&block_id) =>
Opcode::MemoryInit { block_id, block_type, .. }
if !block_type.is_databus()
&& self.unused_memory_initializations.contains(&block_id) =>
{
// Drop opcode
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ impl<'a> Context<'a> {
&mut self,
terminator: &TerminatorInstruction,
dfg: &DataFlowGraph,
) -> Result<Vec<SsaReport>, InternalError> {
) -> Result<Vec<SsaReport>, RuntimeError> {
let (return_values, call_stack) = match terminator {
TerminatorInstruction::Return { return_values, call_stack } => {
(return_values, call_stack)
Expand All @@ -1750,6 +1750,8 @@ impl<'a> Context<'a> {
if !is_databus {
// We do not return value for the data bus.
self.acir_context.return_var(acir_var)?;
} else {
self.check_array_is_initialized(self.data_bus.return_data.unwrap(), dfg)?;
}
}
Ok(warnings)
Expand Down

0 comments on commit 70b2a26

Please sign in to comment.