linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ian Rogers <irogers@google.com>,
	Kan Liang <kan.liang@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-perf-users@vger.kernel.org
Subject: [PATCH v2 2/5] perf annotate: Add and use ins__is_nop()
Date: Fri, 29 Mar 2024 14:58:09 -0700	[thread overview]
Message-ID: <20240329215812.537846-3-namhyung@kernel.org> (raw)
In-Reply-To: <20240329215812.537846-1-namhyung@kernel.org>

Likewise, add ins__is_nop() to check if the current instruction is NOP.

Tested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/annotate.c | 7 ++++++-
 tools/perf/util/annotate.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 986c499150ef..5d0ca004dcfb 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -757,6 +757,11 @@ static struct ins_ops ret_ops = {
 	.scnprintf = ins__raw_scnprintf,
 };
 
+bool ins__is_nop(const struct ins *ins)
+{
+	return ins->ops == &nop_ops;
+}
+
 bool ins__is_ret(const struct ins *ins)
 {
 	return ins->ops == &ret_ops;
@@ -1785,7 +1790,7 @@ static void delete_last_nop(struct symbol *sym)
 		dl = list_entry(list->prev, struct disasm_line, al.node);
 
 		if (dl->ins.ops) {
-			if (dl->ins.ops != &nop_ops)
+			if (!ins__is_nop(&dl->ins))
 				return;
 		} else {
 			if (!strstr(dl->al.line, " nop ") &&
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index 14980b65f812..98f556af637c 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -74,6 +74,7 @@ struct ins_ops {
 
 bool ins__is_jump(const struct ins *ins);
 bool ins__is_call(const struct ins *ins);
+bool ins__is_nop(const struct ins *ins);
 bool ins__is_ret(const struct ins *ins);
 bool ins__is_lock(const struct ins *ins);
 int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops, int max_ins_name);
-- 
2.44.0.478.gd926399ef9-goog


  parent reply	other threads:[~2024-03-29 21:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 21:58 [PATCH v2 0/5] perf annotate: Use libcapstone as a disasssembler Namhyung Kim
2024-03-29 21:58 ` [PATCH v2 1/5] perf annotate: Use ins__is_xxx() if possible Namhyung Kim
2024-03-29 21:58 ` Namhyung Kim [this message]
2024-03-29 21:58 ` [PATCH v2 3/5] perf annotate: Split out util/disasm.c Namhyung Kim
2024-04-02 22:08   ` Arnaldo Carvalho de Melo
2024-04-02 22:11     ` Arnaldo Carvalho de Melo
2024-04-02 23:03       ` Namhyung Kim
2024-04-03 14:13         ` Arnaldo Carvalho de Melo
2024-03-29 21:58 ` [PATCH v2 4/5] perf annotate: Use libcapstone to disassemble Namhyung Kim
2024-03-29 21:58 ` [PATCH v2 5/5] perf annotate: Add symbol name when using capstone Namhyung Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240329215812.537846-3-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).