From 78b2835936802efdc56bae8ceb026d2041e69596 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 26 Apr 2019 12:02:41 -0700 Subject: [PATCH] [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 --- sledge/src/llair/frontend.ml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index 9feec97c1..5e8353af0 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -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