All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fix rem_usage()
@ 2020-12-27  9:27 Luc Van Oostenryck
  2020-12-27  9:27 ` [PATCH 1/2] add helper has_definition() Luc Van Oostenryck
  2020-12-27  9:27 ` [PATCH 2/2] fix rem_usage() Luc Van Oostenryck
  0 siblings, 2 replies; 8+ messages in thread
From: Luc Van Oostenryck @ 2020-12-27  9:27 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

These two patches fix a bug with rem_usage(), after having removed the
last element of a def-use list, tries to kill the defining instruction
although only PSEUDO_REGs and PSEUDO_PHIs have one.


Luc Van Oostenryck (2):
  add helper has_definition()
  fix rem_usage()

 linearize.h | 5 +++++
 simplify.c  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.29.2


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

* [PATCH 1/2] add helper has_definition()
  2020-12-27  9:27 [PATCH 0/2] fix rem_usage() Luc Van Oostenryck
@ 2020-12-27  9:27 ` Luc Van Oostenryck
  2020-12-28 17:20   ` Ramsay Jones
  2020-12-27  9:27 ` [PATCH 2/2] fix rem_usage() Luc Van Oostenryck
  1 sibling, 1 reply; 8+ messages in thread
From: Luc Van Oostenryck @ 2020-12-27  9:27 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

Add he helper has_definition() to check if the pseudo belong to one
of the pseudo types having a definition: PSEUDO_REG & PSEUDO_PHI.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 linearize.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linearize.h b/linearize.h
index 2c548d43526f..c5bdd04257a1 100644
--- a/linearize.h
+++ b/linearize.h
@@ -249,6 +249,11 @@ static inline int has_use_list(pseudo_t p)
 	return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_UNDEF && p->type != PSEUDO_VAL);
 }
 
+static inline bool has_definition(pseudo_t p)
+{
+	return p->type == PSEUDO_REG || p->type == PSEUDO_PHI;
+}
+
 static inline int pseudo_user_list_size(struct pseudo_user_list *list)
 {
 	return ptr_list_size((struct ptr_list *)list);
-- 
2.29.2


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

* [PATCH 2/2] fix rem_usage()
  2020-12-27  9:27 [PATCH 0/2] fix rem_usage() Luc Van Oostenryck
  2020-12-27  9:27 ` [PATCH 1/2] add helper has_definition() Luc Van Oostenryck
@ 2020-12-27  9:27 ` Luc Van Oostenryck
  2020-12-28 17:22   ` Ramsay Jones
  1 sibling, 1 reply; 8+ messages in thread
From: Luc Van Oostenryck @ 2020-12-27  9:27 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

rem_usage() is used to remove an element from a def-use chain. Optionally,
if the chain become empty, the defining instruction can also be killed.

This optional part is currently be done on all pseudos but only those
having a definition should be concerned.

Fix this by adding a check so that only PSEUDO_REGs and PSEUDO_PHIs are killed.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/simplify.c b/simplify.c
index a877b693b610..12482d787189 100644
--- a/simplify.c
+++ b/simplify.c
@@ -271,7 +271,7 @@ static inline void rem_usage(pseudo_t p, pseudo_t *usep, int kill)
 {
 	if (has_use_list(p)) {
 		delete_pseudo_user_list_entry(&p->users, usep, 1);
-		if (kill && !p->users)
+		if (kill && !p->users && has_definition(p))
 			kill_instruction(p->def);
 	}
 }
-- 
2.29.2


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

* Re: [PATCH 1/2] add helper has_definition()
  2020-12-27  9:27 ` [PATCH 1/2] add helper has_definition() Luc Van Oostenryck
@ 2020-12-28 17:20   ` Ramsay Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Ramsay Jones @ 2020-12-28 17:20 UTC (permalink / raw)
  To: Luc Van Oostenryck, linux-sparse



On 27/12/2020 09:27, Luc Van Oostenryck wrote:
> Add he helper has_definition() to check if the pseudo belong to one

s/Add he/Add the/

ATB,
Ramsay Jones

