Re: [PATCH, bpf-llvm] Fix bug on silently truncating 64-bit immediate

Jiong Wang

On 12/10/2017 12:04, Jesper Dangaard Brouer wrote:
On Thu, 12 Oct 2017 06:21:30 -0400
Jiong Wang <> wrote:

We came across an llvm bug when compiling some testcases that 64-bit
immediates are silently truncated into 32-bit and then packed into
BPF_JMP | BPF_K encoding. This caused comparison with wrong value.
I think you send this to the wrong mailing list... this looks like a
patch against the LLVM source code.

Shouldn't you send to: llvm-dev@... ?
Hi Jesper,

I am thinking the users & developers of eBPF llvm are quite focused in
xdp-newbies and iovisor-dev, so if the code is related with user visible
effect, for example bug fix, and if the code change is straightforward
and small, I tend to just send it to these two so related user could be
aware of it in case they are encountering the same problem, and then this
patch could be posted to llvm review site (

This bug looks to be introduced by r308080.
This looks like a very recent change:
Sat Jul 15 05:41:42 2017 UTC (2 months, 4 weeks ago)

(As you are sending this to a user mailing list: xdp-newbies@...)

I want to know if this have made it into a LLVM release? and which release?
This has not been made into any LLVM official release.
The bug may show up if the user is trying to use distributor snapshop release.

As the git-repo[1] replica of LLVM SVN-repo does not git-tag the
releases, I could not answer this question myself via the command:

$ git describe --contains 7c423e0690


The Select_Ri pattern is
supposed to be lowered into J*_Ri while the latter only support 32-bit
immediate encoding, therefore Select_Ri should have similar immediate
predicate check as what J*_Ri are doing.

Reported-by: Jakub Kicinski <jakub.kicinski@...>
Signed-off-by: Jiong Wang <>
lib/Target/BPF/BPFISelLowering.cpp | 8 ++++++--
lib/Target/BPF/ | 2 +-
test/CodeGen/BPF/select_ri.ll | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 3 deletions(-)


Join to automatically receive all group messages.