This is an improvement with a *LOW* priority. Only if spare time (hey could be a nice homework). See comments in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46941
Bringing in a note from the other PR... The reason memory allocated by the C++ new operator does not get optimized by the TM-memopt pass is not because of a missing ECF_MALLOC attribute, but because the alias oracle in GCC considers the chunk of memory as possibly able to escape from the current function. That is, the following hunk of code returns true in the TM-memopt pass: if (ptr_deref_may_alias_global_p (x)) Apparently, since new/delete operators may be overridden by class specific hooks, the memory must be considered escaped.
If the alias oracle considers the memory region returned from new/delete to be potentially escaping to code outside of the transaction, then I think we need to respect this. If you think this should not be possible, please file another bug against the alias oracle.