[all-commits] [llvm/llvm-project] 44d23d: [DSE] Remove calls with known writes to dead memory

Philip Reames via All-commits all-commits at lists.llvm.org
Mon Dec 20 18:15:00 PST 2021

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 44d23d5345a6ed377c238ebd74f0c7a628e1c968
  Author: Philip Reames <listmail at philipreames.com>
  Date:   2021-12-20 (Mon, 20 Dec 2021)

  Changed paths:
    M llvm/lib/Analysis/MemoryLocation.cpp
    M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    M llvm/test/Transforms/DeadStoreElimination/trivial-dse-calls.ll

  Log Message:
  [DSE] Remove calls with known writes to dead memory

This is a reapply of a8a51fe5, which was reverted in 1ba99e due to a failing compiler-rt test.   That test was a false positive because it was checking asan failures not accounting for the fact the call could be validly optimized out.  I hopefully managed to stablize that test in 9b955f.  (That's a speculative fix due to disk consumption needed to build compiler-rt tests locally being absurd.)

Original commit message follows..

The majority of this change is sinking logic from instcombine into MemoryLocation such that it can be generically reused. If we have a call with a single analyzable write to an argument, we can treat that as-if it were a store of unknown size.

Merging the code in this was unblocks DSE in the store to dead memory code paths. In theory, it should also enable classic DSE of such calls, but the code appears to not know how to use object sizes to refine unknown access bounds (yet).

In addition, this does make the isAllocRemovable path slightly stronger by reusing the libfunc and additional intrinsics bits which are already in getForDest.

Differential Revision: https://reviews.llvm.org/D115904

More information about the All-commits mailing list