eddyz87 added a comment.

In D143967#4233414 <https://reviews.llvm.org/D143967#4233414>, @jemarch wrote:

>> If some tooling applies such tags movement it should also apply
>> appropriate copying of tags, e.g. it should transform DWARF like this:
>>
>>   var1 -> const -> typedef (bar) -> int
>>                                      |
>>                                   __tag1
>>   
>>   var2 ----------> typedef (bar) -> int
>>
>> (and it is what needs to be implemented in pahole to get BTF
>> qualifiers ordering expected by kernel, but the move is in the
>> opposite direction).
>
> So the kernel expects tags to precede typedefs as well as qualifiers?
> i.e. given this DWARF:
>
>   var1 -> const -> typedef (bar) -> int
>                        ^             |
>                        |           __tag1
>                        |
>   var2 ----------------+
>
> We have to transform to these two BTF type chains:
>
>   var1 -> __tag1 -> const -> typedef (bar) -> int
>                                   ^
>                                   |
>   var2 -> __tag1 -----------------+
>
> Correct?

This is controlled by the following code (btf.c:btf_check_type_tags()):

https://elixir.bootlin.com/linux/latest/source/kernel/bpf/btf.c#L5349

It uses `btf_type_is_modifier()` utility function, which treats typedef as a 
modifier.

So, in theory the transformation moving tags past typedef is necessary. On the 
other hand, such transformation is not applied now, and this does not cause 
issues. Which suggests that there are no cases in practice where type tag 
follows typedef (and thus, this is not required for backwards compatibility).

Moving type tags cross typedef feels wrong.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143967/new/

https://reviews.llvm.org/D143967

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to