From 9309ab656b880515290c45322ff0da533e7bee55 Mon Sep 17 00:00:00 2001 From: Aaron Councilman <aaronjc4@illinois.edu> Date: Thu, 5 Dec 2024 10:32:56 -0600 Subject: [PATCH] Another CCP bugfix --- hercules_opt/src/ccp.rs | 23 ++++++++++++++++++----- juno_samples/nested_ccp/src/main.rs | 3 ++- juno_samples/nested_ccp/src/nested_ccp.jn | 8 ++++---- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/hercules_opt/src/ccp.rs b/hercules_opt/src/ccp.rs index 692d0f71..cf3a0919 100644 --- a/hercules_opt/src/ccp.rs +++ b/hercules_opt/src/ccp.rs @@ -845,11 +845,24 @@ fn ccp_flow_function( } Node::Read { collect, - indices: _, - } => CCPLattice { - reachability: inputs[collect.idx()].reachability.clone(), - constant: ConstantLattice::bottom(), - }, + indices, + } => { + let mut reachability = inputs[collect.idx()].reachability.clone(); + for index in indices.iter() { + if let Index::Position(positions) = index { + for position in positions.iter() { + reachability = ReachabilityLattice::join( + &reachability, + &inputs[position.idx()].reachability, + ); + } + } + } + CCPLattice { + reachability, + constant: ConstantLattice::bottom(), + } + } // Projection handles reachability when following an if or match. Node::Projection { control, selection } => match &editor.func().nodes[control.idx()] { Node::If { control: _, cond } => { diff --git a/juno_samples/nested_ccp/src/main.rs b/juno_samples/nested_ccp/src/main.rs index 1acea9bf..f866112f 100644 --- a/juno_samples/nested_ccp/src/main.rs +++ b/juno_samples/nested_ccp/src/main.rs @@ -8,8 +8,9 @@ juno_build::juno!("nested_ccp"); fn main() { async_std::task::block_on(async { + let mut a = vec![17.0, 18.0, 19.0]; let output = unsafe { - ccp_example().await + ccp_example(a.as_mut_ptr()).await }; println!("{}", output); assert_eq!(output, 1.0); diff --git a/juno_samples/nested_ccp/src/nested_ccp.jn b/juno_samples/nested_ccp/src/nested_ccp.jn index 506f0361..7a957585 100644 --- a/juno_samples/nested_ccp/src/nested_ccp.jn +++ b/juno_samples/nested_ccp/src/nested_ccp.jn @@ -1,15 +1,15 @@ #[entry] -fn ccp_example() -> f32 { +fn ccp_example(arg : f32[3]) -> f32 { let x : f32 = 2; if x < 3 { x = 1; } else { if x == 1 { - x = 4; + x = 3; } else { - x = 1; + x = 7; } } - if false { for i = 0 to 3 by 1 { } } + if false { for i = 0 to 3 by 1 { x = arg[i]; arg[i] = 0; } } return x; } -- GitLab