nir/lower_io: Add a build_addr_for_var helper
[mesa.git] / src / compiler / nir / nir_opt_copy_prop_vars.c
index fddbf88daf9edc78af60ae2e6db310f8b7fa30f8..8b41e0e8832779e4b6ca7aa3543518a1a65a96d9 100644 (file)
@@ -290,10 +290,10 @@ static void
 copy_entry_remove(struct util_dynarray *copies,
                   struct copy_entry *entry)
 {
-   /* This also works when removing the last element since pop don't shrink
-    * the memory used by the array, so the swap is useless but not invalid.
-    */
-   *entry = util_dynarray_pop(copies, struct copy_entry);
+   const struct copy_entry *src =
+      util_dynarray_pop_ptr(copies, struct copy_entry);
+   if (src != entry)
+      *entry = *src;
 }
 
 static bool