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: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 5/5] replace convert_load_instruction() by replace_with_pseudo()
Date: Sun, 29 Nov 2020 15:49:22 +0100	[thread overview]
Message-ID: <20201129144922.56209-6-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com>

These two functions are now exactly the same, so replace the
first one by the second one.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 flow.c   | 7 +------
 flow.h   | 1 -
 memops.c | 7 ++++---
 ssa.c    | 9 +++++----
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/flow.c b/flow.c
index 20827acce88b..95e44ac104f6 100644
--- a/flow.c
+++ b/flow.c
@@ -16,6 +16,7 @@
 #include "parse.h"
 #include "expression.h"
 #include "linearize.h"
+#include "simplify.h"
 #include "flow.h"
 #include "target.h"
 #include "flowgraph.h"
@@ -453,12 +454,6 @@ void convert_instruction_target(struct instruction *insn, pseudo_t src)
 	target->users = NULL;
 }
 
-void convert_load_instruction(struct instruction *insn, pseudo_t src)
-{
-	convert_instruction_target(insn, src);
-	kill_instruction(insn);
-}
-
 static int overlapping_memop(struct instruction *a, struct instruction *b)
 {
 	unsigned int a_start = bytes_to_bits(a->offset);
diff --git a/flow.h b/flow.h
index c55362de848e..46d76a780484 100644
--- a/flow.h
+++ b/flow.h
@@ -38,7 +38,6 @@ static inline int kill_instruction_force(struct instruction *insn)
 }
 
 void check_access(struct instruction *insn);
-void convert_load_instruction(struct instruction *, pseudo_t);
 int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local);
 
 extern void vrfy_flow(struct entrypoint *ep);
diff --git a/memops.c b/memops.c
index 6620688264ad..7efade22c9b5 100644
--- a/memops.c
+++ b/memops.c
@@ -14,6 +14,7 @@
 #include "parse.h"
 #include "expression.h"
 #include "linearize.h"
+#include "simplify.h"
 #include "flow.h"
 
 /*
@@ -40,7 +41,7 @@ static void rewrite_load_instruction(struct instruction *insn, struct pseudo_lis
 	 * and convert the load into a LNOP and replace the
 	 * pseudo.
 	 */
-	convert_load_instruction(insn, new);
+	replace_with_pseudo(insn, new);
 	FOR_EACH_PTR(dominators, phi) {
 		kill_instruction(phi->def);
 	} END_FOR_EACH_PTR(phi);
@@ -167,7 +168,7 @@ static void simplify_loads(struct basic_block *bb)
 					if (!compatible_loads(insn, dom))
 						goto next_load;
 					/* Yeehaa! Found one! */
-					convert_load_instruction(insn, dom->target);
+					replace_with_pseudo(insn, dom->target);
 					goto next_load;
 				}
 			} END_FOR_EACH_PTR_REVERSE(dom);
@@ -181,7 +182,7 @@ static void simplify_loads(struct basic_block *bb)
 				if (!dominators) {
 					if (local) {
 						assert(pseudo->type != PSEUDO_ARG);
-						convert_load_instruction(insn, value_pseudo(0));
+						replace_with_pseudo(insn, value_pseudo(0));
 					}
 					goto next_load;
 				}
diff --git a/ssa.c b/ssa.c
index 3e8800507f63..a2e27030e4b6 100644
--- a/ssa.c
+++ b/ssa.c
@@ -11,7 +11,8 @@
 #include "dominate.h"
 #include "flowgraph.h"
 #include "linearize.h"
-#include "flow.h"			// for convert_load_instruction()
+#include "simplify.h"
+#include "flow.h"
 
 
 // Is it possible and desirable for this to be promoted to a pseudo?
@@ -109,7 +110,7 @@ static void rewrite_local_var(struct basic_block *bb, pseudo_t addr, int nbr_sto
 		case OP_LOAD:
 			if (!val)
 				val = undef_pseudo();
-			convert_load_instruction(insn, val);
+			replace_with_pseudo(insn, val);
 			break;
 		case OP_STORE:
 			val = insn->target;
@@ -150,7 +151,7 @@ static bool rewrite_single_store(struct instruction *store)
 
 		// undefs ?
 
-		convert_load_instruction(insn, store->target);
+		replace_with_pseudo(insn, store->target);
 	} END_FOR_EACH_PTR(pu);
 
 	// is there some unconverted loads?
@@ -292,7 +293,7 @@ static void ssa_rename_insn(struct basic_block *bb, struct instruction *insn)
 		if (!var || !var->torename)
 			break;
 		val = lookup_var(bb, var);
-		convert_load_instruction(insn, val);
+		replace_with_pseudo(insn, val);
 		break;
 	case OP_PHI:
 		var = insn->type;
-- 
2.29.2


      parent reply	other threads:[~2020-11-29 14:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29 14:49 [PATCH 0/5] use replace_with_pseudo() for simplify_memops() Luc Van Oostenryck
2020-11-29 14:49 ` [PATCH 1/5] let replace_with_pseudo() use kill_instruction() Luc Van Oostenryck
2020-11-29 14:49 ` [PATCH 2/5] make a header for simplification Luc Van Oostenryck
2020-11-29 14:49 ` [PATCH 3/5] make replace_with_pseudo() extern Luc Van Oostenryck
2020-11-29 14:49 ` [PATCH 4/5] memops: move rewrite_load_instruction() here Luc Van Oostenryck
2020-11-29 14:49 ` Luc Van Oostenryck [this message]

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=20201129144922.56209-6-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.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).