@@ -1591,31 +1591,14 @@ static void insertTrivialPHIs(CHRScope *Scope,
1591
1591
}
1592
1592
TrivialPHIs.insert (PN);
1593
1593
CHR_DEBUG (dbgs () << " Insert phi " << *PN << " \n " );
1594
- bool FoundLifetimeAnnotation = false ;
1595
1594
for (Instruction *UI : Users) {
1596
- // If we found a lifetime annotation, remove it, but set a flag
1597
- // to ensure that we remove all other lifetime annotations attached
1598
- // to the alloca.
1599
- if (UI->isLifetimeStartOrEnd ()) {
1600
- UI->eraseFromParent ();
1601
- FoundLifetimeAnnotation = true ;
1602
- continue ;
1603
- }
1604
1595
for (unsigned J = 0 , NumOps = UI->getNumOperands (); J < NumOps; ++J) {
1605
1596
if (UI->getOperand (J) == &I) {
1606
1597
UI->setOperand (J, PN);
1607
1598
}
1608
1599
}
1609
1600
CHR_DEBUG (dbgs () << " Updated user " << *UI << " \n " );
1610
1601
}
1611
- // Erase any leftover lifetime annotations for a dynamic alloca.
1612
- if (FoundLifetimeAnnotation) {
1613
- for (User *U : make_early_inc_range (I.users ())) {
1614
- if (auto *UI = dyn_cast<Instruction>(U))
1615
- if (UI->isLifetimeStartOrEnd ())
1616
- UI->eraseFromParent ();
1617
- }
1618
- }
1619
1602
}
1620
1603
}
1621
1604
}
@@ -1710,12 +1693,14 @@ void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) {
1710
1693
BasicBlock *ExitBlock = LastRegion->getExit ();
1711
1694
std::optional<uint64_t > ProfileCount = BFI.getBlockProfileCount (EntryBlock);
1712
1695
1713
- SmallVector<AllocaInst *> StaticAllocas;
1714
- for (Instruction &I : *EntryBlock) {
1715
- if (auto *AI = dyn_cast<AllocaInst>(&I)) {
1716
- if (AI->isStaticAlloca ())
1717
- StaticAllocas.push_back (AI);
1718
- }
1696
+ if (ExitBlock) {
1697
+ // Insert a trivial phi at the exit block (where the CHR hot path and the
1698
+ // cold path merges) for a value that's defined in the scope but used
1699
+ // outside it (meaning it's alive at the exit block). We will add the
1700
+ // incoming values for the CHR cold paths to it below. Without this, we'd
1701
+ // miss updating phi's for such values unless there happens to already be a
1702
+ // phi for that value there.
1703
+ insertTrivialPHIs (Scope, EntryBlock, ExitBlock, TrivialPHIs);
1719
1704
}
1720
1705
1721
1706
// Split the entry block of the first region. The new block becomes the new
@@ -1734,20 +1719,6 @@ void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) {
1734
1719
FirstRegion->replaceEntryRecursive (NewEntryBlock);
1735
1720
BasicBlock *PreEntryBlock = EntryBlock;
1736
1721
1737
- // Move static allocas into the pre-entry block so they stay static.
1738
- for (AllocaInst *AI : StaticAllocas)
1739
- AI->moveBefore (EntryBlock->getTerminator ()->getIterator ());
1740
-
1741
- if (ExitBlock) {
1742
- // Insert a trivial phi at the exit block (where the CHR hot path and the
1743
- // cold path merges) for a value that's defined in the scope but used
1744
- // outside it (meaning it's alive at the exit block). We will add the
1745
- // incoming values for the CHR cold paths to it below. Without this, we'd
1746
- // miss updating phi's for such values unless there happens to already be a
1747
- // phi for that value there.
1748
- insertTrivialPHIs (Scope, EntryBlock, ExitBlock, TrivialPHIs);
1749
- }
1750
-
1751
1722
ValueToValueMapTy VMap;
1752
1723
// Clone the blocks in the scope (excluding the PreEntryBlock) to split into a
1753
1724
// hot path (originals) and a cold path (clones) and update the PHIs at the
0 commit comments