Re: [PATCH v4 11/23] perf annotate-data: Extract invalidate_reg_state() as a common helper

Shuai Xue <[email protected]>
Newsgroups dev.linux.lists.llvm,org.kernel.vger.linux-kernel,org.kernel.vger.linux-perf-users
Message-ID <[email protected]>

On 8/8/26 8:23 PM, Tengda Wu wrote:
> The invalidate_reg_state() function is currently static and only used
> within the x86 data type profiling implementation. To prepare for adding
> arm64 instruction tracking support, extract it as a common helper that
> can be shared across architectures.
> 
> No functional change intended.
> 
> Signed-off-by: Tengda Wu <[email protected]>
> ---
>   tools/perf/util/annotate-arch/annotate-x86.c | 9 ---------
>   tools/perf/util/annotate-data.c              | 9 +++++++++
>   tools/perf/util/annotate-data.h              | 1 +
>   3 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/perf/util/annotate-arch/annotate-x86.c b/tools/perf/util/annotate-arch/annotate-x86.c
> index 6044a68966f1..ee4e3e7f3209 100644
> --- a/tools/perf/util/annotate-arch/annotate-x86.c
> +++ b/tools/perf/util/annotate-arch/annotate-x86.c
> @@ -207,15 +207,6 @@ static int x86__cpuid_parse(struct arch *arch, const char *cpuid)
>   }
>   
>   #ifdef HAVE_LIBDW_SUPPORT
> -static void invalidate_reg_state(struct type_state_reg *reg)
> -{
> -	reg->kind = TSR_KIND_INVALID;
> -	reg->ok = false;
> -	reg->lifetime_active = false;
> -	reg->lifetime_end = 0;
> -	reg->copied_from = -1;
> -}
> -
>   static void update_insn_state_x86(struct type_state *state,
>   				  struct data_loc_info *dloc, Dwarf_Die *cu_die,
>   				  struct disasm_line *dl)
> diff --git a/tools/perf/util/annotate-data.c b/tools/perf/util/annotate-data.c
> index 4e4c58764082..104b80d471f1 100644
> --- a/tools/perf/util/annotate-data.c
> +++ b/tools/perf/util/annotate-data.c
> @@ -638,6 +638,15 @@ struct type_state_stack *findnew_stack_state(struct type_state *state,
>   	return stack;
>   }
>   
> +void invalidate_reg_state(struct type_state_reg *reg)
> +{
> +	reg->kind = TSR_KIND_INVALID;
> +	reg->ok = false;
> +	reg->lifetime_active = false;
> +	reg->lifetime_end = 0;
> +	reg->copied_from = -1;
> +}
> +
>   /* Maintain a cache for quick global variable lookup */
>   struct global_var_entry {
>   	struct rb_node node;
> diff --git a/tools/perf/util/annotate-data.h b/tools/perf/util/annotate-data.h
> index c26130744260..453e13bbe3e2 100644
> --- a/tools/perf/util/annotate-data.h
> +++ b/tools/perf/util/annotate-data.h
> @@ -258,6 +258,7 @@ void set_stack_state(struct type_state_stack *stack, int offset, u8 kind,
>   				Dwarf_Die *type_die, int ptr_offset);
>   struct type_state_stack *find_stack_state(struct type_state *state,
>   						int offset);
> +void invalidate_reg_state(struct type_state_reg *reg);
>   bool get_global_var_type(Dwarf_Die *cu_die, struct data_loc_info *dloc,
>   				u64 ip, u64 var_addr, int *var_offset,
>   				Dwarf_Die *type_die);

Reviewed-by: Shuai Xue <[email protected]>

Thanks.
Shuai
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.