Skip to content

Commit

Permalink
Combined assign and return & disabled simplification for restarted an…
Browse files Browse the repository at this point in the history
…alysis
  • Loading branch information
HoseongLee committed Sep 27, 2024
1 parent ddc1706 commit 82eae1f
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 100 deletions.
34 changes: 23 additions & 11 deletions src/ai/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,14 @@ pub fn analyze(
);
}

let AnalyzedBody {
states,
writes_map,
init_state,
} = analyzer.analyze_body(body);
let (
AnalyzedBody {
states,
writes_map,
init_state,
},
restarted,
) = analyzer.analyze_body(body);
if conf.print_functions.contains(&tcx.def_path_str(def_id)) {
tracing::info!(
"{:?}\n{}",
Expand Down Expand Up @@ -237,6 +240,10 @@ pub fn analyze(
}
}

if restarted {
stack.clear();
}

for (loc, sp) in stack.iter() {
let must_writes: BTreeSet<_> = states
.get(loc)
Expand Down Expand Up @@ -737,8 +744,9 @@ impl<'a, 'tcx> Analyzer<'a, 'tcx> {
}
}

fn analyze_body(&mut self, body: &Body<'tcx>) -> AnalyzedBody {
fn analyze_body(&mut self, body: &Body<'tcx>) -> (AnalyzedBody, bool) {
let mut start_state = AbsState::bot();
let mut restarted = false;
start_state.writes = MustPathSet::top();
start_state.nulls = MustPathSet::top();

Expand Down Expand Up @@ -902,17 +910,21 @@ impl<'a, 'tcx> Analyzer<'a, 'tcx> {
}
}
if restart {
restarted = true;
continue 'analysis_loop;
}
}
break (states, writes_map);
};

AnalyzedBody {
states,
writes_map,
init_state,
}
(
AnalyzedBody {
states,
writes_map,
init_state,
},
restarted,
)
}

pub fn expands_path(&self, place: &AbsPath) -> Vec<AbsPath> {
Expand Down
Loading

0 comments on commit 82eae1f

Please sign in to comment.