[DSE] Bail out on MemoryPhis when deleting stores at end of function.
authorFlorian Hahn <flo@fhahn.com>
Sat, 12 Sep 2020 17:57:26 +0000 (18:57 +0100)
committerFlorian Hahn <flo@fhahn.com>
Sat, 12 Sep 2020 18:05:59 +0000 (19:05 +0100)
commite082dee2b5885bba65e20b22b088bcaca5546984
tree77428e88110bd9d6f0ea40626f199708794fef04
parent3de9e3e493baed93e1aa0e99b04a0b11f370a939
[DSE] Bail out on MemoryPhis when deleting stores at end of function.

When deleting stores at the end of a function, we have to do PHI
translation, otherwise we might miss reads in different iterations of a
loop. See multiblock-loop-carried-dependence.ll for details.

This fixes a mis-compile and surprisingly also increases the number of
eliminated stores from 26047 to 26572 for MultiSource/SPEC2000/SPEC2006
on X86 with -O3 -flto. This is most likely because we save budget by not
exploring through MemoryPhis, which are less likely to result in valid
candidates for elimination.

The issue was reported post-commit for fb109c42d91c.
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-loop-carried-dependence.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-malloc-free.ll
llvm/test/Transforms/DeadStoreElimination/MSSA/multiblock-memintrinsics.ll