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: Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 1/8] extract add_dominator() from find_dominating_parents()
Date: Thu, 13 Apr 2017 18:55:44 +0200	[thread overview]
Message-ID: <20170413165551.2785-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170413165551.2785-1-luc.vanoostenryck@gmail.com>

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 flow.c   | 19 ++++++++++++-------
 flow.h   |  1 +
 memops.c |  8 +-------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/flow.c b/flow.c
index 45bae773e..50507a5e7 100644
--- a/flow.c
+++ b/flow.c
@@ -374,8 +374,6 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
 
 	FOR_EACH_PTR(bb->parents, parent) {
 		struct instruction *one;
-		struct instruction *br;
-		pseudo_t phi;
 
 		FOR_EACH_PTR_REVERSE(parent->insns, one) {
 			int dominance;
@@ -403,15 +401,22 @@ no_dominance:
 found_dominator:
 		if (dominators && phisrc_in_bb(*dominators, parent))
 			continue;
-		br = delete_last_instruction(&parent->insns);
-		phi = alloc_phi(parent, one->target, one->type);
-		phi->ident = phi->ident ? : pseudo->ident;
-		add_instruction(&parent->insns, br);
-		use_pseudo(insn, phi, add_pseudo(dominators, phi));
+		add_dominator(dominators, insn, one, pseudo->ident);
 	} END_FOR_EACH_PTR(parent);
 	return 1;
 }		
 
+void add_dominator(struct pseudo_list **phi_list, struct instruction *insn,
+	struct instruction *dom, struct ident *ident)
+{
+	struct basic_block *bb = dom->bb;
+	struct instruction *br = delete_last_instruction(&bb->insns);
+	pseudo_t phi = alloc_phi(bb, dom->target, dom->type);
+	phi->ident = phi->ident ? : ident ? : dom->target->ident;
+	add_instruction(&bb->insns, br);
+	use_pseudo(insn, phi, add_pseudo(phi_list, phi));
+}
+
 /*
  * We should probably sort the phi list just to make it easier to compare
  * later for equality. 
diff --git a/flow.h b/flow.h
index 31ed80d40..800585547 100644
--- a/flow.h
+++ b/flow.h
@@ -38,6 +38,7 @@ static inline void kill_instruction_force(struct instruction *insn)
 void check_access(struct instruction *insn);
 void convert_load_instruction(struct instruction *, pseudo_t);
 void rewrite_load_instruction(struct instruction *, struct pseudo_list *);
+void add_dominator(struct pseudo_list **, struct instruction *, struct instruction *, struct ident*);
 int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local);
 
 extern void clear_liveness(struct entrypoint *ep);
diff --git a/memops.c b/memops.c
index 187a63284..ac43b6a0a 100644
--- a/memops.c
+++ b/memops.c
@@ -24,8 +24,6 @@ static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
 
 	FOR_EACH_PTR(bb->parents, parent) {
 		struct instruction *one;
-		struct instruction *br;
-		pseudo_t phi;
 
 		FOR_EACH_PTR_REVERSE(parent->insns, one) {
 			int dominance;
@@ -51,11 +49,7 @@ no_dominance:
 		continue;
 
 found_dominator:
-		br = delete_last_instruction(&parent->insns);
-		phi = alloc_phi(parent, one->target, one->type);
-		phi->ident = phi->ident ? : one->target->ident;
-		add_instruction(&parent->insns, br);
-		use_pseudo(insn, phi, add_pseudo(dominators, phi));
+		add_dominator(dominators, insn, one, NULL);
 	} END_FOR_EACH_PTR(parent);
 	return 1;
 }		
-- 
2.12.0


  reply	other threads:[~2017-04-13 16:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-13 16:55 [PATCH 0/8] avoid creating orphaned OP_PHISRCs Luc Van Oostenryck
2017-04-13 16:55 ` Luc Van Oostenryck [this message]
2017-04-13 16:55 ` [PATCH 2/8] add helper add_load_dominators() Luc Van Oostenryck
2017-04-13 16:55 ` [PATCH 3/8] remove test on initial phi->ident Luc Van Oostenryck
2017-04-13 16:55 ` [PATCH 4/8] avoid phisrc orphaned by simplify_loads() Luc Van Oostenryck
2017-04-13 16:55 ` [PATCH 5/8] avoid phisrc orphaned by find_dominating_stores() Luc Van Oostenryck
2017-04-13 16:55 ` [PATCH 6/8] integrate add_load_dominators() into rewrite_load_instruction() Luc Van Oostenryck
2017-04-13 16:55 ` [PATCH 7/8] check duplicated phi-nodes directly on dominators Luc Van Oostenryck
2017-04-13 16:55 ` [PATCH 8/8] avoid creating unneeded phi-sources Luc Van Oostenryck
2017-05-18 17:04 ` [PATCH 0/8] avoid creating orphaned OP_PHISRCs Luc Van Oostenryck

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=20170413165551.2785-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).