@@ -1591,31 +1591,14 @@ static void insertTrivialPHIs(CHRScope *Scope,
15911591 }
15921592 TrivialPHIs.insert (PN);
15931593 CHR_DEBUG (dbgs () << " Insert phi " << *PN << " \n " );
1594- bool FoundLifetimeAnnotation = false ;
15951594 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- }
16041595 for (unsigned J = 0 , NumOps = UI->getNumOperands (); J < NumOps; ++J) {
16051596 if (UI->getOperand (J) == &I) {
16061597 UI->setOperand (J, PN);
16071598 }
16081599 }
16091600 CHR_DEBUG (dbgs () << " Updated user " << *UI << " \n " );
16101601 }
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- }
16191602 }
16201603 }
16211604 }
@@ -1710,12 +1693,14 @@ void CHR::transformScopes(CHRScope *Scope, DenseSet<PHINode *> &TrivialPHIs) {
17101693 BasicBlock *ExitBlock = LastRegion->getExit ();
17111694 std::optional<uint64_t > ProfileCount = BFI.getBlockProfileCount (EntryBlock);
17121695
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);
17191704 }
17201705
17211706 // 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) {
17341719 FirstRegion->replaceEntryRecursive (NewEntryBlock);
17351720 BasicBlock *PreEntryBlock = EntryBlock;
17361721
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-
17511722 ValueToValueMapTy VMap;
17521723 // Clone the blocks in the scope (excluding the PreEntryBlock) to split into a
17531724 // hot path (originals) and a cold path (clones) and update the PHIs at the
0 commit comments