1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(**************************************************************************)(* This file is part of BINSEC. *)(* *)(* Copyright (C) 2016-2024 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* you can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file licenses/LGPLv2.1). *)(* *)(**************************************************************************)openTypesmoduleFlags:Exec.PLUGIN=structletname="sse-kill-flags-at-return"letgrammar_extension=[]letinstruction_printer=Noneletdeclaration_printer=Noneletextension:typeab.(moduleEXPLORATION_STATISTICS)->(modulePath.Swithtypet=a)->(moduleSTATEwithtypet=b)->(moduleExec.EXTENSIONwithtypepath=aandtypestate=b)option=fun_statspathstate->letshordlived_flags=Isa_helper.get_shortlived_flags()inifshordlived_flags<>[]&&Options.KillFlagsAtReturn.get()thenSome(modulestructmoduleP=(valpath)moduleS=(valstate)typepath=P.tandstate=S.tletinitialization_callback=Noneletdeclaration_callback=Noneletinstruction_callback=Noneletprocess_handler:typea.(moduleIr.GRAPHwithtypet=a)->a->unit=fungraph->letmoduleG=(valgraph)infungraph->G.iter_exits(funvertex->ifG.is_new_vertexgraphvertexthenmatchG.nodegraphvertexwith|Goto{tag=Return;_}|Terminator(Jump{tag=Return;_})->List.iter(funvar->ignore(G.insert_beforegraphvertex(Forgetvar)))shordlived_flags|_->())graphletprocess_callback=Someprocess_handlerletbuiltin_callback=Noneletbuiltin_printer=Noneletat_exit_callback=Noneend)elseNoneendlet()=Exec.register_plugin(moduleFlags)