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

Jesper Dangaard Brouer

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@... ?

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?

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(-)
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat

Join to automatically receive all group messages.