Fix DSE miscompile when store is clobbered across loop iterations
authorArtur Pilipenko <apilipenko@azulsystems.com>
Fri, 21 Feb 2020 22:40:22 +0000 (14:40 -0800)
committerArtur Pilipenko <apilipenko@azulsystems.com>
Thu, 27 Feb 2020 22:43:01 +0000 (14:43 -0800)
commit02e3d5c3a25b9c00c0ab9bdd59931fde606ee0b4
tree01f62f23f481639b5ca7d896419ef923f069da42
parent4c2a6567bb12559cfc091bca2b25ae907cbd4e0f
Fix DSE miscompile when store is clobbered across loop iterations

DSE would mistakenly remove store (2):

  a = calloc(n+1)
  for (int i = 0; i < n; i++) {
    store 1, a[i+1] // (1)
    store 0, a[i]   // (2)
  }

The fix is to do PHI transaltion while looking for clobbering
instructions between the store and the calloc.

Reviewed By: efriedma, bjope

Differential Revision: https://reviews.llvm.org/D68006
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/simple.ll