From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 4/5] memops: move rewrite_load_instruction() here
Date: Sun, 29 Nov 2020 15:49:21 +0100 [thread overview]
Message-ID: <20201129144922.56209-5-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20201129144922.56209-1-luc.vanoostenryck@gmail.com>
The function rewrite_load_instruction() is defined in flow.c but:
* is not directly related to 'flow'
* it's only used in memops.c
* needs some change related to simplify_loads().
So, move this code to memops.c
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
flow.c | 41 -----------------------------------------
flow.h | 1 -
memops.c | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 41 insertions(+), 42 deletions(-)
diff --git a/flow.c b/flow.c
index 1a871df16bd5..20827acce88b 100644
--- a/flow.c
+++ b/flow.c
@@ -520,47 +520,6 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom
return 1;
}
-/*
- * We should probably sort the phi list just to make it easier to compare
- * later for equality.
- */
-void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators)
-{
- pseudo_t new, phi;
-
- /*
- * Check for somewhat common case of duplicate
- * phi nodes.
- */
- new = first_pseudo(dominators)->def->phi_src;
- FOR_EACH_PTR(dominators, phi) {
- if (new != phi->def->phi_src)
- goto complex_phi;
- new->ident = new->ident ? : phi->ident;
- } END_FOR_EACH_PTR(phi);
-
- /*
- * All the same pseudo - mark the phi-nodes unused
- * and convert the load into a LNOP and replace the
- * pseudo.
- */
- convert_load_instruction(insn, new);
- FOR_EACH_PTR(dominators, phi) {
- kill_instruction(phi->def);
- } END_FOR_EACH_PTR(phi);
- goto end;
-
-complex_phi:
- /* We leave symbol pseudos with a bogus usage list here */
- if (insn->src->type != PSEUDO_SYM)
- kill_use(&insn->src);
- insn->opcode = OP_PHI;
- insn->phi_list = dominators;
-
-end:
- repeat_phase |= REPEAT_CSE;
-}
-
/* Kill a pseudo that is dead on exit from the bb */
// The context is:
// * the variable is not global but may have its address used (local/non-local)
diff --git a/flow.h b/flow.h
index 7cdc7c2a496b..c55362de848e 100644
--- a/flow.h
+++ b/flow.h
@@ -39,7 +39,6 @@ static inline int 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 *);
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 badcdbbb9378..6620688264ad 100644
--- a/memops.c
+++ b/memops.c
@@ -16,6 +16,47 @@
#include "linearize.h"
#include "flow.h"
+/*
+ * We should probably sort the phi list just to make it easier to compare
+ * later for equality.
+ */
+static void rewrite_load_instruction(struct instruction *insn, struct pseudo_list *dominators)
+{
+ pseudo_t new, phi;
+
+ /*
+ * Check for somewhat common case of duplicate
+ * phi nodes.
+ */
+ new = first_pseudo(dominators)->def->phi_src;
+ FOR_EACH_PTR(dominators, phi) {
+ if (new != phi->def->phi_src)
+ goto complex_phi;
+ new->ident = new->ident ? : phi->ident;
+ } END_FOR_EACH_PTR(phi);
+
+ /*
+ * All the same pseudo - mark the phi-nodes unused
+ * and convert the load into a LNOP and replace the
+ * pseudo.
+ */
+ convert_load_instruction(insn, new);
+ FOR_EACH_PTR(dominators, phi) {
+ kill_instruction(phi->def);
+ } END_FOR_EACH_PTR(phi);
+ goto end;
+
+complex_phi:
+ /* We leave symbol pseudos with a bogus usage list here */
+ if (insn->src->type != PSEUDO_SYM)
+ kill_use(&insn->src);
+ insn->opcode = OP_PHI;
+ insn->phi_list = dominators;
+
+end:
+ repeat_phase |= REPEAT_CSE;
+}
+
static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators,
int local)
--
2.29.2
next prev 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 ` Luc Van Oostenryck [this message]
2020-11-29 14:49 ` [PATCH 5/5] replace convert_load_instruction() by replace_with_pseudo() 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=20201129144922.56209-5-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).