[PATCH 5/5] llvm: only compare void pointers

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

 



LLVM use a stricter type system fro it's IR than sparse does.
In the present case, sparse allow to compare pointers regardless
of their types.

This create LLVM errors if we try to simply translate, instruction
by instruction, spasre compare instructions to LLVM compares.

Fix this by casting all pointers to void *, before comparing them.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 sparse-llvm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sparse-llvm.c b/sparse-llvm.c
index 3a68d09d9..9a0a76096 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -654,6 +654,10 @@ static void output_op_compare(struct function *fn, struct instruction *insn)
 
 	switch  (LLVMGetTypeKind(LLVMTypeOf(lhs))) {
 	case LLVMPointerTypeKind:
+		lhs = value_to_pvalue(fn, &ptr_ctype, lhs);
+		rhs = value_to_pvalue(fn, &ptr_ctype, rhs);
+		/* fall through */
+
 	case LLVMIntegerTypeKind: {
 		LLVMIntPredicate op = translate_op(insn->opcode);
 
-- 
2.14.0

--
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