[clang] [BPF] Support preserve_access_index attribute for enum (PR #232498)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 3 14:59:51 PST 2026
yonghong-song wrote:
> > With a little bit clang change, we could support the following for a bpf prog:
> > ```
> > #include "vmlinux.h"
> >
> > /* user decide */
> > #ifdef __BPF_FEATURE_ENUM_PRESERVE_ACCESS_INDEX
> > enum __attribute__((preserve_access_index)) cgroup_subsys_id;
> > #endif
> > ```
>
> the premise is that user will most probably forget that enum needs relocation in the first place. If that was not the case, then just using `bpf_core_enum_value()` would be sufficient and not error-prone.
Okay, I think we just do what you suggested in the above with per-type attribute (filtering out some specific enums like map flag, etc.).
https://github.com/llvm/llvm-project/pull/232498
More information about the cfe-commits
mailing list