linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamil Dudka <kdudka@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jeff Garzik <jeff@garzik.org>,
	Sparse Mailing-list <linux-sparse@vger.kernel.org>,
	Pekka J Enberg <penberg@cs.helsinki.fi>
Subject: [PATCH] cse: update PHI users when throwing away an instruction
Date: Sun, 28 Aug 2011 01:39:58 +0200	[thread overview]
Message-ID: <201108280139.59217.kdudka@redhat.com> (raw)
In-Reply-To: <CA+55aFxGwAXRWVcv_Qx6C4B_PKqzVVbc8O_znwUt_D6g1iDJvQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

On Saturday 27 August 2011 17:53:23 Linus Torvalds wrote:
> phi2/phi3 are both dead, but theor 'phisrc' instructions haven't been
> killed. Ugly.

The attached patch solves the dangling PHI nodes and does not seem to break 
anything at first glance.  It is probably not the most efficient solution, 
but it might at least show where to look for the problem.

Kamil

[-- Attachment #2: 0001-cse-update-PHI-users-when-throwing-away-an-instructi.patch --]
[-- Type: text/x-diff, Size: 1115 bytes --]

From 7024fcdfba9fce20569f86e2a279c76cb94cbfd8 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Sun, 28 Aug 2011 01:29:13 +0200
Subject: [PATCH] cse: update PHI users when throwing away an instruction


Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 cse.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/cse.c b/cse.c
index 2a15745..1b63c0e 100644
--- a/cse.c
+++ b/cse.c
@@ -250,6 +250,19 @@ static void sort_instruction_list(struct instruction_list **list)
 static struct instruction * cse_one_instruction(struct instruction *insn, struct instruction *def)
 {
 	convert_instruction_target(insn, def->target);
+
+	if (insn->opcode == OP_PHI) {
+		/* Remove the instruction from PHI users */
+		pseudo_t phi;
+		FOR_EACH_PTR(insn->phi_list, phi) {
+			struct pseudo_user *pu;
+			FOR_EACH_PTR(phi->users, pu) {
+				if (pu->insn == insn)
+					DELETE_CURRENT_PTR(pu);
+			} END_FOR_EACH_PTR(pu);
+		} END_FOR_EACH_PTR(phi);
+	}
+
 	insn->opcode = OP_NOP;
 	insn->bb = NULL;
 	repeat_phase |= REPEAT_CSE;
-- 
1.7.6


  parent reply	other threads:[~2011-08-27 23:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-27  6:29 linearize bug? Jeff Garzik
2011-08-27 11:34 ` Kamil Dudka
2011-08-27 15:29   ` Linus Torvalds
2011-08-27 15:37     ` Jeff Garzik
2011-08-27 15:53       ` Linus Torvalds
2011-08-27 16:54         ` Kamil Dudka
2011-08-27 17:13           ` Linus Torvalds
2011-08-27 17:27             ` Linus Torvalds
2011-08-27 19:26               ` Linus Torvalds
2011-08-27 20:03         ` Jeff Garzik
2011-08-28  6:26           ` Pekka Enberg
2011-08-27 23:39         ` Kamil Dudka [this message]
2011-08-28  0:34           ` [PATCH] cse: update PHI users when throwing away an instruction Linus Torvalds
2011-08-28  6:32             ` Christopher Li
2011-08-28  6:33             ` Pekka Enberg
2011-08-28  8:53               ` Jeff Garzik
2011-08-27 22:07   ` linearize bug? Jeff Garzik

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=201108280139.59217.kdudka@redhat.com \
    --to=kdudka@redhat.com \
    --cc=jeff@garzik.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=torvalds@linux-foundation.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).