From 16a9b9f7d232ada41b6f5f0c98bfdbfa39f9fb34 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Wed, 2 Dec 2020 13:49:22 -0800 Subject: [PATCH] [sledge] Fix translation of alloca Summary: The size could sometimes be wrong. Reviewed By: jvillard Differential Revision: D25196730 fbshipit-source-id: 26c6d0d60 --- sledge/cli/frontend.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sledge/cli/frontend.ml b/sledge/cli/frontend.ml index 2df115a29..f05b8a800 100644 --- a/sledge/cli/frontend.ml +++ b/sledge/cli/frontend.ml @@ -1080,11 +1080,11 @@ let xlate_instr : emit_inst ~prefix:(pre0 @ pre1) (Inst.store ~ptr ~exp ~len ~loc) | Alloca -> let reg = xlate_name x instr in - let rand = Llvm.operand instr 0 in - let prefix, arg = xlate_value x rand in - let num = convert_to_siz (xlate_type x (Llvm.type_of rand)) arg in + let num_elts = Llvm.operand instr 0 in + let prefix, num = xlate_value x num_elts in + let num = convert_to_siz (xlate_type x (Llvm.type_of num_elts)) num in assert (Poly.(Llvm.classify_type (Llvm.type_of instr) = Pointer)) ; - let len = size_of x (Llvm.type_of instr) in + let len = size_of x (Llvm.element_type (Llvm.type_of instr)) in emit_inst ~prefix (Inst.alloc ~reg ~num ~len ~loc) | Call -> ( let llcallee = Llvm.operand instr (Llvm.num_operands instr - 1) in