sparse-llvm failure when comparing pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux