HomePhabricator

[DSE] Allow ptrs defined in the entry block in IsGuaranteedLoopInvariant.

Authored by fvrmatteo on Feb 23 2021, 2:22 AM.

Description

[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