@ -129,18 +129,21 @@ 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 . (
Llvm . classify_value llv = Instruction Call
&& Llvm . classify_type ( Llvm . type_of llv ) = Void )
then (
(* LLVM does not give unique names to the result of
void - returning function calls . We need unique names for
these as they determine the labels of newly - created return
blocks . * )
let fname =
let fname =
match Llvm . classify_value llv with
| Instruction ( Call | Invoke ) -> (
match
match
Llvm . value_name
Llvm . ( value_name ( operand llv ( num_operands llv - 1 ) ) )
( Llvm . operand llv ( Llvm . num_operands llv - 1 ) )
with
with
| " " -> Int . to_string ( ! next - 1 )
| " " -> Int . to_string ( ! next - 1 )
| s -> s )
| s -> s
| _ -> " void "
in
in
match String . Tbl . find void_tbl fname with
match String . Tbl . find void_tbl fname with
| None ->
| None ->
@ -150,7 +153,7 @@ open struct
String . Tbl . set void_tbl ~ key : fname ~ data : ( count + 1 ) ;
String . Tbl . set void_tbl ~ key : fname ~ data : ( count + 1 ) ;
String . concat ~ sep : " "
String . concat ~ sep : " "
[ fname ; " .void. " ; Int . to_string count ] )
[ 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