[PATCH] D89190: [MemCpyOpt] Don't shorten memset if destination observable through unwinding

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 10 09:25:58 PDT 2020


nikic added a subscriber: fhahn.
nikic added a comment.

> As a side-note, at least for the constant size case this transform should really be performed by DSE, and it does have some support for this (isShortenableAtTheBeginning), but apparently doesn't catch the memset+memcpy combination.

After looking into this a bit more, the problem is that I tried something like this

  define void @test(i8* %src, i8* %dst, i8 %c) {
    call void @llvm.memset.p0i8.i64(i8* %dst, i8 %c, i64 64, i1 false)
    call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dst, i8* %src, i64 32, i1 false)
    ret void
  }

which doesn't work, while adding a `noalias` on `%dst` does work. As a result of D86815 <https://reviews.llvm.org/D86815>, the memcpy now counts as a read-clobber of `%dst`, as dst and src may be equal. And with that in mind, the MemCpyOpt transform isn't correct either since that change, unless we know that dst and src are NoAlias. cc @fhahn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89190



More information about the llvm-commits mailing list