This is an archive of the discontinued LLVM Phabricator instance.

[BPF] Introduce support for type match relocations
ClosedPublic

Authored by d-e-s-o on Jun 1 2022, 4:40 PM.

Details

Summary

Among others, BPF currently supports the type-exists CO-RE relocation
(e.g., see D83878 & D83242). Its intention, as the name tries to convey,
is to be used for checking existence of a type in a target.
While that check is useful and has its place, we would also like to
be able to perform stricter type queries: instead of just checking mere
existence, we want to make sure that members match up in composite
types, that enum variants are present, etc. We refer to this as "type
match".
This change proposes the addition of a new relocation variant/value that
we intend to use for establishing this match relation.

Diff Detail

Event Timeline

d-e-s-o created this revision.Jun 1 2022, 4:40 PM
d-e-s-o created this object with visibility "d-e-s-o (Daniel Müller)".
d-e-s-o created this object with edit policy "d-e-s-o (Daniel Müller)".
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 4:40 PM
d-e-s-o requested review of this revision.Jun 1 2022, 4:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2022, 4:40 PM
d-e-s-o changed the visibility from "d-e-s-o (Daniel Müller)" to "Subscribers".Jun 1 2022, 4:56 PM
d-e-s-o added inline comments.
llvm/test/CodeGen/BPF/CORE/intrinsic-typeinfo-type-match.ll
71–101

I am unsure how that blob is created or whether I need to adjust it. I just copied it from an existing file for now.

d-e-s-o changed the visibility from "Subscribers" to "Public (No Login Required)".Jun 2 2022, 7:41 AM
d-e-s-o added a subscriber: ast.Jun 2 2022, 7:50 AM
d-e-s-o changed the edit policy from "d-e-s-o (Daniel Müller)" to "All Users".Jun 2 2022, 1:23 PM
yonghong-song added inline comments.Jun 2 2022, 1:34 PM
llvm/test/CodeGen/BPF/CORE/intrinsic-typeinfo-type-match.ll
71–101

As mentioned in the test itself, it is generated with

clang -target bpf -S -O2 -g -emit-llvm -Xclang -disable-llvm-passes t1.c

Let us use latest llvm-project to generate IR for this test. The test you are copied using llvm12 which is not correct for this patch as this patch will apply to llvm15. Also please add '/tmp' as the prefix to the path in the below IR,

!1 = !DIFile(filename: "t1.c", directory: "/tmp/home/yhs/tmp1")

The reason is to avoid test failures when merging the tests. The reason is the path will be actually used by llvm, so adding /tmp will make sure both your local run and also sanity run after merging will have the same behavior.

d-e-s-o updated this revision to Diff 433904.Jun 2 2022, 3:20 PM

Addressed Yonghong's comment and regenerated IR. Thanks for the review!

d-e-s-o marked an inline comment as done.Jun 2 2022, 3:21 PM
d-e-s-o added inline comments.
llvm/test/CodeGen/BPF/CORE/intrinsic-typeinfo-type-match.ll
71–101

Makes sense, thanks for the explanation. Done.

d-e-s-o marked an inline comment as done.Jun 3 2022, 8:35 AM
yonghong-song accepted this revision.Jun 29 2022, 6:00 PM
This revision is now accepted and ready to land.Jun 29 2022, 6:00 PM
This revision was automatically updated to reflect the committed changes.