Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp234555lqz; Fri, 29 Mar 2024 14:58:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZ/TP7wA7Gh3mCUy+6wxb5oZZ/KCUMrrOTR+kS9RqW2D/m3J1A2IEC/ZTq+seKzIw1PQE/Y79sDHf0oo/hbRxEDbMkfs6/DQvqPugMFg== X-Google-Smtp-Source: AGHT+IE/saQZx5VUT6XjQO1duHpx0mdaw56U/G+G7/zirtZMj7kecL1ytN8uCtXLKPXTX1SMQVqe X-Received: by 2002:a05:620a:171e:b0:789:d55a:d10c with SMTP id az30-20020a05620a171e00b00789d55ad10cmr4323344qkb.48.1711749518931; Fri, 29 Mar 2024 14:58:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711749518; cv=pass; d=google.com; s=arc-20160816; b=0b3pGKsTJsgMMIboG9b+VTsEzQmmB6paW1SSImAe8F6KxszDusbE0zpjFWq5IReKRJ GvpEXewGVlbO/U3jycGYkokbk9uIzjAEb6KhSDHQW5y62zJO1pgf7nPgrO9TyOnsTKQV BnTbG/sBxdfGEiF6D4GaPVoRPALvYSETo7Cs5h5v5Oo/PkYvxleJjh3aJTqdp0EwKKS2 /DFLtH63D6DGSsDPb83OmB0IfWavVq8zGU67LHFq3oUekZvvCPiHK7TbIru304DuJA6x tK2+MVbF5zMGB20r5InGCQak7B33OFQMBILklbxs+lYNIaAOp3ismUoVf4GC7nA4RQFC B6Bg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=n3hdqUEDDWbK8S6gCfY9ft9HsKWMs+VSvfwK48N1RtQ=; fh=fHhbvXgCev/wpffLVpfaAi8pPyv7hrTyhVPgsZ7HNrs=; b=Ej83SoNLDpJJZ6eCDdNUgP+2oJV7Ns4vWXIOGLiNOsGcnCcRvllUVpe1f/j9y/npzt 6qh3T5PCrKSf28bjxs94oD+rqKeGMwcPGwqZqogd6mjkLfGBxMcOH/EhW2AiC85Eanz0 AkDFPjqYOjh7zNS2fseBadXSI3vkE770ucXqwszFQ0WXL5xK+xHmZ0xUixxF03agVb2K wJNsbz7akpUxPgg9bfUmaVUOUQmgqGznCfM8jof7LOt7/ZbdmunumqCPCPM7iaADAomf kv7m4Q60IZob5geQXwfas9C0D7oxpn+Q0c0SGoNHQo5FXq235f4amQ+gnVGNOgiNgdop pBpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fEWoUclj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-125466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125466-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c24-20020a05620a201800b00789e5140168si4479361qka.423.2024.03.29.14.58.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 14:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fEWoUclj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-125466-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125466-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A784F1C21037 for ; Fri, 29 Mar 2024 21:58:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1681013D29C; Fri, 29 Mar 2024 21:58:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fEWoUclj" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 386C713C3C5; Fri, 29 Mar 2024 21:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711749495; cv=none; b=jJeB563R1ilmR5QfN3zIsYLljXbXiVOeX1dk0x0k1l1FfffMY45HUtE2WCv4RhZqIiyZmjDlzlsEBsIrrAxCfwObjUtab/kwnyWKS7TUgUcy9ShX89cN1Leg0etwh7ZQzrfZ1lN++1z3wO3kEqBgN3oTtX9egvjCCe/ubTWmu8g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711749495; c=relaxed/simple; bh=UvaA7BRgw7vdNNiWdsV21ScZVQR/gOFfTgj7FTu8ZyU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jPqVeZlVoxpBQMBNeRGQkjf+d2mxZH5uf5mHhdhqiUJ/gmmf6PUbJ/kG1rdudaWFyGkDLezihJzx6KYggPV+S8xhxHMnZvZO/9BfBdH2o6bJxXaDS6pUtM1R/cAGlrpqMEThtI5pDl16YobqjewgZ/pzEtqr61pZPoUDCAF/cQw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fEWoUclj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73861C433B1; Fri, 29 Mar 2024 21:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711749494; bh=UvaA7BRgw7vdNNiWdsV21ScZVQR/gOFfTgj7FTu8ZyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fEWoUcljKPFGFZDhUB5C6dt3JqlfJIvvJqrjiCsOmAVtVdz9MQiFu48/lNSiV5RjZ oOM3rj5b1AO4/voR/MH+sLPImwHJk1Cl0ejA7BQqasV20gPPbKsoySx4HfSs7MLoEG uBgZhMlcDyu83RfPPEzWQoMqB5FzLOOK2rtwCq0jomR2gG9XxzfVtBQ28kw4FkDwnP 8CSUokIwAUv4A/BUqigPWkWEhyYL+tVfl+kAFr5c14Ow0Ncvsxx03SJbVPUyMc5tWp 5T/OlpsRxXnEDE/8ETbXSTQNJSn6YCC19fg9qJBm2u76z8UWr8Bqn41Q1ESJcupzNB 10DKE/2QoY71g== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , 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 Message-ID: <20240329215812.537846-3-namhyung@kernel.org> X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog In-Reply-To: <20240329215812.537846-1-namhyung@kernel.org> References: <20240329215812.537846-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Likewise, add ins__is_nop() to check if the current instruction is NOP. Tested-by: Ian Rogers Signed-off-by: Namhyung Kim --- 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