[PATCH vkd3d v7 5/6] vkd3d-shader/hlsl: Handle conditionals in copy propagation.

Zebediah Figura (she/her) zfigura at codeweavers.com
Wed Nov 17 22:09:21 CST 2021


On 11/17/21 02:47, Giovanni Mascellani wrote:
> @@ -272,7 +283,9 @@ struct copy_propagation_variable
>   
>   struct copy_propagation_state
>   {
> -    struct rb_tree variables;
> +    struct rb_tree *variables;

I didn't notice this last time, but since IIUC rbtree entries can hold a 
pointer to the head of the list (much like linked list entries), this 
isn't safe. You'll need to individually allocate list heads.

> +    size_t depth;
> +    size_t capacity;
>   };
>   

...

> +static bool copy_propagation_duplicate(struct hlsl_ctx *ctx, struct copy_propagation_state *state)
> +{
> +    struct copy_propagation_variable *var;
> +
> +    if (!hlsl_array_reserve(ctx, (void**)&state->variables, &state->capacity, state->depth + 2, sizeof(*state->variables)))

"state->depth + 2" looks wrong; is it?

> +        return false;
> +    ++state->depth;
> +
> +    rb_init(&state->variables[state->depth], copy_propagation_variable_compare);
> +
> +    RB_FOR_EACH_ENTRY(var, &state->variables[state->depth - 1], struct copy_propagation_variable, entry)
> +    {
> +        struct copy_propagation_variable *new_var = copy_propagation_create_variable(ctx, state, var->var);
> +
> +        if (!new_var)
> +            return false;
> +
> +        memcpy(new_var->values, var->values, sizeof(*var->values) * var->var->data_type->reg_size);
> +    }
> +
> +    return true;
> +}
> +



More information about the wine-devel mailing list