@@ -408,6 +408,14 @@ static LLVMValueRef pseudo_to_value(struct function *fn, struct instruction *ins
return result;
}
+static LLVMValueRef pseudo_to_rvalue(struct function *fn, struct instruction *insn, pseudo_t pseudo)
+{
+ LLVMValueRef val = pseudo_to_value(fn, insn, pseudo);
+ LLVMTypeRef dtype = symbol_type(insn->type);
+
+ return LLVMBuildBitCast(fn->builder, val, dtype, "");
+}
+
static LLVMValueRef calc_gep(LLVMBuilderRef builder, LLVMValueRef base, LLVMValueRef off)
{
LLVMTypeRef type = LLVMTypeOf(base);
@@ -655,7 +663,7 @@ static void output_op_store(struct function *fn, struct instruction *insn)
addr = calc_memop_addr(fn, insn);
- target_in = pseudo_to_value(fn, insn, insn->target);
+ target_in = pseudo_to_rvalue(fn, insn, insn->target);
/* perform store */
LLVMBuildStore(fn->builder, target_in, addr);
@@ -744,7 +752,7 @@ static void output_op_call(struct function *fn, struct instruction *insn)
i = 0;
FOR_EACH_PTR(insn->arguments, arg) {
- args[i++] = pseudo_to_value(fn, arg, arg->src);
+ args[i++] = pseudo_to_rvalue(fn, arg, arg->src);
} END_FOR_EACH_PTR(arg);
func = pseudo_to_value(fn, insn, insn->func);
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- sparse-llvm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)