From d7697181920ee7c75470d234f41fbcca108e3f2a Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Fri, 8 Mar 2019 07:07:24 -0800 Subject: [PATCH] [sledge] Add missing i32 to i64 conversion for gep indices Reviewed By: jvillard Differential Revision: D14344289 fbshipit-source-id: 10e99f37e --- sledge/src/llair/exp.ml | 6 +++++- sledge/src/llair/frontend.ml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sledge/src/llair/exp.ml b/sledge/src/llair/exp.ml index bff555aeb..34ed8888f 100644 --- a/sledge/src/llair/exp.ml +++ b/sledge/src/llair/exp.ml @@ -366,7 +366,11 @@ let typ_of = function let typ = typ_of let type_check e typ = - assert (Option.for_all ~f:(Typ.castable typ) (typ_of e)) + assert ( + Option.for_all ~f:(Typ.castable typ) (typ_of e) + || fail "%a@ : %a not <:@ %a" pp e Typ.pp + (Option.value_exn (typ_of e)) + Typ.pp typ ) let type_check2 e f typ = type_check e typ ; type_check f typ diff --git a/sledge/src/llair/frontend.ml b/sledge/src/llair/frontend.ml index b59b87e31..e565fef93 100644 --- a/sledge/src/llair/frontend.ml +++ b/sledge/src/llair/frontend.ml @@ -532,7 +532,11 @@ and xlate_opcode : x -> Llvm.llvalue -> Llvm.Opcode.t -> Exp.t = [%Trace.call fun {pf} -> pf "%i %a" i pp_llvalue (Llvm.operand llv i)] ; - let idx = xlate_rand i in + let idx = + Exp.convert ~dst:Typ.siz + ~src:(xlate_type x (Llvm.type_of (Llvm.operand llv i))) + (xlate_rand i) + in ( if i = 1 then let base = xlate_rand 0 in let lltyp = Llvm.type_of (Llvm.operand llv 0) in