This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyCFG] Use applyUpdatesPermissive in HoistThenElseCodeToIf.
AbandonedPublic

Authored by fhahn on Apr 26 2021, 5:37 AM.

Details

Summary

The updates can in theory contain duplicates if the branch has the same
true and false successors. This is not really an issue when used in
SimplifyCFG, because such branches are simplified first. But it could
happen if it is used as a utility.

Diff Detail

Event Timeline

fhahn created this revision.Apr 26 2021, 5:37 AM
fhahn requested review of this revision.Apr 26 2021, 5:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2021, 5:37 AM

Please give me the testcase.

Please give me the testcase.

I don't think it's possible to have a test case that's just using SimplifyCFG, because the branch would be simplified first. But there should be a crashing one in llvm/test/Transforms/LoopVectorize/AArch64/prepare-hoist-sink.ll from D101290

How about this then?

llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1620–1622
1626
fhahn updated this revision to Diff 340556.Apr 26 2021, 9:21 AM

Avoid using applyUpdatesPermissive, by directly handling the case with duplicated successors.

fhahn marked 2 inline comments as done.Apr 26 2021, 9:22 AM
fhahn added inline comments.
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1620–1622

Done! I think we also need handling for the Insert part, because BB1 could also have duplicated successors.

lebedev.ri accepted this revision.Apr 26 2021, 12:58 PM

LG with nits, thanks.

llvm/lib/Transforms/Utils/SimplifyCFG.cpp
1613

You don't need this to be a vector.

1620–1622

Hmm. Only if you can add a test that will crash otherwise :)

1622–1623
This revision is now accepted and ready to land.Apr 26 2021, 12:58 PM
fhahn marked an inline comment as done.Jun 24 2021, 7:32 AM

@lebedev.ri should we push this, even though we did not go with D101290 ?

Uh, i think i going to go with: we need a test first.

fhahn abandoned this revision.Sep 12 2021, 11:52 AM

There are no plans to use this as utility which could trigger the crash mentioned above. Abandoning for now.