linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamil Dudka <kdudka@redhat.com>
To: sparse <linux-sparse@vger.kernel.org>
Subject: [PATCH] unssa: track uses when replacing a phi node
Date: Sun, 9 Aug 2009 10:30:23 +0200	[thread overview]
Message-ID: <200908091030.24138.kdudka@redhat.com> (raw)

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

Hello,

attached are patch, testing input for test-unssa and its outputs before patch 
and after patch. Thanks in advance for considering the patch!

Kamil

[-- Attachment #2: unssa-bug-before_patch.out --]
[-- Type: text/plain, Size: 348 bytes --]



test:
.L0x7f9fb2030010
	<entry-point>
	phisrc.32   %phi2(ptr) <- %arg1
	br          .L0x7f9fb2030130

.L0x7f9fb2030130
	copy.32     %r1(ptr) <- %r5(ptr)
	br          %r1(ptr), .L0x7f9fb2030058, .L0x7f9fb20300e8

.L0x7f9fb2030058
	load.32     %r3 <- 0[%r1(ptr)]
	phisrc.32   %phi3(ptr) <- %r3
	br          .L0x7f9fb2030130

.L0x7f9fb20300e8
	ret


[-- Attachment #3: unssa-bug-input.c --]
[-- Type: text/x-csrc, Size: 77 bytes --]

static void test(void **ptr)
{
    while (ptr) {
        ptr = *ptr;
    }
}

[-- Attachment #4: unssa-bug-after_patch.out --]
[-- Type: text/plain, Size: 344 bytes --]



test:
.L0x7f4a7f7f1010
	<entry-point>
	copy.32     %r5(ptr) <- %arg1
	br          .L0x7f4a7f7f1130

.L0x7f4a7f7f1130
	copy.32     %r1(ptr) <- %r5(ptr)
	br          %r1(ptr), .L0x7f4a7f7f1058, .L0x7f4a7f7f10e8

.L0x7f4a7f7f1058
	load.32     %r3 <- 0[%r1(ptr)]
	copy.32     %r5(ptr) <- %r3
	br          .L0x7f4a7f7f1130

.L0x7f4a7f7f10e8
	ret


[-- Attachment #5: 0001-unssa-track-uses-when-replacing-a-phi-node.patch --]
[-- Type: text/x-diff, Size: 1942 bytes --]

From 66a02fa7cec780fc88d6ef4cce7a1e704928808a Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Sun, 9 Aug 2009 10:22:11 +0200
Subject: [PATCH] unssa: track uses when replacing a phi node

The output of test-unssa is inconsistent for a simple test-case without
this patch:

static void test(void **ptr)
{
    while (ptr) {
        ptr = *ptr;
    }
}

Signed-off-by: Kamil Dudka <kdudka@redhat.com>
---
 flow.h     |    1 +
 liveness.c |    2 +-
 unssa.c    |    2 ++
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/flow.h b/flow.h
index 9f2e165..fbc9505 100644
--- a/flow.h
+++ b/flow.h
@@ -29,6 +29,7 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom
 extern void clear_liveness(struct entrypoint *ep);
 extern void track_pseudo_liveness(struct entrypoint *ep);
 extern void track_pseudo_death(struct entrypoint *ep);
+extern void track_phi_uses(struct instruction *insn);
 
 extern void vrfy_flow(struct entrypoint *ep);
 extern int pseudo_in_list(struct pseudo_list *list, pseudo_t pseudo);
diff --git a/liveness.c b/liveness.c
index 8b0dfd8..eeff0f7 100644
--- a/liveness.c
+++ b/liveness.c
@@ -279,7 +279,7 @@ static void merge_pseudo_list(struct pseudo_list *src, struct pseudo_list **dest
 	} END_FOR_EACH_PTR(pseudo);
 }
 
-static void track_phi_uses(struct instruction *insn)
+void track_phi_uses(struct instruction *insn)
 {
 	pseudo_t phi;
 	FOR_EACH_PTR(insn->phi_list, phi) {
diff --git a/unssa.c b/unssa.c
index cd18313..3eea9b2 100644
--- a/unssa.c
+++ b/unssa.c
@@ -26,6 +26,7 @@
 #include "lib.h"
 #include "linearize.h"
 #include "allocate.h"
+#include "flow.h"
 #include <assert.h>
 
 
@@ -51,6 +52,7 @@ static void replace_phi_node(struct instruction *phi)
 	// update the current liveness
 	remove_pseudo(&phi->bb->needs, phi->target);
 	add_pseudo(&phi->bb->needs, tmp);
+	track_phi_uses(phi);
 
 	phi->opcode = OP_COPY;
 	phi->src = tmp;
-- 
1.6.4


             reply	other threads:[~2009-08-09  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-09  8:30 Kamil Dudka [this message]
2009-08-11  9:16 ` [PATCH] unssa: track uses when replacing a phi node Christopher Li

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=200908091030.24138.kdudka@redhat.com \
    --to=kdudka@redhat.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).