--- include/llvm/Analysis/Dominators.h	27 Oct 2002 13:44:47 -0000	1.3
+++ include/llvm/Analysis/Dominators.h	27 Oct 2002 20:26:18 -0000	1.3.2.1
@@ -385,6 +385,24 @@
 
   // print - Convert to human readable form
   virtual void print(std::ostream &OS) const;
+
+  void addBasicBlock(BasicBlock *BB, const DomSetType &frontier) {
+    assert(find(BB) == end() && "Block already in DominanceFrontier!");
+    Frontiers.insert(std::make_pair(BB, frontier));
+  }
+
+  void addToFrontier(BasicBlock *BB, BasicBlock *Node) {
+    DomSetMapType::iterator I = Frontiers.find(BB);
+    assert(I != end() && "BB is not in DominanceFrontier!");
+    I->second.insert(Node);
+  }
+
+  void removeFromFrontier(BasicBlock *BB, BasicBlock *Node) {
+    DomSetMapType::iterator I = Frontiers.find(BB);
+    assert(I != end() && "BB is not in DominanceFrontier!");
+    assert(I->second.count(Node) && "Node is not in DominanceFrontier of BB");
+    I->second.erase(Node);
+  }
 };
 
 
--- lib/Transforms/Scalar/BreakCriticalEdges.cpp	27 Oct 2002 14:04:37 -0000	1.1
+++ lib/Transforms/Scalar/BreakCriticalEdges.cpp	27 Oct 2002 20:26:18 -0000	1.1.2.2
@@ -26,6 +26,7 @@
       AU.addPreserved<DominatorSet>();
       AU.addPreserved<ImmediateDominators>();
       AU.addPreserved<DominatorTree>();
+      AU.addPreserved<DominanceFrontier>();
       AU.addPreservedID(LoopPreheadersID);   // No preheaders deleted.
     }
   };
@@ -66,8 +67,14 @@
   BasicBlock *TIBB = TI->getParent();
 
   // Create a new basic block, linking it into the CFG.
-  BasicBlock *NewBB = new BasicBlock(TIBB->getName()+"_crit_edge");
   BasicBlock *DestBB = TI->getSuccessor(SuccNum);
+  std::string name = TIBB->getName();
+  if(DestBB->getName().empty())
+    name += "_crit_edge";
+  else
+    name += '.' + DestBB->getName();
+  BasicBlock *NewBB = new BasicBlock(name);
+
   // Create our unconditional branch...
   BranchInst *BI = new BranchInst(DestBB);
   NewBB->getInstList().push_back(BI);
@@ -120,6 +127,17 @@
     //
     if (TINode)        // Don't break unreachable code!
       DT->createNewNode(NewBB, TINode);
+  }
+
+
+  // Should we update DominanceFrontier information?
+  if (DominanceFrontier *DF = P->getAnalysisToUpdate<DominanceFrontier>()) {
+    // Since the new block is dominated by its only predecessor TIBB,
+    // it cannot be in any block's dominance frontier.  Its dominance
+    // frontier is {DestBB}.
+    DominanceFrontier::DomSetType dfset;
+    dfset.insert(DestBB);
+    DF->addBasicBlock(NewBB, dfset);
   }
 }
 
