[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,18 +129,21 @@ open struct
(ref 0, String.Tbl.create ()) )
in
let name =
match Llvm.classify_type (Llvm.type_of llv) with
| Void -> (
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.classify_value llv with
| Instruction (Call | Invoke) -> (
match
Llvm.value_name
(Llvm.operand llv (Llvm.num_operands llv - 1))
Llvm.(value_name (operand llv (num_operands llv - 1)))
with
| "" -> Int.to_string (!next - 1)
| s -> s )
| _ -> "void"
| s -> s
in
match String.Tbl.find void_tbl fname with
| None ->
@ -150,7 +153,7 @@ open struct
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