@ -72,14 +72,23 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit)
~ col : ( Llvm . get_debug_loc_column i )
~ col : ( Llvm . get_debug_loc_column i )
in
in
let add_sym llv loc =
let add_sym llv loc =
let next , void_tbl =
let maybe_scope =
let scope =
match Llvm . classify_value llv with
match Llvm . classify_value llv with
| Argument -> ` Fun ( Llvm . param_parent llv )
| Argument -> Some ( ` Fun ( Llvm . param_parent llv ) )
| BasicBlock -> ` Fun ( Llvm . block_parent ( Llvm . block_of_value llv ) )
| BasicBlock ->
| Instruction _ -> ` Fun ( Llvm . block_parent ( Llvm . instr_parent llv ) )
Some ( ` Fun ( Llvm . block_parent ( Llvm . block_of_value llv ) ) )
| _ -> ` Mod ( Llvm . global_parent llv )
| Instruction _ ->
Some ( ` Fun ( Llvm . block_parent ( Llvm . instr_parent llv ) ) )
| GlobalVariable | Function -> Some ( ` Mod ( Llvm . global_parent llv ) )
| UndefValue -> None
| _ ->
warn " Unexpected type of llv, might crash: %a " pp_llvalue llv () ;
Some ( ` Mod ( Llvm . global_parent llv ) )
in
in
match maybe_scope with
| None -> ()
| Some scope ->
let next , void_tbl =
Hashtbl . find_or_add scope_tbl scope ~ default : ( fun () ->
Hashtbl . find_or_add scope_tbl scope ~ default : ( fun () ->
( ref 0 , Hashtbl . Poly . create () ) )
( ref 0 , Hashtbl . Poly . create () ) )
in
in
@ -103,7 +112,8 @@ let ( (scan_names_and_locs : Llvm.llmodule -> unit)
fname ^ " .void "
fname ^ " .void "
| Some count ->
| Some count ->
Hashtbl . set void_tbl ~ key : fname ~ data : ( count + 1 ) ;
Hashtbl . set void_tbl ~ key : fname ~ data : ( count + 1 ) ;
String . concat_array [| fname ; " .void. " ; Int . to_string count |] )
String . concat_array
[| fname ; " .void. " ; Int . to_string count |] )
| _ -> (
| _ -> (
match Llvm . value_name llv with
match Llvm . value_name llv with
| " " ->
| " " ->
@ -1404,4 +1414,6 @@ let translate : string list -> Llair.t =
Llvm . dispose_module llmodule ;
Llvm . dispose_module llmodule ;
Llair . mk ~ globals ~ functions
Llair . mk ~ globals ~ functions
| >
| >
[ % Trace . retn fun { pf } _ -> pf " " ]
[ % Trace . retn fun { pf } _ ->
pf " number of globals %d, number of functions %d " ( List . length globals )
( List . length functions ) ]