On 9/23/20 9:21 AM, Andrii Nakryiko wrote:
On Wed, Sep 23, 2020 at 9:15 AM Lorenz Bauer <lmb@xxxxxxxxxxxxxx> wrote:
On Wed, 23 Sep 2020 at 08:17, Yonghong Song <yhs@xxxxxx> wrote:
Hi,
I have spent some time to add additional logic in llvm BPF backend
in order to generate verifier friendly code.
The first patch is:
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D87153&d=DwIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=-_pOOUYXONnvN0eDqgPfyjzi3pU0ZJV-eT7LViel2u0&s=1lUhNqSXg_nXYENMizJLX-GtAxNqKETBdD50CC4wB-U&e=
which moves CORE relocation builtin handling from in late IR
optimization (after inlining and major optimizations)
to in early IR optimization (before inlining and any optimizations).
The reason is to prevent harmful CSEs.
But this change may change how compiler do optimizations.
The patch can pass bpf selftests in latest bpf-next.
Andrii helped it can also pass bcc/libbpf-tools.
If your code uses COREs, esp. having a lot of subroutines
and/or loops, it would be good to give a try with new patch
to see whether there are any issues or not. In my case,
for one of our internal applications with lots of subroutines
and loops, inlining all subroutines and unrolling all loops
will cause register spills which cannot be handled by
the verifier, while existing llvm won't have issue.
Hi Yonghong,
We currently don't use CORE (outside of bcc, etc.), so there isn't
much I can test I guess? Please let me know if there is something I
can do for your follow up patches.
It would still be good if you could test all three Clang/LLVM patches
Yonghong referenced. The latter two are not CO-RE-specific. Thanks!
Right, the first patch (I described here) in 3-patch series
Patch 1: https://reviews.llvm.org/D87153
is related to CORE and will be a noop for program without CORE.
The second and the third patches:
Patch 2: https://reviews.llvm.org/D85570
Patch 3: https://reviews.llvm.org/D87428
is not related to CORE and intends to solve some verifier
failures related to value range. Please see commit message for
the above two patches.
Agree that it would be still be good to test all of them, esp,
if you have asm/source workaround, it will be curious to see how many
those can be removed.
Thanks!
And pedantic nit: BCC doesn't use CO-RE, it just does runtime
compilation using local kernel headers with exact memory layout of
kernel structs.
Best
Lorenz
--
Lorenz Bauer | Systems Engineer
6th Floor, County Hall/The Riverside Building, SE1 7PB, UK
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cloudflare.com&d=DwIBaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=-_pOOUYXONnvN0eDqgPfyjzi3pU0ZJV-eT7LViel2u0&s=5gNN1mRte8LrjgHn6sz7v6goGzL2lWt4-EaghCAagq0&e=