[llvm] [BPF] Support Jump Table (PR #149715)

Anton Protopopov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 09:43:31 PDT 2025


aspsk wrote:

Hi @yonghong-song 

> @aspsk I just rebased on top of latest llvm-project main branch. Based on discussion with @4ast, we will not introduce v5 at this moment. So jump table support will be in v4. The reason is that adding more and more versions are not scale.

Yes, makes sense, plus there is potentially yet another instruction to be added for static keys.

> With this llvm version, I tried with latest bpf-next with your current patch set https://lore.kernel.org/bpf/20250816180631.952085-1-a.s.protopopov@gmail.com/T/#mbfb4fc7728228e74fd17c5147a64f21933b9987f

Thanks! The current version is here: https://github.com/aspsk/bpf-next/tree/wip/indirect-jumps
 
> To build bpf selftest, I got the following libbpf warnings like
> 
> ```
> libbpf: elf: skipping unrecognized data section(6) .comment
> libbpf: elf: skipping unrecognized data section(6) .comment
> libbpf: elf: skipping section(7) .note.GNU-stack (size 0)
> libbpf: elf: skipping section(7) .note.GNU-stack (size 0)
> ```

Do you think this is related to the patch or just to the latest llvm?

> I did a hack like below
> 
> ```
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 606d7d5a48a7..51e390eb7141 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -742,7 +742,7 @@ $(eval $(call DEFINE_TEST_RUNNER,test_progs,no_alu32))
>  # Define test_progs-cpuv4 test runner.
>  ifneq ($(CLANG_CPUV4),)
>  TRUNNER_BPF_BUILD_RULE := CLANG_CPUV4_BPF_BUILD_RULE
> -TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) -DENABLE_ATOMICS_TESTS
> +TRUNNER_BPF_CFLAGS := $(BPF_CFLAGS) $(CLANG_CFLAGS) -DENABLE_ATOMICS_TESTS -mllvm -bpf-min-jump-table-entries=3
>  $(eval $(call DEFINE_TEST_RUNNER,test_progs,cpuv4))
>  endif
> ```
> 
> to allow jump table with switch cases 3 or above.
> 
> When running `test_progs-cpuv4 -j`, I got some failures like
> [...] snip

Thanks a lot! I will run all tests with `-bpf-min-jump-table-entries=3` tomorrow with my current branch and check the failures. 

> I think maybe it is time to send another revision?

Planning to send it this week. (WIP, but I still need to address one comment from Eduard and one from Andrii.)

https://github.com/llvm/llvm-project/pull/149715


More information about the llvm-commits mailing list