method vinst i =
let cstmt = Extlib.the self#current_stmt in
let handle_inst iosh i = match i with
| Asm(_,_,slvl,_,_,_) -> List.iter (fun (_,s,lv) ->
match lv with (Var v, off) ->
if s.[0] = '+' then
self#add_defids iosh (dummy_exp(Lval(Var v, off)))
(UD.VS.singleton v)
| _ -> ()) slvl
| Call(_,ce,el,_) when not (!callHasNoSideEffects i) ->
List.iter (fun e ->
let u = UD.computeUseExp e in
UD.VS.iter (fun vi ->
if IH.mem iosh vi.vid then
let ios = IH.find iosh vi.vid in
RD.IOS.iter (function
| Some i -> begin
try
let set = IH.find sidUseSetHash i in
IH.replace sidUseSetHash i (IS.add cstmt.sid set)
with Not_found ->
IH.add sidUseSetHash i (IS.singleton cstmt.sid)
end
| None -> ()) ios) u) (ce::el)
| Set((Mem _,_) as lh, rhs,_l) ->
List.iter (fun e ->
let u = UD.computeUseExp e in
UD.VS.iter (fun vi ->
if IH.mem iosh vi.vid then
let ios = IH.find iosh vi.vid in
RD.IOS.iter (function
| Some i -> begin
try
let set = IH.find sidUseSetHash i in
IH.replace sidUseSetHash i (IS.add cstmt.sid set)
with Not_found ->
IH.add sidUseSetHash i (IS.singleton cstmt.sid)
end
| None -> ()) ios) u) ([new_exp
~loc:Cil_datatype.Location.unknown
(Lval(lh));rhs])
| _ -> ()
in
ignore(super#vinst i);
match cur_rd_dat with
| None -> begin
if !debug then (Kernel.debug "DCE: instr with no cur_rd_dat\n");
DoChildren
end
| Some(_,s,iosh) -> begin
let u,d = UD.computeUseDefInstr i in
let rec loop n =
if n < 0 then () else begin
UD.VS.iter (fun vi ->
if IH.mem iosh vi.vid then
let ios = IH.find iosh vi.vid in
RD.IOS.iter (function
| Some i -> begin
try
let set = IH.find defUseSetHash i in
IH.replace defUseSetHash i (IS.add (n+s) set)
with Not_found ->
IH.add defUseSetHash i (IS.singleton (n+s))
end
| None -> ()) ios
else ()) u;
loop (n-1)
end
in
loop (UD.VS.cardinal d - 1);
handle_inst iosh i;
DoChildren
end