This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fix Arm block placement creating branches after jump tables.
ClosedPublic

Authored by dmgreen on Sep 24 2021, 10:46 AM.

Details

Summary

Given:

  • A jump table
  • Which jumps to the next block
  • The next block ends in a WLS
  • Where the WLS conditionally jumps to block earlier in the program.

The Arm block placement pass would attempt to move the block containing the WLS earlier, as the WLS instruction can only branch forward. In doing so it would add a branch from the jumptable block to the WLS block, thinking it previously fell-through. This in itself would be fine, if a little inefficient, but the constant island pass expects all instructions after a jump-table branch to have been removed by analyzeBranch. So it gets confused and can assign the same labels to multiple jump table blocks.

I've changed the condition to the same as used in analyzeBranch.

Diff Detail

Event Timeline

dmgreen created this revision.Sep 24 2021, 10:46 AM
dmgreen requested review of this revision.Sep 24 2021, 10:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 24 2021, 10:46 AM
lenary accepted this revision.Sep 24 2021, 11:58 AM
This revision is now accepted and ready to land.Sep 24 2021, 11:58 AM
chill accepted this revision.Sep 24 2021, 12:12 PM

LGTM. While I don't seem to grok how the duplicate labels happen, the change in isolation looks obviously correct.

Thanks. Committed in rG883758ed4800.

dmgreen closed this revision.Sep 27 2021, 7:02 AM