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 02/29] give a type to OP_PHISOURCEs
Date: Wed, 16 Aug 2017 17:34:28 +0200 [thread overview]
Message-ID: <20170816153455.97693-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170816153455.97693-1-luc.vanoostenryck@gmail.com>
Currently, OP_PHISOURCEs are given a size but not a type.
For consistency and for sparse-LLVM which need it,
give them a type too.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
flow.c | 2 +-
linearize.c | 16 +++++++---------
linearize.h | 2 +-
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/flow.c b/flow.c
index 6b2c879a8..78dd6b3a5 100644
--- a/flow.c
+++ b/flow.c
@@ -414,7 +414,7 @@ found_dominator:
if (dominators && phisrc_in_bb(*dominators, parent))
continue;
br = delete_last_instruction(&parent->insns);
- phi = alloc_phi(parent, one->target, one->size);
+ phi = alloc_phi(parent, one->target, one->type);
phi->ident = phi->ident ? : pseudo->ident;
add_instruction(&parent->insns, br);
use_pseudo(insn, phi, add_pseudo(dominators, phi));
diff --git a/linearize.c b/linearize.c
index ba76397ea..e3d234e7e 100644
--- a/linearize.c
+++ b/linearize.c
@@ -821,7 +821,7 @@ static pseudo_t argument_pseudo(struct entrypoint *ep, int nr)
return pseudo;
}
-pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size)
+pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type)
{
struct instruction *insn;
pseudo_t phi;
@@ -830,7 +830,7 @@ pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size)
if (!source)
return VOID;
- insn = alloc_instruction(OP_PHISOURCE, size);
+ insn = alloc_typed_instruction(OP_PHISOURCE, type);
phi = __alloc_pseudo(0);
phi->type = PSEUDO_PHI;
phi->nr = ++nr;
@@ -1384,19 +1384,18 @@ static pseudo_t linearize_short_conditional(struct entrypoint *ep, struct expres
struct basic_block *bb_false;
struct basic_block *merge = alloc_basic_block(ep, expr->pos);
pseudo_t phi1, phi2;
- int size = type_size(expr->ctype);
if (!expr_false || !ep->active)
return VOID;
bb_false = alloc_basic_block(ep, expr_false->pos);
src1 = linearize_expression(ep, cond);
- phi1 = alloc_phi(ep->active, src1, size);
+ phi1 = alloc_phi(ep->active, src1, expr->ctype);
add_branch(ep, expr, src1, merge, bb_false);
set_activeblock(ep, bb_false);
src2 = linearize_expression(ep, expr_false);
- phi2 = alloc_phi(ep->active, src2, size);
+ phi2 = alloc_phi(ep->active, src2, expr->ctype);
set_activeblock(ep, merge);
return add_join_conditional(ep, expr, phi1, phi2);
@@ -1410,7 +1409,6 @@ static pseudo_t linearize_conditional(struct entrypoint *ep, struct expression *
pseudo_t src1, src2;
pseudo_t phi1, phi2;
struct basic_block *bb_true, *bb_false, *merge;
- int size = type_size(expr->ctype);
if (!cond || !expr_true || !expr_false || !ep->active)
return VOID;
@@ -1422,12 +1420,12 @@ static pseudo_t linearize_conditional(struct entrypoint *ep, struct expression *
set_activeblock(ep, bb_true);
src1 = linearize_expression(ep, expr_true);
- phi1 = alloc_phi(ep->active, src1, size);
+ phi1 = alloc_phi(ep->active, src1, expr->ctype);
add_goto(ep, merge);
set_activeblock(ep, bb_false);
src2 = linearize_expression(ep, expr_false);
- phi2 = alloc_phi(ep->active, src2, size);
+ phi2 = alloc_phi(ep->active, src2, expr->ctype);
set_activeblock(ep, merge);
return add_join_conditional(ep, expr, phi1, phi2);
@@ -1926,7 +1924,7 @@ static pseudo_t linearize_return(struct entrypoint *ep, struct statement *stmt)
phi_node->bb = bb_return;
add_instruction(&bb_return->insns, phi_node);
}
- phi = alloc_phi(active, src, type_size(expr->ctype));
+ phi = alloc_phi(active, src, expr->ctype);
phi->ident = &return_ident;
use_pseudo(phi_node, phi, add_pseudo(&phi_node->phi_list, phi));
}
diff --git a/linearize.h b/linearize.h
index bac82d7ff..c03940eea 100644
--- a/linearize.h
+++ b/linearize.h
@@ -331,7 +331,7 @@ struct entrypoint {
extern void insert_select(struct basic_block *bb, struct instruction *br, struct instruction *phi, pseudo_t if_true, pseudo_t if_false);
extern void insert_branch(struct basic_block *bb, struct instruction *br, struct basic_block *target);
-pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, int size);
+pseudo_t alloc_phi(struct basic_block *source, pseudo_t pseudo, struct symbol *type);
pseudo_t alloc_pseudo(struct instruction *def);
pseudo_t value_pseudo(long long val);
--
2.14.0
next prev parent 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 ` [PATCH 01/29] remove wrong part of simplify_loads() Luc Van Oostenryck
2017-08-16 15:34 ` Luc Van Oostenryck [this message]
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-3-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).