btf_encoder: Exclude functions with unexpected param register use not optimizations

A key problem with the existing approach of excluding functions with
optimized-out parameters is that it does not distinguish between cases
where a parameter was passed but not used versus cases where a parameter
is not passed or used.

The latter is the only problematic case as for the former case, the
expected register states at function call time are as they would be
absent optimization.

Ideally call-site analysis could tell us what actually happens when a
function is called, but in practice we use a different method to exclude
functions from BTF representation.

If a function clearly violates the calling-convention expectations,
where such a violation means "parameter X does not use the expected
register as specified in calling conventions", it is excluded.

Note that we continue to mark functions which have optimized-out
parameters as this is good to know, but only actively exclude functions
with unexpected register usage for parameters or multiple inconsistent
function prototypes.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Eduard Zingerman <eddyz87@gmail.com>
Cc: Hao Luo <haoluo@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: KP Singh <kpsingh@chromium.org>
Cc: Kui-Feng Lee <sinquersw@gmail.com>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stanislav Fomichev <sdf@google.com>
Cc: Timo Beckers <timo@incline.eu>
Cc: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/1676675433-10583-3-git-send-email-alan.maguire@oracle.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 file changed