This is an archive of the discontinued LLVM Phabricator instance.

[LoopSimplifyCFG] Delete landing pads in dead exit blocks
ClosedPublic

Authored by yrouban on Jul 22 2020, 6:36 AM.

Details

Summary

In addition to removing phi nodes this patch removes any landing pad the dead exit block might have.
Without this fix Verifier complains about a new switch instruction jumps to a block with a landing pad:

Block containing LandingPadInst must be jumped to only by the unwind edge of an invoke.
  %res = landingpad token
          cleanup
in function test_remove_lpad
LLVM ERROR: Broken function found, compilation aborted!

Regression tests provided.

Diff Detail

Event Timeline

yrouban created this revision.Jul 22 2020, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2020, 6:36 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
mkazantsev added inline comments.Jul 22 2020, 10:01 PM
llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
370

Why do we only delete phis and landingpad? If this block is proved dead, we can remove all its instructions and insert unreachable instead of its terminator.

yrouban marked an inline comment as done.Jul 24 2020, 9:35 AM
yrouban added inline comments.
llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
370

I think we do minimal changes for the sake of validity.

mkazantsev accepted this revision.Jul 28 2020, 5:09 AM

LGTM. Please add a TODO that the whole block can be collapsed.

This revision is now accepted and ready to land.Jul 28 2020, 5:09 AM
This revision was automatically updated to reflect the committed changes.