From e415b8f22e4fb09ed411cd6f96d36ca9e1a9489b Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 12 Nov 2020 16:37:17 -0800 Subject: [PATCH] [sledge] Change Typ.is_sized to remove hack for opaque types Summary: It happens so seldomly that it is not worth it to optimistically assume that linking will make opaque types sized. In particular, it is incongruent for `Typ.is_sized` to hold and then `Typ.size_of` to raise. Reviewed By: jvillard Differential Revision: D24772956 fbshipit-source-id: 96a72a5cf --- sledge/cli/frontend.ml | 5 ++++- sledge/src/llair/typ.ml | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sledge/cli/frontend.ml b/sledge/cli/frontend.ml index e427dac58..9d13d4068 100644 --- a/sledge/cli/frontend.ml +++ b/sledge/cli/frontend.ml @@ -489,7 +489,10 @@ and xlate_value ?(inline = false) stk : let name = find_name (Llvm.operand llv 1) in ([], Exp.label ~parent ~name) | UndefValue -> - let typ = xlate_type x (Llvm.type_of llv) in + let llt = Llvm.type_of llv in + let typ = xlate_type x llt in + if not (Typ.is_sized typ) then + todo "types with undetermined size: %a" pp_lltype llt () ; let name = Printf.sprintf "undef_%i" !undef_count in let loc = Loc.none in let reg = Reg.program typ name in diff --git a/sledge/src/llair/typ.ml b/sledge/src/llair/typ.ml index 3a6adffc0..e8b480104 100644 --- a/sledge/src/llair/typ.ml +++ b/sledge/src/llair/typ.ml @@ -57,9 +57,8 @@ let pp_defn fs = function (** Invariants *) let is_sized = function - | Function _ -> false + | Function _ | Opaque _ -> false | Integer _ | Float _ | Pointer _ | Array _ | Tuple _ | Struct _ -> true - | Opaque _ -> (* optimistically assume linking will make it sized *) true let invariant t = let@ () = Invariant.invariant [%here] t [%sexp_of: t] in