[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
| Call -> (
match Llvm.(value_name (operand i (num_arg_operands i))) with
| "llvm.dbg.declare" -> (
match Llvm.(get_mdnode_operands (operand i 0)) with
| [|var|] when not (String.is_empty (Llvm.value_name var)) ->
add ~key:var ~data:loc
| _ ->
warn "could not find variable for debug info %a at %a"
pp_llvalue (Llvm.operand i 0) Loc.pp loc )
| "llvm.dbg.declare" ->
let md = Llvm.(get_mdnode_operands (operand i 0)) in
if not (Array.is_empty md) then add ~key:md.(0) ~data:loc
else
warn
"could not find variable for debug info %a at %a with \
metadata %a"
pp_llvalue (Llvm.operand i 0) Loc.pp loc
(List.pp ", " pp_llvalue) (Array.to_list md)
| _ -> () )
| _ -> ()
in

Loading…
Cancel
Save