[PATCH] D69759: [BPF] Add preserve_access_index attribute for record definition
Yonghong Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 8 11:12:22 PST 2019
yonghong-song added a comment.
Yes, in the above, all three of them will be relocatable.
-bash-4.4$ cat t2.c
#define __reloc__ __attribute__((preserve_access_index))
struct S1;
struct S2 {
struct S1 *f;
} __reloc__;
struct S1 {
int i;
} __reloc__;
// access s2->f
// access s2->f->i
int test(struct S2 *arg) {
return arg->f->i;
}
-bash-4.4$ clang -target bpf -S -O2 -emit-llvm -g t2.c
...
%0 = tail call %struct.S1** @llvm.preserve.struct.access.index.p0p0s_struct.S1s.p0s_struct.S2s(%struct.S2* %arg, i32 0, i32 0
), !dbg !22, !llvm.preserve.access.index !12
%1 = load %struct.S1*, %struct.S1** %0, align 8, !dbg !22, !tbaa !23
%2 = tail call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.S1s(%struct.S1* %1, i32 0, i32 0), !dbg !28, !llvm.pr
eserve.access.index !16
In clang, BPF routines will see the record definition if it has the attribute. So in the above, the actual definition of
struct S1 and S2 will be seen and marked with attributes properly.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69759/new/
https://reviews.llvm.org/D69759
More information about the cfe-commits
mailing list