[all-commits] [llvm/llvm-project] 7abefc: [instcombine] Fold away memset/memmove from otherw...

Philip Reames via All-commits all-commits at lists.llvm.org
Tue Mar 22 13:49:08 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7abefc42220b74551b433083ece33be31e48700f
      https://github.com/llvm/llvm-project/commit/7abefc42220b74551b433083ece33be31e48700f
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2022-03-22 (Tue, 22 Mar 2022)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
    M llvm/test/Transforms/Inline/byval-tail-call.ll
    M llvm/test/Transforms/InstCombine/memcpy_alloca.ll

  Log Message:
  -----------
  [instcombine] Fold away memset/memmove from otherwise unused alloca

The motivation for this is that while both memcpyopt and dse will catch this case, both are limited by MSSA's walk back threshold when finding clobbers.  As such, if you have a memcpy of an otherwise dead alloca placed towards the end of a long basic block with lots of other memory instructions, it would be missed.  This is a bit undesirable for such an "obviously" useless bit of code.

As noted in comments, we should probably generalize instcombine's escape analysis peephole (see visitAllocInst) to allow read xor write.  Doing that would subsume this code in a more general way, but is also a more involved change.  For the moment, I went with the easiest fix.




More information about the All-commits mailing list