[PATCH] D72787: [BPF] Adjust optimizations to generate kernel verifier friendly codes

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 13:29:08 PST 2020


yonghong-song added a comment.

Indeed tried kernel selftests, revert the previous workaround like

  diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
  index d22e438198cf..608a06871572 100644
  --- a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
  +++ b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c
  @@ -44,10 +44,7 @@ int sysctl_tcp_mem(struct bpf_sysctl *ctx)
          unsigned long tcp_mem[TCP_MEM_LOOPS] = {};
          char value[MAX_VALUE_STR_LEN];
          unsigned char i, off = 0;
  -       /* a workaround to prevent compiler from generating
  -        * codes verifier cannot handle yet.
  -        */
  -       volatile int ret;
  +       int ret;
   
          if (ctx->write)
                  return 0;

The optimization kicked in. The adjust-instcombine-1.ll is exactly for the above case. But kernel verifier needs some work to handle 32bit sign comparisons, which I will work on later.

The adjust-instcombine-2.ll is also derived from a real use case inside Facebook.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72787/new/

https://reviews.llvm.org/D72787





More information about the llvm-commits mailing list