Re: [PATCH RFC 0/3] list inline expansions in .BTF.inline

Alexei Starovoitov
2025-04-29T23:58:32Z

On Tue, Apr 29, 2025 at 12:14 PM Thierry Treyer <ttreyer@meta.com> wrote:
>
> > It looks to me we only need:
> > - register
> > - load_from_reg_plus_offset
> > - constant
>
> In that case, we can shorten the list of operators:
>
> ### | Operator Name | Operands[...]
> ----+------------------------+-------------------------------------------
> 1 | LOC_SIGNED_CONST_1 | s8: constant's value
> 2 | LOC_SIGNED_CONST_2 | s16: constant's value
> 3 | LOC_SIGNED_CONST_4 | s32: constant's value
> 4 | LOC_SIGNED_CONST_8 | s64: constant's value
> 5 | LOC_UNSIGNED_CONST_1 | u8: constant's value
> 6 | LOC_UNSIGNED_CONST_2 | u16: constant's value
> 7 | LOC_UNSIGNED_CONST_4 | u32: constant's value
> 8 | LOC_UNSIGNED_CONST_8 | u64: constant's value
> 9 | LOC_REGISTER | u8: DWARF register number from the ABI
> 10 | LOC_REGISTER_OFFSET | u8: DWARF register number from the ABI
> | s64: offset added to the register's value

Since we want to make the format compat let's use s32 for offset.
We can even consider s16.
Since that's typically stack and kernel stack is rarely above 2k.

>
> > register vs register_offset is another artifact of dwarf.
> > ...
> > - load_from_reg_plus_offset
>
> What is the difference between LOC_REGISTER_OFFSET
> and load_from_reg_plus_offset?

Just a different name, because LOC_REGISTER_OFFSET is confusing.
LOC_REGISTER means that the value of the argument is in that register.
LOC_REGISTER_OFFSET can be interpreted that the argument value
is in the register plus constant.
But that's not the case. reg+const is an address in memory when
value is stored.
So we need a different name.
Probably load_from_reg_plus_offset is confusing too.
How about
LOC_ADDR_REGISTER_OFFSET