[BlockGenerator] Also eliminate dead code not originating from BB
authorTobias Grosser <tobias@grosser.es>
Tue, 9 Aug 2016 08:59:05 +0000 (08:59 +0000)
committerTobias Grosser <tobias@grosser.es>
Tue, 9 Aug 2016 08:59:05 +0000 (08:59 +0000)
commitc59b3ce044fc7d0b7d91497b60db26bc6877602c
treee0511d9c22bffaaff8e4c92359bd3d43d277b351
parentc99f72868d1ce70695e2e4b7212d2fcd51e734b6
[BlockGenerator] Also eliminate dead code not originating from BB

After having generated the code for a ScopStmt, we run a simple dead-code
elimination that drops all instructions that are known to be and remain unused.
Until this change, we only considered instructions for dead-code elimination, if
they have a corresponding instruction in the original BB that belongs to
ScopStmt. However, when generating code we do not only copy code from the BB
belonging to a ScopStmt, but also generate code for operands referenced from BB.
After this change, we now also considers code for dead code elimination, which
does not have a corresponding instruction in BB.

This fixes a bug in Polly-ACC where such dead-code referenced CPU code from
within a GPU kernel, which is possible as we do not guarantee that all variables
that are used in known-dead-code are moved to the GPU.

llvm-svn: 278103
polly/lib/CodeGen/BlockGenerators.cpp
polly/test/GPGPU/host-control-flow.ll
polly/test/GPGPU/remove-dead-instructions-in-stmt-2.ll [new file with mode: 0644]
polly/test/GPGPU/remove-dead-instructions-in-stmt.ll [new file with mode: 0644]
polly/test/ScopInfo/int2ptr_ptr2int_2.ll