* sparse-llvm failure when comparing pointers
@ 2017-03-13 23:47 Dibyendu Majumdar
2017-03-19 15:33 ` Luc Van Oostenryck
0 siblings, 1 reply; 2+ messages in thread
From: Dibyendu Majumdar @ 2017-03-13 23:47 UTC (permalink / raw)
To: Linux-Sparse
Pointer comparions are failing LLVM validation if they are not the
same type. One way to resolve this is to cast the pointer to integer
before comparing. I am trying out following approach. In
output_op_compare(), I separated out the pointer case as follows:
switch (LLVMGetTypeKind(LLVMTypeOf(lhs))) {
case LLVMPointerTypeKind: {
lhs = LLVMBuildPtrToInt(fn->builder, lhs,
LLVMIntType(C->target->bits_in_pointer), "");
if (LLVMGetTypeKind(LLVMTypeOf(rhs)) == LLVMPointerTypeKind) {
rhs = LLVMBuildPtrToInt(fn->builder, rhs,
LLVMIntType(C->target->bits_in_pointer), "");
}
LLVMIntPredicate op = translate_op(insn->opcode);
target = LLVMBuildICmp(fn->builder, op, lhs, rhs, target_name);
break;
}
case LLVMIntegerTypeKind: {
LLVMIntPredicate op = translate_op(insn->opcode);
target = LLVMBuildICmp(fn->builder, op, lhs, rhs, target_name);
break;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-19 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-13 23:47 sparse-llvm failure when comparing pointers Dibyendu Majumdar
2017-03-19 15:33 ` 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