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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 9 14:47:06 PDT 2020


nikic added a comment.

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

> Oh, I see, the unmodified callCapturesBefore result is correct if you're trying to determine whether the the call might modify a value that can be consumed by a load, but not if you're trying to determine if a store clobbers memory that might be used in another thread.
>
> I think I'd prefer to sink the conditional into callCapturesBefore itself, so anyone who modifies it in the future has the necessary context.  I think the isa<Argument> check is too tightly coupled to the implementation of callCapturesBefore, as opposed to its abstract semantics.

To clarify, the suggestion here is to add a boolean flag to callCapturesBefore() that determines whether arguments should always be considered capturing?

One thing to note is that this would not allow us to treat the call modref check (which does not care about noalias arguments) and the willreturn check (which does) separately. That is, the following code would no longer fold:

  define void @test(i8* noalias dereferenceable(16) %dest.i8) {
    %src = alloca [16 x i8]
    %src.i8 = bitcast [16 x i8]* %src to i8*
    call void @accept_ptr(i8* %src.i8) nounwind willreturn
    call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest.i8, i8* %src.i8, i64 16, i1 false)
    call void @accept_ptr(i8* %dest.i8) ; capture
    ret void
  }

Of course, it's not a big loss.


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

https://reviews.llvm.org/D88921



More information about the llvm-commits mailing list