xref: /llvm-project/clang/test/CodeGen/bpf-preserve-access-index.c (revision 54d9f743c8b0f501288119123cf1828bf7ade69c)
1*54d9f743SYonghong Song // RUN: %clang %s -target bpfeb -x c -emit-llvm -S -g -O2 -Xclang -disable-llvm-passes -o - | FileCheck --check-prefix=CHECK %s
2*54d9f743SYonghong Song // RUN: %clang %s -target bpfel -x c -emit-llvm -S -g -O2 -Xclang -disable-llvm-passes -o - | FileCheck --check-prefix=CHECK %s
3048493f8SYonghong Song 
4048493f8SYonghong Song struct t {
5048493f8SYonghong Song   int i:1;
6048493f8SYonghong Song   int j:2;
7048493f8SYonghong Song   union {
8048493f8SYonghong Song    int a;
9048493f8SYonghong Song    int b;
10048493f8SYonghong Song   } c[4];
11048493f8SYonghong Song };
12048493f8SYonghong Song 
13048493f8SYonghong Song #define _(x) (__builtin_preserve_access_index(x))
14048493f8SYonghong Song 
test(struct t * arg)15048493f8SYonghong Song const void *test(struct t *arg) {
16048493f8SYonghong Song   return _(&arg->c[3].b);
17048493f8SYonghong Song }
18048493f8SYonghong Song 
19048493f8SYonghong Song // CHECK: llvm.preserve.struct.access.index
20048493f8SYonghong Song // CHECK: llvm.preserve.array.access.index
21048493f8SYonghong Song // CHECK: llvm.preserve.union.access.index
22048493f8SYonghong Song // CHECK-NOT: __builtin_preserve_access_index
23