This is an archive of the discontinued LLVM Phabricator instance.

[Loop Simplify] Resolve an issue where metadata is not applied to a loop latch.
ClosedPublic

Authored by sidbav on Jul 15 2020, 6:51 AM.

Details

Summary

The function SplitBlockPredecessors adds a new block in a loop, and in the case that the block passed into this function is the header of the loop, the loop can be modified such that the latch of the loop is replaced. In this situation, the metadata from the old latch needs to added to the new latch, and removed from the old one.

This applies to the Loop Simplify pass since it ensures that each loop has exit blocks which only have predecessors that are inside of the loop. In the case that this is not true, the pass will create a new exit block for the loop. This guarantees that the loop preheader/header will dominate the exit blocks.

Diff Detail

Event Timeline

sidbav created this revision.Jul 15 2020, 6:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 15 2020, 6:51 AM
bmahjour added inline comments.Jul 15 2020, 7:57 AM
llvm/test/Transforms/LoopSimplify/update_latch_md.ll
17

The function and label names should be renamed to make the test more readable.

sidbav updated this revision to Diff 278208.Jul 15 2020, 8:48 AM

Address Bardia's comments

sidbav marked an inline comment as done.Jul 15 2020, 8:49 AM
asbirlea accepted this revision.Jul 15 2020, 11:30 AM

Thank you.

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
811

nit: it's enough to check if (OldLatch).

This revision is now accepted and ready to land.Jul 15 2020, 11:30 AM
sidbav updated this revision to Diff 278487.Jul 16 2020, 8:19 AM

Address review comments

sidbav marked an inline comment as done.Jul 16 2020, 8:19 AM
This revision was automatically updated to reflect the committed changes.