bufferizesToMemoryWrite(OpResult) looks for OpOperands that bufferize to memory writes inside the region of the defining op (if it has one). Currently, if the reverse use-def chain stops at any value inside of the region, the OpResult is considered to bufferize to a memory write.
It is always safe to have false positives among bufferizesToMemoryWrite, so the previous implementation is also correct. However, it can lead to additional buffer copies.
Depends On: D141684
What was the reasoning before for returning the leaves (even when they did not satisfy the condition) when using this function?
After this change, are there any uses for /*alwaysIncludeLeaves=*/true left?