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: Linus Torvalds <torvalds@linux-foundation.org>,
	Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 01/29] remove wrong part of simplify_loads()
Date: Wed, 16 Aug 2017 17:34:27 +0200	[thread overview]
Message-ID: <20170816153455.97693-2-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170816153455.97693-1-luc.vanoostenryck@gmail.com>

Currently simplify_loads() is broken with exactly the
same error as in simplify_one_symbol().

The core of the problem is that phi-nodes are stored at
the place where the value is needed, where the initial load
was, while phi-nodes must be placed where branches meet.

Temporary fix this removing this 'simplification'.

Note: It's possible to do this a bit less crudely
Note: This patch is kinda useless without the SSA construction
      first fixed..

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 memops.c                | 63 -------------------------------------------------
 validation/kill-casts.c |  1 -
 2 files changed, 64 deletions(-)

diff --git a/memops.c b/memops.c
index aeacdf566..99430e455 100644
--- a/memops.c
+++ b/memops.c
@@ -16,51 +16,6 @@
 #include "linearize.h"
 #include "flow.h"
 
-static int find_dominating_parents(pseudo_t pseudo, struct instruction *insn,
-	struct basic_block *bb, unsigned long generation, struct pseudo_list **dominators,
-	int local)
-{
-	struct basic_block *parent;
-
-	FOR_EACH_PTR(bb->parents, parent) {
-		struct instruction *one;
-		struct instruction *br;
-		pseudo_t phi;
-
-		FOR_EACH_PTR_REVERSE(parent->insns, one) {
-			int dominance;
-			if (!one->bb)
-				continue;
-			if (one == insn)
-				goto no_dominance;
-			dominance = dominates(pseudo, insn, one, local);
-			if (dominance < 0) {
-				if (one->opcode == OP_LOAD)
-					continue;
-				return 0;
-			}
-			if (!dominance)
-				continue;
-			goto found_dominator;
-		} END_FOR_EACH_PTR_REVERSE(one);
-no_dominance:
-		if (parent->generation == generation)
-			continue;
-		parent->generation = generation;
-
-		if (!find_dominating_parents(pseudo, insn, parent, generation, dominators, local))
-			return 0;
-		continue;
-
-found_dominator:
-		br = delete_last_instruction(&parent->insns);
-		phi = alloc_phi(parent, one->target, one->size);
-		phi->ident = phi->ident ? : one->target->ident;
-		add_instruction(&parent->insns, br);
-		use_pseudo(insn, phi, add_pseudo(dominators, phi));
-	} END_FOR_EACH_PTR(parent);
-	return 1;
-}		
 
 static int address_taken(pseudo_t pseudo)
 {
@@ -91,8 +46,6 @@ static void simplify_loads(struct basic_block *bb)
 			struct instruction *dom;
 			pseudo_t pseudo = insn->src;
 			int local = local_pseudo(pseudo);
-			struct pseudo_list *dominators;
-			unsigned long generation;
 
 			/* Check for illegal offsets.. */
 			check_access(insn);
@@ -117,22 +70,6 @@ static void simplify_loads(struct basic_block *bb)
 					goto next_load;
 				}
 			} END_FOR_EACH_PTR_REVERSE(dom);
-
-			/* OK, go find the parents */
-			generation = ++bb_generation;
-			bb->generation = generation;
-			dominators = NULL;
-			if (find_dominating_parents(pseudo, insn, bb, generation, &dominators, local)) {
-				/* This happens with initial assignments to structures etc.. */
-				if (!dominators) {
-					if (local) {
-						assert(pseudo->type != PSEUDO_ARG);
-						convert_load_instruction(insn, value_pseudo(0));
-					}
-					goto next_load;
-				}
-				rewrite_load_instruction(insn, dominators);
-			}
 		}
 next_load:
 		/* Do the next one */;
diff --git a/validation/kill-casts.c b/validation/kill-casts.c
index cf52f2460..7b72c4719 100644
--- a/validation/kill-casts.c
+++ b/validation/kill-casts.c
@@ -18,5 +18,4 @@ void foo(struct s *x)
  * check-command: test-linearize $file
  *
  * check-output-ignore
- * check-output-excludes: cast\\.
  */
