[DSE] Allow ptrs defined in the entry block in IsGuaranteedLoopInvariant.
authorMatteo Favaro <fvrmatteo@gmail.com>
Tue, 23 Feb 2021 10:22:53 +0000 (10:22 +0000)
committerFlorian Hahn <flo@fhahn.com>
Tue, 23 Feb 2021 12:00:44 +0000 (12:00 +0000)
commit633e090528dbc9b6dd380771046af8463bbb5fe1
treed12a447c28820b5c1f432e20d54affc75ba2f015
parent53c4c2b9f7328a8b80ecfd1fc60387d0f910cc2f
[DSE] Allow ptrs defined in the entry block in IsGuaranteedLoopInvariant.

The **IsGuaranteedLoopInvariant** function is making sure to check if the
incoming pointer is guaranteed to be loop invariant, therefore I think
the case where the pointer is defined in the entry block of a function
automatically guarantees the pointer to be loop invariant, as the entry
block of a function cannot have predecessors or be part of a loop.

I implemented this small patch and tested it using
**ninja check-llvm-unit** and **ninja check-llvm**. I added a contained test
file that shows the problem and used **opt -O3 -debug** on it to make sure
the case is not currently handled (in fact the debug log is showing that
the DSE pass is bailing out when testing if the killer store is able to
clobber the dead store).

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D96979
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
llvm/test/Transforms/DeadStoreElimination/MSSA/loop-invariant-entry-block.ll [new file with mode: 0644]