Re: [PATCH] fix OP_PHI usage in try_to_simplify_bb(), correctly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 22, 2017 at 6:53 PM, Luc Van Oostenryck
<luc.vanoostenryck@xxxxxxxxx> wrote:
> Patch 11b1a83b1 solved an issue with dangling PSEUDO_PHI
> by killing it's use after a branch rewrite.
>
> However, the change didn't took in account the fact that,
> even after the branch rewrite, some other paths may exist
> where this pseudo was needed.
>
> Fix this by cheking that no such path exist before killing
> the (usage of the) pseudo.
>
> Fixes: 11b1a83b1 "fix OP_PHI usage in try_to_simplify_bb()"
> Reported-by: Dibyendu Majumdar <mobile@xxxxxxxxxxxxxxx>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
> ---
>  flow.c                       | 35 ++++++++++++++++++++++++++++++++++-
>  validation/kill-phi-ttsbb2.c | 40 ++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 74 insertions(+), 1 deletion(-)
>  create mode 100644 validation/kill-phi-ttsbb2.c
>
> diff --git a/flow.c b/flow.c
> index a5332203f..c12bc0716 100644
> --- a/flow.c
> +++ b/flow.c
> @@ -79,6 +79,39 @@ static int bb_depends_on(struct basic_block *target, struct basic_block *src)
>         return 0;
>  }
>
> +/*
> + * Return 1 if 'pseudo' is needed in some parent of 'bb'.
> + * Need liveness info.
> + */
> +static int needed_phisrc(struct instruction *phi, struct basic_block *curr, unsigned long generation)
> +{
> +       pseudo_t target = phi->target;
> +       struct basic_block *bb;
> +       int rc = 0;
> +
> +       curr->generation = generation;
> +       FOR_EACH_PTR(curr->children, bb) {
> +               if (bb->generation == generation)
> +                       continue;
> +               if (bb == phi->bb)
> +                       continue;
> +               if (pseudo_in_list(bb->defines, target)) {
> +                       continue;
> +               }

For just one line continue, there is no need for {}

> +               if (pseudo_in_list(bb->needs, target)) {
> +                       rc = 1;
> +                       goto ret;

Can this simplify as "return 1;"

> +               }
> +               rc = needed_phisrc(phi, bb, generation);
> +               if (rc)
> +                       goto ret;
needed_phisrc(phi, bb, generation)

And "return 1;" here
> +
> +       } END_FOR_EACH_PTR(bb);


> +
> +ret:
> +       return rc;

"return 0" here.
There is no need for rc variable.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux