linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Chris Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/3] extract has_users() from dead_insn()
Date: Thu,  8 Jun 2017 09:39:25 +0200	[thread overview]
Message-ID: <20170608073927.55218-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170608073927.55218-1-luc.vanoostenryck@gmail.com>

so that it can be reused for others uses.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/simplify.c b/simplify.c
index a141ddd43..65114193a 100644
--- a/simplify.c
+++ b/simplify.c
@@ -301,16 +301,23 @@ void kill_insn(struct instruction *insn, int force)
 	return;
 }
 
+static int has_users(pseudo_t p)
+{
+	struct pseudo_user *pu;
+	FOR_EACH_PTR(p->users, pu) {
+		if (*pu->userp != VOID)
+			return 1;
+	} END_FOR_EACH_PTR(pu);
+	return 0;
+}
+
 /*
  * Kill trivially dead instructions
  */
 static int dead_insn(struct instruction *insn, pseudo_t *src1, pseudo_t *src2, pseudo_t *src3)
 {
-	struct pseudo_user *pu;
-	FOR_EACH_PTR(insn->target->users, pu) {
-		if (*pu->userp != VOID)
-			return 0;
-	} END_FOR_EACH_PTR(pu);
+	if (has_users(insn->target))
+		return 0;
 
 	insn->bb = NULL;
 	kill_use(src1);
-- 
2.13.0


  reply	other threads:[~2017-06-08  7:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08  7:39 [PATCH 0/3] kill dead loads Luc Van Oostenryck
2017-06-08  7:39 ` Luc Van Oostenryck [this message]
2017-06-08  7:39 ` [PATCH 2/3] let kill_instruction() report if it made some changes or not Luc Van Oostenryck
2017-06-08  7:39 ` [PATCH 3/3] kill dead loads Luc Van Oostenryck
2017-06-09  7:46 ` [PATCH 0/3] " Christopher Li

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=20170608073927.55218-2-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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).