-- 
2.14.0


  reply	other threads:[~2017-08-16 15:35 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16 15:34 [PATCH 00/29] Simple & Efficient SSA construction Luc Van Oostenryck
2017-08-16 15:34 ` Luc Van Oostenryck [this message]
2017-08-16 15:34 ` [PATCH 02/29] give a type to OP_PHISOURCEs Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 03/29] fix test case kill-phi-ttsb Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 04/29] add test case for incomplete type Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 05/29] add test case for bad return type Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 06/29] topasm: top-level asm is special Luc Van Oostenryck
2017-08-17  6:49   ` Christopher Li
2017-08-17 19:22     ` Luc Van Oostenryck
2017-08-18 15:13       ` Christopher Li
2017-08-16 15:34 ` [PATCH 07/29] ret-void: return nothing only for void functions Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 08/29] small code reorg of add_store() Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 09/29] add helper to test if a variable is "simple" Luc Van Oostenryck
2017-08-17  7:19   ` Christopher Li
2017-08-17 16:59     ` Dibyendu Majumdar
2017-08-17 19:17       ` Luc Van Oostenryck
2017-08-17 19:21         ` Dibyendu Majumdar
2017-08-17 19:25           ` Luc Van Oostenryck
2017-08-17 19:28             ` Dibyendu Majumdar
2017-08-18 16:18               ` Christopher Li
2017-08-18 16:38                 ` Luc Van Oostenryck
2017-08-18 18:15                 ` Dibyendu Majumdar
2017-08-18 18:35                   ` Christopher Li
2017-08-18 19:21                     ` Luc Van Oostenryck
2017-08-18 20:14                       ` Christopher Li
2017-08-18 20:27                         ` Luc Van Oostenryck
2017-08-17 19:51       ` Luc Van Oostenryck
2017-08-17 19:14     ` Luc Van Oostenryck
2017-08-18 16:13       ` Christopher Li
2017-08-18 16:26         ` Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 10/29] add helper imple_access() to test if an access " Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 11/29] add PSEUDO_UNDEF Luc Van Oostenryck
2017-08-17  7:30   ` Christopher Li
2017-08-17 16:55     ` Dibyendu Majumdar
2017-08-17 19:01       ` Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 12/29] add undef_pseudo() Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 13/29] add insert_phi_node() Luc Van Oostenryck
2017-08-18 20:39   ` Christopher Li
2017-08-18 20:52     ` Luc Van Oostenryck
2017-08-18 21:17       ` Christopher Li
2017-08-18 21:43         ` Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 14/29] extract alloc_phisrc() from alloc_phi() Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 15/29] add remove_use() Luc Van Oostenryck
2017-08-18 20:51   ` Christopher Li
2017-08-16 15:34 ` [PATCH 16/29] ptrmap: add missing #include "compat.h" Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 17/29] ptrmap: core implementation Luc Van Oostenryck
2017-08-18 21:02   ` Christopher Li
2017-08-18 21:35     ` Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 18/29] ptrmap: add type-safe interface Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 19/29] sssa: add Simple SSA interfaces Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 20/29] sssa: add needed new members Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 21/29] sssa: add basic implementation Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 22/29] sssa: add seal_gotos() needed to seal BBs targeted by gotos Luc Van Oostenryck
2017-08-18 21:26   ` Christopher Li
2017-08-18 21:46     ` Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 23/29] sssa: set var's ident Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 24/29] sssa: add PSEUDO_INDIR Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 25/29] sssa: reorg load_var() Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 26/29] sssa: protect against unreachable loops Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 27/29] sssa: remove trivial phi-nodes Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 28/29] sssa: switch to the new SSA construction Luc Van Oostenryck
2017-08-18 21:47   ` Christopher Li
2017-08-18 21:58     ` Luc Van Oostenryck
2017-08-16 15:34 ` [PATCH 29/29] sssa: remove now unneeded simplify_one_symbol() Luc Van Oostenryck
2017-08-16 15:51 ` [PATCH 00/29] Simple & Efficient SSA construction Linus Torvalds
2017-08-16 16:12   ` Luc Van Oostenryck
2017-08-17  4:45   ` Christopher Li
2017-08-17  4:42 ` Christopher Li
2017-08-17  5:16   ` Luc Van Oostenryck
2017-08-17  5:58     ` Christopher Li
2017-08-17 19:29       ` Luc Van Oostenryck
2017-08-17 20:04       ` Luc Van Oostenryck
2017-08-19  2:08         ` Christopher Li
2017-08-17  6:09     ` Luc Van Oostenryck
2017-08-17  6:16       ` Christopher Li
2017-08-17 19:58         ` Luc Van Oostenryck
2017-08-17 10:10   ` Dibyendu Majumdar

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=20170816153455.97693-2-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --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).