aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-08-14 02:17:01 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-11-17 10:04:37 +0100
commitc0229b5ce35752c7fd4a888b6351eb9a4fc20e66 (patch)
tree44b578e5bd61d83c936a166e2193019e5d90be2c
parentc786446be00802e3aa7b1b5c6caf7fed846c68fd (diff)
downloadsparse-dev-c0229b5ce35752c7fd4a888b6351eb9a4fc20e66.tar.gz
llvm: only compare void pointers
LLVM use a stricter type system for its 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, sparse's compare instructions to LLVM ones. Fix this by casting all pointers to void *, before comparing them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--sparse-llvm.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sparse-llvm.c b/sparse-llvm.c
index c0b20922..fa0689dc 100644
--- a/sparse-llvm.c
+++ b/sparse-llvm.c
@@ -661,6 +661,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);