Skip to content
Snippets Groups Projects
Commit ee66f23f authored by Andre Maroneze's avatar Andre Maroneze
Browse files

[Kernel] remove dead code from rmtmps; minor simplifications

parent e35ef29b
No related branches found
No related tags found
No related merge requests found
......@@ -48,8 +48,10 @@ open Cil_types
open Cil
module H = Hashtbl
(* Set on the command-line: *)
(* Used by external plug-ins: *)
let keepUnused = ref false
(* Possibly no longer used: *)
let rmUnusedInlines = ref false
let rmUnusedStatic = ref false
......@@ -760,9 +762,7 @@ let removeUnmarked isRoot file =
type rootsFilter = global -> bool
let isDefaultRoot = isExportedRoot
let removeUnusedTemps ?(isRoot : rootsFilter = isDefaultRoot) file =
let removeUnusedTemps ?(isRoot : rootsFilter = isExportedRoot) file =
if not !keepUnused then
begin
Kernel.debug ~dkey "Removing unused temporaries" ;
......@@ -772,8 +772,8 @@ let removeUnusedTemps ?(isRoot : rootsFilter = isDefaultRoot) file =
(* build up the root set *)
let isRoot global =
isPragmaRoot keepers global ||
isRoot global
isPragmaRoot keepers global ||
isRoot global
in
(* mark everything reachable from the global roots *)
......@@ -785,12 +785,12 @@ let removeUnusedTemps ?(isRoot : rootsFilter = isDefaultRoot) file =
(* print which original source variables were removed *)
if false && removedLocals != [] then
let count = List.length removedLocals in
if count > 2000 then
(Kernel.warning "%d unused local variables removed" count)
else
(Kernel.warning "%d unused local variables removed:@!%a"
count (Pretty_utils.pp_list ~sep:",@," Format.pp_print_string) removedLocals)
let count = List.length removedLocals in
if count > 2000 then
(Kernel.warning "%d unused local variables removed" count)
else
(Kernel.warning "%d unused local variables removed:@!%a"
count (Pretty_utils.pp_list ~sep:",@," Format.pp_print_string) removedLocals)
end
(*
......
......@@ -76,7 +76,6 @@
type rootsFilter = Cil_types.global -> bool
val isDefaultRoot : rootsFilter
val isExportedRoot : rootsFilter
val isCompleteProgramRoot : rootsFilter
......
......@@ -637,7 +637,7 @@ let () =
keep_unused_specified_function). This function is meant to be passed to
{!Rmtmps.removeUnusedTemps}. *)
let keep_entry_point ?(specs=Kernel.Keep_unused_specified_functions.get ()) g =
Rmtmps.isDefaultRoot g ||
Rmtmps.isExportedRoot g ||
match g with
| GFun({svar = v; sspec = spec},_)
| GFunDecl(spec,v,_) ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment