mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
Fix for LoopInfo::updateUnloop. Remove subloop blocks from former
ancestor loops. I have a unit test that depends on scev-unroll, which unfortunately isn't checked in. But I will check it in when I can. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137341 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -411,6 +411,8 @@ public:
|
|||||||
|
|
||||||
void updateBlockParents();
|
void updateBlockParents();
|
||||||
|
|
||||||
|
void removeBlocksFromAncestors();
|
||||||
|
|
||||||
void updateSubloopParents();
|
void updateSubloopParents();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -467,6 +469,31 @@ void UnloopUpdater::updateBlockParents() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// removeBlocksFromAncestors - Remove unloop's blocks from all ancestors below
|
||||||
|
/// their new parents.
|
||||||
|
void UnloopUpdater::removeBlocksFromAncestors() {
|
||||||
|
// Remove unloop's blocks from all ancestors below their new parents.
|
||||||
|
for (Loop::block_iterator BI = Unloop->block_begin(),
|
||||||
|
BE = Unloop->block_end(); BI != BE; ++BI) {
|
||||||
|
Loop *NewParent = LI->getLoopFor(*BI);
|
||||||
|
// If this block is an immediate subloop, remove all blocks (including
|
||||||
|
// nested subloops) from ancestors below the new parent loop.
|
||||||
|
// Otherwise, if this block is in a nested subloop, skip it.
|
||||||
|
if (SubloopParents.count(NewParent))
|
||||||
|
NewParent = SubloopParents[NewParent];
|
||||||
|
else if (Unloop->contains(NewParent))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Remove blocks from former Ancestors except Unloop itself which will be
|
||||||
|
// deleted.
|
||||||
|
for (Loop *OldParent = Unloop->getParentLoop(); OldParent != NewParent;
|
||||||
|
OldParent = OldParent->getParentLoop()) {
|
||||||
|
assert(OldParent && "new loop is not an ancestor of the original");
|
||||||
|
OldParent->removeBlockFromLoop(*BI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// updateSubloopParents - Update the parent loop for all subloops directly
|
/// updateSubloopParents - Update the parent loop for all subloops directly
|
||||||
/// nested within unloop.
|
/// nested within unloop.
|
||||||
void UnloopUpdater::updateSubloopParents() {
|
void UnloopUpdater::updateSubloopParents() {
|
||||||
@ -605,22 +632,8 @@ void LoopInfo::updateUnloop(Loop *Unloop) {
|
|||||||
UnloopUpdater Updater(Unloop, this);
|
UnloopUpdater Updater(Unloop, this);
|
||||||
Updater.updateBlockParents();
|
Updater.updateBlockParents();
|
||||||
|
|
||||||
// Remove unloop's blocks from all ancestors below their new parents.
|
// Remove blocks from former ancestor loops.
|
||||||
for (Loop::block_iterator BI = Unloop->block_begin(),
|
Updater.removeBlocksFromAncestors();
|
||||||
BE = Unloop->block_end(); BI != BE; ++BI) {
|
|
||||||
Loop *NewParent = getLoopFor(*BI);
|
|
||||||
// If this block is in a subloop, skip it.
|
|
||||||
if (Unloop->contains(NewParent))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Remove blocks from former Ancestors except Unloop itself which will be
|
|
||||||
// deleted.
|
|
||||||
for (Loop *OldParent = Unloop->getParentLoop(); OldParent != NewParent;
|
|
||||||
OldParent = OldParent->getParentLoop()) {
|
|
||||||
assert(OldParent && "new loop is not an ancestor of the original");
|
|
||||||
OldParent->removeBlockFromLoop(*BI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add direct subloops as children in their new parent loop.
|
// Add direct subloops as children in their new parent loop.
|
||||||
Updater.updateSubloopParents();
|
Updater.updateSubloopParents();
|
||||||
|
Reference in New Issue
Block a user