This is an archive of the discontinued LLVM Phabricator instance.

Sink: Handle instruction sink when a user is dead
ClosedPublic

Authored by cfang on Oct 9 2020, 3:38 PM.

Details

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. In addition, if findNearestCommonDominator fails somehow,
we bail out instruction sinking.

Diff Detail

Event Timeline

cfang created this revision.Oct 9 2020, 3:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 9 2020, 3:38 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
cfang requested review of this revision.Oct 9 2020, 3:38 PM
MaskRay added inline comments.Oct 9 2020, 3:40 PM
llvm/lib/Transforms/Scalar/Sink.cpp
150

After D88758, the return value cannot be nullptr.

cfang updated this revision to Diff 297349.Oct 9 2020, 3:49 PM

remove checking for findNearestCommonDominator failures.

cfang marked an inline comment as done.Oct 9 2020, 3:50 PM
cfang added inline comments.
llvm/lib/Transforms/Scalar/Sink.cpp
150

Done. Remove the checking.

MaskRay accepted this revision.Oct 9 2020, 3:57 PM

'unreachable' may be more appropriate than 'dead'.

Please mention that this fixes PR47415 ( https://bugs.llvm.org/show_bug.cgi?id=47415)

In addition, if findNearestCommonDominator fails somehow, we bail out instruction sinking.

This sentence should be deleted.

This revision is now accepted and ready to land.Oct 9 2020, 3:57 PM
This revision was automatically updated to reflect the committed changes.
cfang marked an inline comment as done.