On 11/17/21 22:09, Zebediah Figura (she/her) wrote:
+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?
Wait, never mind, I see why this looks wrong. The fact that "depth" is 1-biased seems confusing to me, though...
+ 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; +}