123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263(**************************************************************************)(* *)(* SPDX-License-Identifier LGPL-2.1 *)(* Copyright (C) *)(* CEA (Commissariat à l'énergie atomique et aux énergies alternatives) *)(* *)(**************************************************************************)letconcurrent_writesshared_bases=letmoduleAnalyzer=(valAnalysis.current_analyzer())inmatchAnalyzer.Dom.getMt_domain.Domain.keywith(* Domain disabled, no information about writes *)|None->Position.Local.Set.empty(* Domain enabled *)|Some_extract->letadd_posstmtcs_stateacc=letpos=Position.localstmtcsin(* TODO: Maybe take the memory read/written for all callstacks of the
given statement? (can be done directly by Inout_access). *)letfilter=Inout_access.keep_globals_onlyinletaccesses=Inout_access.at~filterposinletwritten_bases=Locations.Zone.get_basesaccesses.writeinifBase.SetLattice.(intersects(injectshared_bases)written_bases)thenPosition.Local.Set.add(stmt,cs)accelseaccinletadd_stmtaccstmt=letis_write_stmt=matchstmt.Cil_types.skindwith|Cil_types.Instr(Set_|Call_|Local_init_)->true|_->falseinifis_write_stmtthenmatchAnalyzer.get_stmt_state_by_callstack~after:truestmtwith|`Top|`Bottom->acc(* TODO: handle Tops *)|`Valuetable->Callstack.Hashtbl.fold(add_posstmt)tableaccelseaccinletadd_kfkfacc=matchkf.Cil_types.fundecwith|Declaration_->acc|Definition(fundec,_)->List.fold_leftadd_stmtaccfundec.Cil_types.sallstmtsinGlobals.Functions.foldadd_kfPosition.Local.Set.emptyletshared_basesanalysis_state=letshared_zones=analysis_state.Mt_thread.concurrent_accessesinmatchLocations.Zone.get_basesshared_zoneswith|Top->assertfalse|Setzones->zonesletadd_last_analysisanalysis_state=letmoduleAnalyzer=(valAnalysis.current_analyzer())inletbases=shared_basesanalysis_stateinletwrites=concurrent_writesbasesinletthread=analysis_state.curr_thread.th_eva_threadinmatchAnalyzer.Interferences.add_last_analysisthreadwritesbaseswith|Updated->Mt_thread.iter_threadsanalysis_state(funth->Mt_thread.ThreadState.recompute_becausethInterferencesChanged)|NoChanges->()