[sledge] Revise name generation for return blocks of void-returning functions

Summary:
Current code partially tries to handle Invoke, but incorrectly, and
these names are only needed for Call. So this diff revises this to be
slightly simpler and less confusing.

Reviewed By: jvillard

Differential Revision: D25146157

fbshipit-source-id: ead4f6f31
master
Josh Berdine 4 years ago committed by Facebook GitHub Bot
parent c346c5ec7f
commit 9e3ca541e8

@ -129,28 +129,31 @@ open struct
(ref 0, String.Tbl.create ()) )
in
let name =
match Llvm.classify_type (Llvm.type_of llv) with
| Void -> (
let fname =
match Llvm.classify_value llv with
| Instruction (Call | Invoke) -> (
match
Llvm.value_name
(Llvm.operand llv (Llvm.num_operands llv - 1))
with
| "" -> Int.to_string (!next - 1)
| s -> s )
| _ -> "void"
in
match String.Tbl.find void_tbl fname with
| None ->
String.Tbl.set void_tbl ~key:fname ~data:1 ;
fname ^ ".void"
| Some count ->
String.Tbl.set void_tbl ~key:fname ~data:(count + 1) ;
String.concat ~sep:""
[fname; ".void."; Int.to_string count] )
| _ -> (
if
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 =
match
Llvm.(value_name (operand llv (num_operands llv - 1)))
with
| "" -> Int.to_string (!next - 1)
| s -> s
in
match String.Tbl.find void_tbl fname with
| None ->
String.Tbl.set void_tbl ~key:fname ~data:1 ;
fname ^ ".void"
| 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
| "" ->
(* anonymous values take the next SSA name *)
@ -162,7 +165,7 @@ open struct
| Some _ ->
(* escape to avoid clash with names of anonymous values *)
"\"" ^ name ^ "\""
| None -> name ) )
| None -> name )
in
SymTbl.set sym_tbl ~key:llv ~data:(name, loc)
end

Loading…
Cancel
Save