This is an archive of the discontinued LLVM Phabricator instance.

[llvm][TailDuplicator] permit taildup'ing pred MBB containing INLINEASM_BR
AbandonedPublic

Authored by nickdesaulniers on Feb 2 2023, 2:57 PM.

Details

Summary

If we have:
bb0:

INLINEASM_BR ...
b bb2

bb1:

...

bb2:

ret

it would be nice to taildup that ret into bb0.

Diff Detail

Event Timeline

nickdesaulniers created this revision.Feb 2 2023, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 2:57 PM
nickdesaulniers requested review of this revision.Feb 2 2023, 2:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 2:57 PM
efriedma added inline comments.Feb 2 2023, 4:06 PM
llvm/lib/CodeGen/TailDuplicator.cpp
794

This doesn't seem right... the reasons we want to abort taildup are:

  • There's a conditional branch, and we can't branch in the middle of a block.
  • We can't merge two blocks that have different unwind destinations.
  • We don't want multiple INLINEASM_BRs in a basic block, I think?

Checking !PredBB->mayHaveInlineAsmBr() shortcuts all those potential reasons.


Might be worth considering implementing a form of taildup that doesn't merge the duplicated block with the predecessor; that would work in more cases without tripping over weird edge cases.

nickdesaulniers planned changes to this revision.Feb 6 2023, 9:46 AM
nickdesaulniers abandoned this revision.Mar 1 2023, 11:20 AM