* sparse-llvm subtraction of one pointer from another should result in int difference
@ 2017-03-13 20:59 Dibyendu Majumdar
2017-03-19 15:37 ` Luc Van Oostenryck
0 siblings, 1 reply; 2+ messages in thread
From: Dibyendu Majumdar @ 2017-03-13 20:59 UTC (permalink / raw)
To: Linux-Sparse
Hi,
I was investigating an error reported while compiling minilua (please
see my earlier post on minlua) and I found that one of the issues was
that the result of subtracting one pointer from another is not handled
correctly in sparse-llvm. I think the OP_SUB implementation should be
changed as follows:
case OP_SUB:
if (symbol_is_fp_type(C, insn->type))
target = LLVMBuildFSub(fn->builder, lhs, rhs, target_name);
else if (LLVMGetTypeKind(LLVMTypeOf(lhs)) == LLVMPointerTypeKind &&
LLVMGetTypeKind(LLVMTypeOf(rhs)) == LLVMPointerTypeKind) {
// Both arguments are pointer
// Result will be integer
lhs = LLVMBuildPtrToInt(fn->builder, lhs,
LLVMIntType(C->target->bits_in_pointer), "");
rhs = LLVMBuildPtrToInt(fn->builder, rhs,
LLVMIntType(C->target->bits_in_pointer), "");
target = LLVMBuildSub(fn->builder, lhs, rhs, target_name);
}
else
target = LLVMBuildSub(fn->builder, lhs, rhs, target_name);
break;
Thanks and Regards
Dibyendu
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-19 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 20:59 sparse-llvm subtraction of one pointer from another should result in int difference Dibyendu Majumdar
2017-03-19 15:37 ` Luc Van Oostenryck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox