public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Collingbourne <pcc@google.com>
To: Ian Rogers <irogers@google.com>
Cc: Peter Collingbourne <pcc@google.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	 Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	 Mark Rutland <mark.rutland@arm.com>,
	 Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>,
	 Adrian Hunter <adrian.hunter@intel.com>,
	James Clark <james.clark@linaro.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	 Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	 linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
	 llvm@lists.linux.dev
Subject: [PATCH] perf llvm: Clean up after a failed disassembly
Date: Tue,  3 Mar 2026 15:00:42 -0800	[thread overview]
Message-ID: <20260303230043.2074593-1-pcc@google.com> (raw)

An error returned from a failed backend will cause perf to call the next
backend. If the error happens mid-function, e.g. due to an unrecognized
instruction, we will end up with duplicated instructions in the output
unless the backend that failed deletes any instructions that it created
before failing. The capstone backend was already doing this but the LLVM
backend was not; fix it.

Link: https://linux-review.googlesource.com/id/I377eef3cd662ab98fbcd69e5004a259fa3d7aa06
Signed-off-by: Peter Collingbourne <pcc@google.com>
---
 tools/perf/util/llvm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/util/llvm.c b/tools/perf/util/llvm.c
index 0d126d233c019..87fceae8488a7 100644
--- a/tools/perf/util/llvm.c
+++ b/tools/perf/util/llvm.c
@@ -261,6 +261,15 @@ int symbol__disassemble_llvm(const char *filename, struct symbol *sym,
 	ret = 0;
 
 err:
+	if (ret != 0) {
+		struct disasm_line *tmp;
+
+		list_for_each_entry_safe(dl, tmp, &notes->src->source,
+					 al.node) {
+			list_del(&dl->al.node);
+			disasm_line__free(dl);
+		}
+	}
 	LLVMDisasmDispose(disasm);
 	free(code_buf);
 	free(line_storage);
-- 
2.53.0.473.g4a7958ca14-goog


             reply	other threads:[~2026-03-03 23:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-03 23:00 Peter Collingbourne [this message]
2026-03-03 23:29 ` [PATCH] perf llvm: Clean up after a failed disassembly Ian Rogers
2026-03-04 21:10   ` Peter Collingbourne
2026-03-04 22:05     ` Arnaldo Carvalho de Melo

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=20260303230043.2074593-1-pcc@google.com \
    --to=pcc@google.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --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