[clang] [BPF] Support preserve_access_index attribute for enum (PR #232498)

via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 14 10:09:15 PST 2026


yonghong-song wrote:

> I noticed this PR was merged, but as far as I can tell, two points from our discussion are still unresolved:
> 
>     1. Consistent enum relocation semantics: The merged implementation still allows the same enumerator to be relocated in runtime expressions but not in contexts requiring compile-time constants when -Wno-bpf-enum-not-relocated is used. We discussed providing an explicit opt-out that disables automatic relocations for the affected enum entirely. Is this planned as a follow-up?
> 
>     2. Switch cases: We also haven't addressed whether "case N:" could be made relocatable, so that it behaves consistently with "if (i == N)" in general. Is supporting this feasible, or is the intention to require compile-time constants in switch cases? The GCC implementation extracts these conditions from the switches themselves and turns them into preceding conditional jumps to the case labels.
> 
> 
> @anakryiko @yonghong-song, could you clarify whether these are intended as follow-up changes or whether the current implementation is considered final?

I will work on both above cases. Will send a pull request next week.



https://github.com/llvm/llvm-project/pull/232498


More information about the cfe-commits mailing list