[PATCH] D85570: [RFC] BPF: add AdjustOpt IR pass to generate verifier friendly codes
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 7 16:43:57 PDT 2020
yonghong-song created this revision.
yonghong-song added reviewers: ast, anakryiko.
Herald added subscribers: llvm-commits, hiraditya, mgorny.
Herald added a project: LLVM.
yonghong-song requested review of this revision.
Add IR phase, AdjustOpt, before main optimization. This is to modify
IR to restrict certain downward optimizations in order to generate
verifier friendly code.
Internally, user barrier like
asm volatile ("" : "=r"(var) : "0"(var));
is used. The asm code specifies the use and define of "var" which
prevents optimization involving "var" across asm code.
For example, removing the following workaround,
- a/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c +++ b/tools/testing/selftests/bpf/progs/test_sysctl_loop1.c @@ -47,7 +47,7 @@ int sysctl_tcp_mem(struct bpf_sysctl *ctx) /* a workaround to prevent compiler from generating
- codes verifier cannot handle yet. */
- volatile int ret; + int ret;
this patch is able to generate code which passed the verifier.
Three specific cases are handled in this patch:
- possible instcombine with two conditions in the same basic block
- possible instcombine with two conditions in different basic blocks
- possible speculative code motion
This patch is still in RFC stage and I will need to study and
implement for other known cases and add tests.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D85570
Files:
llvm/lib/Target/BPF/BPF.h
llvm/lib/Target/BPF/BPFAdjustOpt.cpp
llvm/lib/Target/BPF/BPFTargetMachine.cpp
llvm/lib/Target/BPF/CMakeLists.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85570.284091.patch
Type: text/x-patch
Size: 8921 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200807/b3266d1c/attachment.bin>
More information about the llvm-commits
mailing list