linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] simple, registrable, promotable & friends
@ 2017-08-17 22:35 Luc Van Oostenryck
  2017-08-17 22:35 ` [RFC PATCH 2/4] fold is_simple_var() into simple_access() Luc Van Oostenryck
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luc Van Oostenryck @ 2017-08-17 22:35 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li, Dibyendu Majumdar, Luc Van Oostenryck

The goal of this series is tosolve the issues with the 
current is_simple_{var,type}():
- the name was less than optimal, I've choosen 'promotable'
- fix the case for structs & unions.

Luc Van Oostenryck (4):
  move is_simple_XXX() to linearize.c
  fold is_simple_var() into simple_access()
  rename 'simple_{var,access}' by promatable_...'
  fix promotion of struct & union

 linearize.c | 45 +++++++++++++++++++++++++++++++++++++++++----
 symbol.h    | 33 ---------------------------------
 2 files changed, 41 insertions(+), 37 deletions(-)

-- 
2.14.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [RFC PATCH 2/4] fold is_simple_var() into simple_access()
  2017-08-17 22:35 [RFC PATCH 0/4] simple, registrable, promotable & friends Luc Van Oostenryck
@ 2017-08-17 22:35 ` Luc Van Oostenryck
  2017-08-17 22:35 ` [RFC PATCH 3/4] rename 'simple_{var,access}' by promatable_...' Luc Van Oostenryck
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luc Van Oostenryck @ 2017-08-17 22:35 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li, Dibyendu Majumdar, Luc Van Oostenryck

---
 linearize.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/linearize.c b/linearize.c
index 9a7a71d3a..63c896fc7 100644
--- a/linearize.c
+++ b/linearize.c
@@ -978,16 +978,7 @@ static inline int is_simple_type(struct symbol *type)
 	return 0;
 }
 
-static inline int is_simple_var(struct symbol *var)
-{
-	if (!is_simple_type(var))
-		return 0;
 #define	MOD_NONREG	(MOD_STATIC|MOD_NONLOCAL|MOD_ADDRESSABLE|MOD_VOLATILE)
-	if (var->ctype.modifiers & MOD_NONREG)
-		return 0;
-	return 1;
-}

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 3/4] rename 'simple_{var,access}' by promatable_...'
  2017-08-17 22:35 [RFC PATCH 0/4] simple, registrable, promotable & friends Luc Van Oostenryck
  2017-08-17 22:35 ` [RFC PATCH 2/4] fold is_simple_var() into simple_access() Luc Van Oostenryck
