[sledge] Improve lookup of debug locations

Summary:
In some cases there were extra metadata operands (such as alignment of
an alloc) which would cause the debug locations to not be recorded.

Reviewed By: mbouaziz

Differential Revision: D15098816

fbshipit-source-id: a7e83f590
master
Josh Berdine 6 years ago committed by Facebook Github Bot
parent 564bd344fc
commit 78b2835936

@ -68,13 +68,15 @@ let (scan_locs : Llvm.llmodule -> unit), (find_loc : Llvm.llvalue -> Loc.t)
match Llvm.instr_opcode i with match Llvm.instr_opcode i with
| Call -> ( | Call -> (
match Llvm.(value_name (operand i (num_arg_operands i))) with match Llvm.(value_name (operand i (num_arg_operands i))) with
| "llvm.dbg.declare" -> ( | "llvm.dbg.declare" ->
match Llvm.(get_mdnode_operands (operand i 0)) with let md = Llvm.(get_mdnode_operands (operand i 0)) in
| [|var|] when not (String.is_empty (Llvm.value_name var)) -> if not (Array.is_empty md) then add ~key:md.(0) ~data:loc
add ~key:var ~data:loc else
| _ -> warn
warn "could not find variable for debug info %a at %a" "could not find variable for debug info %a at %a with \
pp_llvalue (Llvm.operand i 0) Loc.pp loc ) metadata %a"
pp_llvalue (Llvm.operand i 0) Loc.pp loc
(List.pp ", " pp_llvalue) (Array.to_list md)
| _ -> () ) | _ -> () )
| _ -> () | _ -> ()
in in

Loading…
Cancel
Save