@ -129,28 +129,31 @@ open struct
( ref 0 , String . Tbl . create () ) )
( ref 0 , String . Tbl . create () ) )
in
in
let name =
let name =
match Llvm . classify_type ( Llvm . type_of llv ) with
if
| Void -> (
Poly . (
let fname =
Llvm . classify_value llv = Instruction Call
match Llvm . classify_value llv with
&& Llvm . classify_type ( Llvm . type_of llv ) = Void )
| Instruction ( Call | Invoke ) -> (
then (
match
(* LLVM does not give unique names to the result of
Llvm . value_name
void - returning function calls . We need unique names for
( Llvm . operand llv ( Llvm . num_operands llv - 1 ) )
these as they determine the labels of newly - created return
with
blocks . * )
| " " -> Int . to_string ( ! next - 1 )
let fname =
| s -> s )
match
| _ -> " void "
Llvm . ( value_name ( operand llv ( num_operands llv - 1 ) ) )
in
with
match String . Tbl . find void_tbl fname with
| " " -> Int . to_string ( ! next - 1 )
| None ->
| s -> s
String . Tbl . set void_tbl ~ key : fname ~ data : 1 ;
in
fname ^ " .void "
match String . Tbl . find void_tbl fname with
| Some count ->
| None ->
String . Tbl . set void_tbl ~ key : fname ~ data : ( count + 1 ) ;
String . Tbl . set void_tbl ~ key : fname ~ data : 1 ;
String . concat ~ sep : " "
fname ^ " .void "
[ fname ; " .void. " ; Int . to_string count ] )
| Some count ->
| _ -> (
String . Tbl . set void_tbl ~ key : fname ~ data : ( count + 1 ) ;
String . concat ~ sep : " "
[ fname ; " .void. " ; Int . to_string count ] )
else
match Llvm . value_name llv with
match Llvm . value_name llv with
| " " ->
| " " ->
(* anonymous values take the next SSA name *)
(* anonymous values take the next SSA name *)
@ -162,7 +165,7 @@ open struct
| Some _ ->
| Some _ ->
(* escape to avoid clash with names of anonymous values *)
(* escape to avoid clash with names of anonymous values *)
" \" " ^ name ^ " \" "
" \" " ^ name ^ " \" "
| None -> name ) )
| None -> name )
in
in
SymTbl . set sym_tbl ~ key : llv ~ data : ( name , loc )
SymTbl . set sym_tbl ~ key : llv ~ data : ( name , loc )
end
end