Skip to content

Commit

Permalink
Fix per fundec gas
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-schwarz committed Oct 14, 2024
1 parent 8272935 commit ce1866b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lifters/contextGasLifter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,15 @@ let get_gas_lifter () =
(module ContextGasLifter(GlobalGas):Spec2Spec)
else
let module PerFunctionGas:Gas = struct
module G = GasChain
module M = MapDomain.MapTop_LiftBot(CilType.Fundec)(G)
(* The order is reversed here to ensure that the minimum is used *)
(* 5 join 4 = 4 *)
module G = Lattice.Reverse(GasChain)
(* Missing bindings are bot, i.e., have maximal gas for this function *)
module M = MapDomain.MapBot_LiftTop(CilType.Fundec)(G)
let startgas () = M.empty ()
let is_exhausted f v = GobOption.exists (fun g -> g <= 0) (M.find_opt f v) (* v <= 0 *)
let callee_gas f v =
let c = Option.default (G.top ()) (M.find_opt f v) in
let c = Option.default (G.bot ()) (M.find_opt f v) in
M.add f (max 0 c-1) v
let thread_gas f v =
match Cilfacade.find_varinfo_fundec f with
Expand Down

0 comments on commit ce1866b

Please sign in to comment.