Sink: Handle instruction sink when a user is dead
authorChangpeng Fang <Changpeng.Fang@amd.com>
Fri, 9 Oct 2020 23:20:26 +0000 (16:20 -0700)
committerChangpeng Fang <Changpeng.Fang@amd.com>
Fri, 9 Oct 2020 23:20:26 +0000 (16:20 -0700)
commitf192a27ed3bacdf727f27857adeb6d3762383295
tree4d487ffd0a4223b826b700da6f4aa74cdc699e71
parente0b89df2e0f0130881bf6c39bf31d7f6aac00e0f
Sink: Handle instruction sink when a user is dead

Summary:
  The current instruction sink pass uses findNearestCommonDominator of all users to find block to sink the instruction to.
However, a user may be in a dead block, which will result in unexpected behavior.

This patch handles such cases by skipping dead blocks. This patch fixes:
https://bugs.llvm.org/show_bug.cgi?id=47415

Reviewers:
  MaskRay, arsenm

Differential Revision:
  https://reviews.llvm.org/D89166
llvm/lib/Transforms/Scalar/Sink.cpp
llvm/test/Transforms/Sink/dead-user.ll [new file with mode: 0644]