[PATCH] D88921: [MemCpyOpt] Fix thread-safety of call slot opimization

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 00:48:45 PDT 2020


nikic added a comment.

In D88921#2315685 <https://reviews.llvm.org/D88921#2315685>, @efriedma wrote:

>> If the caller is nosync there is no need for all this thread safety checking.
>
> I'm not sure nosync helps here?  The issue this patch is trying to solve is the case where the memcpy is dynamically dead due to an infinite loop; there isn't any synchronization involved.

That's right. If we synchronized between the copy and the memcpy, then we'd see that as the memcpy dependency. This only applies to the unsynchronized, dynamically dead case.



================
Comment at: llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp:810
+  MemoryLocation destLoc(cpyDest, srcSize);
+  if (isModOrRefSet(AA->callCapturesBefore(C, destLoc, DT))) {
+    // Ensure dest is not accessed by the call.
----------------
efriedma wrote:
> callCapturesBefore only checks the call C itself.  Don't we also care if the pointer is captured somewhere before the call?
I find this method to be somewhat confusingly named, but what it actually does is to a) check for captures up to and including the call (-> ModRef) and b) a potential access via a non-capturing argument in the call itself.

See https://github.com/llvm/llvm-project/blob/334ec6f807fa65e09571fa42a0c3be0eb39e7c0f/llvm/lib/Analysis/AliasAnalysis.cpp#L652.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88921/new/

https://reviews.llvm.org/D88921



More information about the llvm-commits mailing list