In Dead store elimination, we currently do not remove stores in end basic blocks (blocks with no successors), when the basic blocks contains fence.
This patch allows us to remove the stores (and leave the fence as-is) when traversing *safe to remove* stores in end basic blocks.
Stylistically, this code should be further down. Just after the call site handling would be reasonable.
Comment wise, the explanation is a bit unclear. The key point is that a fence doesn't make a memory location visible to any other thread. It simply ensures ordering of already visible writes. Thus, skipping over the fence doesn't change whether a store is dead or not. I didn't get that from your comment.