> of the pseudo types having a definition: PSEUDO_REG & PSEUDO_PHI.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  linearize.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/linearize.h b/linearize.h
> index 2c548d43526f..c5bdd04257a1 100644
> --- a/linearize.h
> +++ b/linearize.h
> @@ -249,6 +249,11 @@ static inline int has_use_list(pseudo_t p)
>  	return (p && p->type != PSEUDO_VOID && p->type != PSEUDO_UNDEF && p->type != PSEUDO_VAL);
>  }
>  
> +static inline bool has_definition(pseudo_t p)
> +{
> +	return p->type == PSEUDO_REG || p->type == PSEUDO_PHI;
> +}
> +
>  static inline int pseudo_user_list_size(struct pseudo_user_list *list)
>  {
>  	return ptr_list_size((struct ptr_list *)list);
> 

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

* Re: [PATCH 2/2] fix rem_usage()
  2020-12-27  9:27 ` [PATCH 2/2] fix rem_usage() Luc Van Oostenryck
@ 2020-12-28 17:22   ` Ramsay Jones
  2020-12-28 21:39     ` Luc Van Oostenryck
  0 siblings, 1 reply; 8+ messages in thread
From: Ramsay Jones @ 2020-12-28 17:22 UTC (permalink / raw)
  To: Luc Van Oostenryck, linux-sparse



On 27/12/2020 09:27, Luc Van Oostenryck wrote:
> rem_usage() is used to remove an element from a def-use chain. Optionally,

Hmm, rename this to 'remove_usage()' at the same time?

ATB,
Ramsay Jones

> if the chain become empty, the defining instruction can also be killed.
> 
> This optional part is currently be done on all pseudos but only those
> having a definition should be concerned.
> 
> Fix this by adding a check so that only PSEUDO_REGs and PSEUDO_PHIs are killed.
> 
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
>  simplify.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/simplify.c b/simplify.c
> index a877b693b610..12482d787189 100644
> --- a/simplify.c
> +++ b/simplify.c
> @@ -271,7 +271,7 @@ static inline void rem_usage(pseudo_t p, pseudo_t *usep, int kill)
>  {
>  	if (has_use_list(p)) {
>  		delete_pseudo_user_list_entry(&p->users, usep, 1);
> -		if (kill && !p->users)
> +		if (kill && !p->users && has_definition(p))
>  			kill_instruction(p->def);
>  	}
>  }
> 

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

* Re: [PATCH 2/2] fix rem_usage()
  2020-12-28 17:22   ` Ramsay Jones
@ 2020-12-28 21:39     ` Luc Van Oostenryck
  2020-12-28 22:09       ` Ramsay Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Luc Van Oostenryck @ 2020-12-28 21:39 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: linux-sparse

On Mon, Dec 28, 2020 at 05:22:36PM +0000, Ramsay Jones wrote:
> 
> 
> On 27/12/2020 09:27, Luc Van Oostenryck wrote:
> > rem_usage() is used to remove an element from a def-use chain. Optionally,
> 
> Hmm, rename this to 'remove_usage()' at the same time?

It can't, 'remove_usage()' is already taken and 'rem_usage()' is more
for internal uses than 'remove_usage()'.

-- Luc

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

* Re: [PATCH 2/2] fix rem_usage()
  2020-12-28 21:39     ` Luc Van Oostenryck
@ 2020-12-28 22:09       ` Ramsay Jones
  2020-12-28 22:30         ` Ramsay Jones
  0 siblings, 1 reply; 8+ messages in thread
From: Ramsay Jones @ 2020-12-28 22:09 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-sparse



On 28/12/2020 21:39, Luc Van Oostenryck wrote:
> On Mon, Dec 28, 2020 at 05:22:36PM +0000, Ramsay Jones wrote:
>>
>>
>> On 27/12/2020 09:27, Luc Van Oostenryck wrote:
>>> rem_usage() is used to remove an element from a def-use chain. Optionally,
>>
>> Hmm, rename this to 'remove_usage()' at the same time?
> 
> It can't, 'remove_usage()' is already taken and 'rem_usage()' is more
> for internal uses than 'remove_usage()'.

Ugh! I just took a quick look. Ugly. ;-)

Well, I think I would rename it 'remove_use()' or somesuch instead.

ATB,
Ramsay Jones


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

* Re: [PATCH 2/2] fix rem_usage()
  2020-12-28 22:09       ` Ramsay Jones
@ 2020-12-28 22:30         ` Ramsay Jones
  0 siblings, 0 replies; 8+ messages in thread
From: Ramsay Jones @ 2020-12-28 22:30 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: linux-sparse



On 28/12/2020 22:09, Ramsay Jones wrote:
> 
> 
> On 28/12/2020 21:39, Luc Van Oostenryck wrote:
>> On Mon, Dec 28, 2020 at 05:22:36PM +0000, Ramsay Jones wrote:
>>>
>>>
>>> On 27/12/2020 09:27, Luc Van Oostenryck wrote:
>>>> rem_usage() is used to remove an element from a def-use chain. Optionally,
>>>
>>> Hmm, rename this to 'remove_usage()' at the same time?
>>
>> It can't, 'remove_usage()' is already taken and 'rem_usage()' is more
>> for internal uses than 'remove_usage()'.
> 
> Ugh! I just took a quick look. Ugly. ;-)
> 
> Well, I think I would rename it 'remove_use()' or somesuch instead.

Ahem, except you can't, because it is already used ... (facepalm).

Ho Hum. ;-)

ATB,
Ramsay Jones


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

end of thread, other threads:[~2020-12-28 23:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27  9:27 [PATCH 0/2] fix rem_usage() Luc Van Oostenryck
2020-12-27  9:27 ` [PATCH 1/2] add helper has_definition() Luc Van Oostenryck
2020-12-28 17:20   ` Ramsay Jones
2020-12-27  9:27 ` [PATCH 2/2] fix rem_usage() Luc Van Oostenryck
2020-12-28 17:22   ` Ramsay Jones
2020-12-28 21:39     ` Luc Van Oostenryck
2020-12-28 22:09       ` Ramsay Jones
2020-12-28 22:30         ` Ramsay Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.