This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix vect_permute_load_chain leaks (PR middle-end/56461)


Hi!

This function used vec copy () method, but unfortunately that allocates
a fresh new vector and overwrites the target vector<tree> variable with it
(making it leak memory).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2013-02-27  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/56461
	* tree-vect-data-refs.c (vect_permute_load_chain): Avoid using copy
	method on dr_chain and result_chain.

--- gcc/tree-vect-data-refs.c.jj	2013-02-05 16:45:40.000000000 +0100
+++ gcc/tree-vect-data-refs.c	2013-02-27 17:59:19.574144962 +0100
@@ -4673,7 +4673,9 @@ vect_permute_load_chain (vec<tree> dr_ch
   unsigned nelt = TYPE_VECTOR_SUBPARTS (vectype);
   unsigned char *sel = XALLOCAVEC (unsigned char, nelt);
 
-  *result_chain = dr_chain.copy ();
+  result_chain->quick_grow (length);
+  memcpy (result_chain->address (), dr_chain.address (),
+	  length * sizeof (tree));
 
   for (i = 0; i < nelt; ++i)
     sel[i] = i * 2;
@@ -4708,7 +4710,8 @@ vect_permute_load_chain (vec<tree> dr_ch
 	  vect_finish_stmt_generation (stmt, perm_stmt, gsi);
 	  (*result_chain)[j/2+length/2] = data_ref;
 	}
-      dr_chain = result_chain->copy ();
+      memcpy (dr_chain.address (), result_chain->address (),
+	      length * sizeof (tree));
     }
 }
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]