Commit 64f706ce authored by Brendan Gregg's avatar Brendan Gregg Committed by GitHub

Merge pull request #115 from iovisor/bug

allow u32 binops and map keys
parents 8fef8ec5 053cd6c5
...@@ -656,6 +656,10 @@ void CodegenLLVM::visit(Binop &binop) ...@@ -656,6 +656,10 @@ void CodegenLLVM::visit(Binop &binop)
binop.right->accept(*this); binop.right->accept(*this);
rhs = expr_; rhs = expr_;
// promote int to 64-bit
lhs = b_.CreateIntCast(lhs, b_.getInt64Ty(), false);
rhs = b_.CreateIntCast(rhs, b_.getInt64Ty(), false);
switch (binop.op) { switch (binop.op) {
case bpftrace::Parser::token::EQ: expr_ = b_.CreateICmpEQ (lhs, rhs); break; case bpftrace::Parser::token::EQ: expr_ = b_.CreateICmpEQ (lhs, rhs); break;
case bpftrace::Parser::token::NE: expr_ = b_.CreateICmpNE (lhs, rhs); break; case bpftrace::Parser::token::NE: expr_ = b_.CreateICmpNE (lhs, rhs); break;
......
...@@ -1384,6 +1384,13 @@ void BPFtrace::sort_by_key(std::vector<SizedType> key_args, ...@@ -1384,6 +1384,13 @@ void BPFtrace::sort_by_key(std::vector<SizedType> key_args,
return *(uint64_t*)(a.first.data() + arg_offset) < *(uint64_t*)(b.first.data() + arg_offset); return *(uint64_t*)(a.first.data() + arg_offset) < *(uint64_t*)(b.first.data() + arg_offset);
}); });
} }
else if (arg.size == 4)
{
std::stable_sort(values_by_key.begin(), values_by_key.end(), [&](auto &a, auto &b)
{
return *(uint32_t*)(a.first.data() + arg_offset) < *(uint32_t*)(b.first.data() + arg_offset);
});
}
else else
abort(); abort();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment