Skip to content

Commit

Permalink
Remove unused function and add more test case output (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-hoffman authored Jun 26, 2024
1 parent 09ce590 commit c425a16
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 40 deletions.
32 changes: 32 additions & 0 deletions circom/tests/controlflow/early_return_loop_1.circom
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,38 @@ component main = EarlyReturn();
//CHECK-NEXT: br label %branch1
//CHECK-EMPTY:
//CHECK-NEXT: branch1:
//CHECK-NEXT: %0 = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %1 = load i256, i256* %0, align 4
//CHECK-NEXT: %call.fr_eq = call i1 @fr_eq(i256 %1, i256 99)
//CHECK-NEXT: br i1 %call.fr_eq, label %if.then, label %if.else
//CHECK-EMPTY:
//CHECK-NEXT: if.then:
//CHECK-NEXT: br label %if.merge
//CHECK-EMPTY:
//CHECK-NEXT: if.else:
//CHECK-NEXT: br label %if.merge
//CHECK-EMPTY:
//CHECK-NEXT: if.merge:
//CHECK-NEXT: br label %assert5
//CHECK-EMPTY:
//CHECK-NEXT: assert5:
//CHECK-NEXT: %2 = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 0
//CHECK-NEXT: %3 = load i256, i256* %2, align 4
//CHECK-NEXT: %call.fr_eq1 = call i1 @fr_eq(i256 %3, i256 0)
//CHECK-NEXT: call void @__assert(i1 %call.fr_eq1)
//CHECK-NEXT: br label %store6
//CHECK-EMPTY:
//CHECK-NEXT: store6:
//CHECK-NEXT: %4 = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %5 = getelementptr [0 x i256], [0 x i256]* %lvars, i32 0, i32 1
//CHECK-NEXT: %6 = load i256, i256* %5, align 4
//CHECK-NEXT: %call.fr_add = call i256 @fr_add(i256 %6, i256 1)
//CHECK-NEXT: store i256 %call.fr_add, i256* %4, align 4
//CHECK-NEXT: br label %return7
//CHECK-EMPTY:
//CHECK-NEXT: return7:
//CHECK-NEXT: ret void
//CHECK-NEXT: }

//CHECK-LABEL: define{{.*}} i256 @noEarlyReturnFn_{{[0-9]+}}(i256* %0){{.*}} {
//CHECK-NEXT: noEarlyReturnFn_[[$F_ID_2:[0-9]+]]:
Expand Down
1 change: 0 additions & 1 deletion circuit_passes/src/bucket_interpreter/observer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub trait Observer<S> {
}
}

fn ignore_subcmp_calls(&self) -> bool;
fn ignore_function_calls(&self) -> bool;
fn ignore_extracted_function_calls(&self) -> bool;
}
3 changes: 0 additions & 3 deletions circuit_passes/src/bucket_interpreter/write_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,6 @@ mod tests {
fn ignore_function_calls(&self) -> bool {
false
}
fn ignore_subcmp_calls(&self) -> bool {
false
}
fn ignore_extracted_function_calls(&self) -> bool {
false
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/conditional_flattening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ impl Observer<Env<'_>> for ConditionalFlatteningPass<'_> {
true
}

fn ignore_subcmp_calls(&self) -> bool {
true
}

fn ignore_extracted_function_calls(&self) -> bool {
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ impl Observer<Env<'_>> for DeterministicSubCmpInvokePass<'_> {
true
}

fn ignore_subcmp_calls(&self) -> bool {
true
}

fn ignore_extracted_function_calls(&self) -> bool {
false
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/loop_unroll/loop_env_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,6 @@ impl Observer<Env<'_>> for EnvRecorder<'_, '_> {
true
}

fn ignore_subcmp_calls(&self) -> bool {
true
}

fn ignore_extracted_function_calls(&self) -> bool {
true
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/loop_unroll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,6 @@ impl Observer<Env<'_>> for LoopUnrollPass<'_> {
false
}

fn ignore_subcmp_calls(&self) -> bool {
true
}

fn ignore_extracted_function_calls(&self) -> bool {
true
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/mapped_to_indexed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,6 @@ impl Observer<Env<'_>> for MappedToIndexedPass<'_> {
true
}

fn ignore_subcmp_calls(&self) -> bool {
true
}

fn ignore_extracted_function_calls(&self) -> bool {
false
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/simplification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,6 @@ impl Observer<Env<'_>> for SimplificationPass<'_> {
false
}

fn ignore_subcmp_calls(&self) -> bool {
true
}

fn ignore_extracted_function_calls(&self) -> bool {
true
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/unknown_index_sanitization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,6 @@ impl Observer<Env<'_>> for UnknownIndexSanitizationPass<'_> {
false
}

fn ignore_subcmp_calls(&self) -> bool {
false
}

fn ignore_extracted_function_calls(&self) -> bool {
true
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/unreachable_code_removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ impl Observer<Env<'_>> for UnreachableRemovalPass<'_> {
false // Observe within all functions
}

fn ignore_subcmp_calls(&self) -> bool {
false // Observe within subcomponents
}

fn ignore_extracted_function_calls(&self) -> bool {
false // Observe within all functions
}
Expand Down
4 changes: 0 additions & 4 deletions circuit_passes/src/passes/unused_func_removal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ impl Observer<()> for UnusedFuncRemovalPass<'_> {
false
}

fn ignore_subcmp_calls(&self) -> bool {
false
}

fn ignore_extracted_function_calls(&self) -> bool {
false
}
Expand Down

0 comments on commit c425a16

Please sign in to comment.