From fb2f33a60bf9e378b9c2cf63df42f3149a279a0e Mon Sep 17 00:00:00 2001
From: Alastair Robertson <alastair@ajor.co.uk>
Date: Sun, 25 Jun 2017 23:30:24 +0100
Subject: [PATCH] codegen: Cast all binary expressions to 64-bit ints

Allows statements such as '@x = (1 == 2)' to work
---
 src/codegen_llvm.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/codegen_llvm.cpp b/src/codegen_llvm.cpp
index 3ad5bba..6ac8adb 100644
--- a/src/codegen_llvm.cpp
+++ b/src/codegen_llvm.cpp
@@ -114,6 +114,7 @@ void CodegenLLVM::visit(Binop &binop)
     case bpftrace::Parser::token::BXOR:  expr_ = b_.CreateXor    (lhs, rhs); break;
     default: abort();
   }
+  expr_ = b_.CreateIntCast(expr_, b_.getInt64Ty(), false);
 }
 
 void CodegenLLVM::visit(Unop &unop)
@@ -195,10 +196,7 @@ void CodegenLLVM::visit(Predicate &pred)
 
   pred.expr->accept(*this);
 
-  expr_ = b_.CreateICmpEQ(
-      b_.CreateIntCast(expr_, b_.getInt64Ty(), true),
-      b_.getInt64(0),
-      "predcond");
+  expr_ = b_.CreateICmpEQ(expr_, b_.getInt64(0), "predcond");
 
   b_.CreateCondBr(expr_, pred_false_block, pred_true_block);
   b_.SetInsertPoint(pred_false_block);
-- 
2.30.9