@ 2017-08-17 22:35 ` Luc Van Oostenryck
  2017-08-17 22:35 ` [RFC PATCH 4/4] fix promotion of struct & union Luc Van Oostenryck
  2017-08-19 11:28 ` [RFC PATCH 0/4] simple, registrable, promotable & friends Christopher Li
  3 siblings, 0 replies; 5+ messages in thread
From: Luc Van Oostenryck @ 2017-08-17 22:35 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li, Dibyendu Majumdar, Luc Van Oostenryck

---
 linearize.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/linearize.c b/linearize.c
index 63c896fc7..485d8eeec 100644
--- a/linearize.c
+++ b/linearize.c
@@ -955,7 +955,7 @@ static int linearize_address_gen(struct entrypoint *ep,
 /*
  * Is it possible and desirable for this to be promoted to a pseudo?
  */
-static inline int is_simple_type(struct symbol *type)
+static inline int is_promotable(struct symbol *type)
 {
 	if (type->type == SYM_NODE)
 		type = type->ctype.base_type;
@@ -979,7 +979,7 @@ static inline int is_simple_type(struct symbol *type)
 }
 
 #define	MOD_NONREG	(MOD_STATIC|MOD_NONLOCAL|MOD_ADDRESSABLE|MOD_VOLATILE)
-static inline struct symbol *simple_access(struct access_data *ad)
+static inline struct symbol *promotable_access(struct access_data *ad)
 {
 	pseudo_t addr = ad->address;
 	struct symbol *sym;
@@ -989,7 +989,7 @@ static inline struct symbol *simple_access(struct access_data *ad)
 	sym = addr->sym;
 	if (sym->ctype.modifiers & MOD_NONREG)
 		return NULL;
-	if (!is_simple_type(sym))
+	if (!is_promotable(sym))
 		return NULL;
 	return sym;
 }
@@ -1003,7 +1003,7 @@ static pseudo_t add_load(struct entrypoint *ep, struct access_data *ad)
 
 	if (!bb)
 		return VOID;
-	if ((var = simple_access(ad))) {
+	if ((var = promotable_access(ad))) {
 		new = load_var(bb, var);
 		return new;
 	}
@@ -1027,7 +1027,7 @@ static void add_store(struct entrypoint *ep, struct access_data *ad, pseudo_t va
 	if (!bb)
 		return;
 
-	if ((var = simple_access(ad))) {
+	if ((var = promotable_access(ad))) {
 		store_var(bb, var, value);
 		return;
 	}
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [RFC PATCH 4/4] fix promotion of struct & union
  2017-08-17 22:35 [RFC PATCH 0/4] simple, registrable, promotable & friends Luc Van Oostenryck
  2017-08-17 22:35 ` [RFC PATCH 2/4] fold is_simple_var() into simple_access() Luc Van Oostenryck
  2017-08-17 22:35 ` [RFC PATCH 3/4] rename 'simple_{var,access}' by promatable_...' Luc Van Oostenryck
@ 2017-08-17 22:35 ` Luc Van Oostenryck
  2017-08-19 11:28 ` [RFC PATCH 0/4] simple, registrable, promotable & friends Christopher Li
  3 siblings, 0 replies; 5+ messages in thread
From: Luc Van Oostenryck @ 2017-08-17 22:35 UTC (permalink / raw)
  To: linux-sparse; +Cc: Christopher Li, Dibyendu Majumdar, Luc Van Oostenryck

---
 linearize.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/linearize.c b/linearize.c
index 485d8eeec..a92a0e095 100644
--- a/linearize.c
+++ b/linearize.c
@@ -957,6 +957,8 @@ static int linearize_address_gen(struct entrypoint *ep,
  */
 static inline int is_promotable(struct symbol *type)
 {
+	struct symbol *member;
+
 	if (type->type == SYM_NODE)
 		type = type->ctype.base_type;
 	switch (type->type) {
@@ -967,7 +969,13 @@ static inline int is_promotable(struct symbol *type)
 		return 1;
 	case SYM_STRUCT:
 	case SYM_UNION:
-		return type->bit_size <= long_ctype.bit_size;
+		if (type->bit_size > long_ctype.bit_size)
+			return 0;
+		FOR_EACH_PTR(type->symbol_list, member) {
+			if (!is_promotable(member))
+				return 0;
+		} END_FOR_EACH_PTR(member);
+		return 1;
 	default:
 		break;
 	}
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [RFC PATCH 0/4] simple, registrable, promotable & friends
  2017-08-17 22:35 [RFC PATCH 0/4] simple, registrable, promotable & friends Luc Van Oostenryck
                   ` (2 preceding siblings ...)
  2017-08-17 22:35 ` [RFC PATCH 4/4] fix promotion of struct & union Luc Van Oostenryck
@ 2017-08-19 11:28 ` Christopher Li
  3 siblings, 0 replies; 5+ messages in thread
From: Christopher Li @ 2017-08-19 11:28 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Linux-Sparse, Dibyendu Majumdar

On Thu, Aug 17, 2017 at 6:35 PM, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> The goal of this series is tosolve the issues with the
> current is_simple_{var,type}():
> - the name was less than optimal, I've choosen 'promotable'
> - fix the case for structs & unions.
>

This series looks fine to me. The SSSA method still have the
question of using C pointers. But that is a separate issue.

Chris

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-08-19 11:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17 22:35 [RFC PATCH 0/4] simple, registrable, promotable & friends Luc Van Oostenryck
2017-08-17 22:35 ` [RFC PATCH 2/4] fold is_simple_var() into simple_access() Luc Van Oostenryck
2017-08-17 22:35 ` [RFC PATCH 3/4] rename 'simple_{var,access}' by promatable_...' Luc Van Oostenryck
2017-08-17 22:35 ` [RFC PATCH 4/4] fix promotion of struct & union Luc Van Oostenryck
2017-08-19 11:28 ` [RFC PATCH 0/4] simple, registrable, promotable & friends Christopher Li

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).