From: "Jan Pokorný" <pokorny_jan@seznam.cz>
To: sparse@chrisli.org
Cc: linux-sparse@vger.kernel.org
Subject: Re: [PATCH 2/2] better dealing with OP_PHISOURCE insn
Date: Sat, 16 Apr 2011 00:52:35 +0200 [thread overview]
Message-ID: <4DA8CC33.1050307@seznam.cz> (raw)
In-Reply-To: <4DA04BE8.9060706@seznam.cz>
This is my proposal of how to fix incorrect handling of a recursive
"(PHISOURCE->PHI->)+ PHISOURCE->PHI" chain in `phi_defines'.
It should be applied instead of my previous 2/2 patch posted on
2011-04-09 which treated this case unwisely as spotted by Chris Li
who also outlined respective correction in his reply from 2011-04-14.
The fix required to move `trackable_pseudo' (if we want to avoid
a forward declaration).
I also added `src_pseudo' in the role of a shortcut and removed `def' to
reduce the number of levels of such shortcuts (to keep it more readable).
I tried few comparisons (some of them in very carefully) and it seems to
do the job (as explained in included comment) right.
Signed-off-by: Jan Pokorny <pokorny_jan@seznam.cz>
---
liveness.c | 39 +++++++++++++++++++++++++--------------
1 files changed, 25 insertions(+), 14 deletions(-)
diff --git a/liveness.c b/liveness.c
index eeff0f7..c9460de 100644
--- a/liveness.c
+++ b/liveness.c
@@ -12,22 +12,38 @@
#include "linearize.h"
#include "flow.h"
+
+static inline int trackable_pseudo(pseudo_t pseudo)
+{
+ return pseudo && (pseudo->type == PSEUDO_REG || pseudo->type == PSEUDO_ARG);
+}
+
static void phi_defines(struct instruction * phi_node, pseudo_t target,
- void (*defines)(struct basic_block *, struct instruction *, pseudo_t))
+ void (*defines)(struct basic_block *, struct instruction *, pseudo_t),
+ unsigned long generation)
{
pseudo_t phi;
FOR_EACH_PTR(phi_node->phi_list, phi) {
- struct instruction *def;
if (phi == VOID)
continue;
- def = phi->def;
- if (!def || !def->bb)
- continue;
- if (def->opcode == OP_PHI) {
- phi_defines(def, target, defines);
+ if (!phi->def || !phi->def->bb)
continue;
+
+ /*
+ * In case of "(PHISOURCE->PHI->)+ PHISOURCE->PHI" chain, move
+ * "defines" information upstream to the BB of a very first PHISOURCE
+ * (recursion guarded using "generation" marking of PHI insn BBs).
+ */
+ pseudo_t src_pseudo = phi->def->phi_src;
+ if (trackable_pseudo(src_pseudo) && src_pseudo->def->opcode == OP_PHI) {
+ phi_node->bb->generation = generation;
+ if (src_pseudo->def->bb->generation != generation) {
+ phi_defines(src_pseudo->def, target, defines, generation);
+ continue;
+ }
}
- defines(def->bb, phi->def, target);
+
+ defines(phi->def->bb, phi->def, target);
} END_FOR_EACH_PTR(phi);
}
@@ -103,7 +119,7 @@ static void track_instruction_usage(struct basic_block *bb, struct instruction *
/* Other */
case OP_PHI:
/* Phi-nodes are "backwards" nodes. Their def doesn't matter */
- phi_defines(insn, insn->target, def);
+ phi_defines(insn, insn->target, def, ++bb_generation);
break;
case OP_PHISOURCE:
@@ -179,11 +195,6 @@ static void add_pseudo_exclusive(struct pseudo_list **list, pseudo_t pseudo)
}
}
-static inline int trackable_pseudo(pseudo_t pseudo)
-{
- return pseudo && (pseudo->type == PSEUDO_REG || pseudo->type == PSEUDO_ARG);
-}
next prev parent reply other threads:[~2011-04-15 22:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-09 11:53 [PATCH 1/2] better dealing with OP_PHISOURCE insn Jan Pokorný
2011-04-09 12:07 ` [PATCH 2/2] " Jan Pokorný
2011-04-09 12:12 ` Jan Pokorný
2011-04-14 10:10 ` Christopher Li
2011-04-15 22:52 ` Jan Pokorný [this message]
2011-04-16 10:56 ` Jan Pokorný
2011-04-16 11:16 ` Jan Pokorný
2011-04-16 14:49 ` Jan Pokorný
2011-04-16 16:21 ` Jan Pokorný
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=4DA8CC33.1050307@seznam.cz \
--to=pokorny_jan@seznam.cz \
--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).