Skip to content

Commit fb7fd2a

Browse files
namhyungacmel
authored andcommitted
perf annotate: Move raw_comment and raw_func_start fields out of 'struct ins_operands'
Thoese two fields are used only for the jump_ops, so move them into the union to save some bytes. Also add jump__delete() callback not to free the fields as they didn't allocate new strings. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Huacai Chen <chenhuacai@kernel.org> Cc: Ian Rogers <irogers@google.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: WANG Rui <wangrui@loongson.cn> Cc: linux-toolchains@vger.kernel.org Cc: linux-trace-devel@vger.kernel.org Link: https://lore.kernel.org/r/20231110000012.3538610-3-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent ded8c48 commit fb7fd2a

3 files changed

Lines changed: 20 additions & 9 deletions

File tree

tools/perf/arch/loongarch/annotate/instructions.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ static int loongarch_jump__parse(struct arch *arch, struct ins_operands *ops, st
6161
const char *c = strchr(ops->raw, '#');
6262
u64 start, end;
6363

64-
ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char);
65-
ops->raw_func_start = strchr(ops->raw, '<');
64+
ops->jump.raw_comment = strchr(ops->raw, arch->objdump.comment_char);
65+
ops->jump.raw_func_start = strchr(ops->raw, '<');
6666

67-
if (ops->raw_func_start && c > ops->raw_func_start)
67+
if (ops->jump.raw_func_start && c > ops->jump.raw_func_start)
6868
c = NULL;
6969

7070
if (c++ != NULL)

tools/perf/util/annotate.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ bool ins__is_call(const struct ins *ins)
340340
*/
341341
static inline const char *validate_comma(const char *c, struct ins_operands *ops)
342342
{
343-
if (ops->raw_comment && c > ops->raw_comment)
343+
if (ops->jump.raw_comment && c > ops->jump.raw_comment)
344344
return NULL;
345345

346-
if (ops->raw_func_start && c > ops->raw_func_start)
346+
if (ops->jump.raw_func_start && c > ops->jump.raw_func_start)
347347
return NULL;
348348

349349
return c;
@@ -359,8 +359,8 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s
359359
const char *c = strchr(ops->raw, ',');
360360
u64 start, end;
361361

362-
ops->raw_comment = strchr(ops->raw, arch->objdump.comment_char);
363-
ops->raw_func_start = strchr(ops->raw, '<');
362+
ops->jump.raw_comment = strchr(ops->raw, arch->objdump.comment_char);
363+
ops->jump.raw_func_start = strchr(ops->raw, '<');
364364

365365
c = validate_comma(c, ops);
366366

@@ -462,7 +462,16 @@ static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
462462
ops->target.offset);
463463
}
464464

465+
static void jump__delete(struct ins_operands *ops __maybe_unused)
466+
{
467+
/*
468+
* The ops->jump.raw_comment and ops->jump.raw_func_start belong to the
469+
* raw string, don't free them.
470+
*/
471+
}
472+
465473
static struct ins_ops jump_ops = {
474+
.free = jump__delete,
466475
.parse = jump__parse,
467476
.scnprintf = jump__scnprintf,
468477
};

tools/perf/util/annotate.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ struct ins {
3131

3232
struct ins_operands {
3333
char *raw;
34-
char *raw_comment;
35-
char *raw_func_start;
3634
struct {
3735
char *raw;
3836
char *name;
@@ -52,6 +50,10 @@ struct ins_operands {
5250
struct ins ins;
5351
struct ins_operands *ops;
5452
} locked;
53+
struct {
54+
char *raw_comment;
55+
char *raw_func_start;
56+
} jump;
5557
};
5658
};
5759

0 commit comments

Comments
 (0)