This is an archive of the discontinued LLVM Phabricator instance.

[ConstantHoisting] Ignore unreachable bb:s when collecting candidates
ClosedPublic

Authored by bjope on Dec 18 2019, 1:51 PM.

Details

Summary

Ignore looking at blocks that are unreachable from entry when
collecting candidates for hosting.

Normally the consthoist pass is executed in the llc pipeline,
just after unreachableblockelim. So it is abnormal to have code
that is unreachable from the entry block. But when running the
pass as part of opt, for example as part of fuzzy testing, we
might trigger various kinds of asserts when collecting candidates
if we include unreachable blocks in that analysis.

Since it also just is a waste of time trying to hoist constants
in unreachble code, the simple solution is to simply ignore such
blocks when collecting the hoisting candidates.

The two added test cases used to end up in two different asserts,
and the intention with the checks is just to verify that we no
longer fail.

Fixes: PR43903

Diff Detail

Event Timeline

bjope created this revision.Dec 18 2019, 1:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 18 2019, 1:51 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
bjope marked an inline comment as done.Dec 18 2019, 3:05 PM
bjope added inline comments.
llvm/test/Transforms/ConstantHoisting/X86/pr43903-not-all-uses-rebased.ll
5

I'll remove the internal ticket number BBI-355111 before landing this.

spatel accepted this revision.Dec 19 2019, 5:18 AM

LGTM

llvm/test/Transforms/ConstantHoisting/X86/pr43903-not-all-uses-rebased.ll
3

Should this RUN line specify the x86 triple explicitly, or it doesn't matter? (not sure what will happen on bots that are non-x86)

This revision is now accepted and ready to land.Dec 19 2019, 5:18 AM
bjope marked an inline comment as done.Dec 19 2019, 5:50 AM
bjope added inline comments.
llvm/test/Transforms/ConstantHoisting/X86/pr43903-not-all-uses-rebased.ll
3

Ah thanks! I've missed to add the triple here. I'll fix that when landing this.

spatel added inline comments.Dec 19 2019, 6:09 AM
llvm/test/Transforms/ConstantHoisting/X86/pr43903-not-all-uses-rebased.ll
3

Actually after I posted the comment, I noticed that the triple is explicitly stated under here with "target triple".

So I don't think there's any problem, but it might be nicer to have it in the RUN line for consistency with the other test.

This revision was automatically updated to reflect the committed changes.