From 984a7fc32ce2df9deb4bde8ddd086185b91bb358 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 5 Oct 2010 20:36:28 +0000 Subject: When we find a reaching definition, make sure it is visited from all paths by erasing it from the visited set. That ensures we create the right phi defs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115666 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SplitKit.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen') diff --git a/lib/CodeGen/SplitKit.cpp b/lib/CodeGen/SplitKit.cpp index 0621945..cce97fd 100644 --- a/lib/CodeGen/SplitKit.cpp +++ b/lib/CodeGen/SplitKit.cpp @@ -424,10 +424,14 @@ VNInfo *LiveIntervalMap::mapValue(const VNInfo *ParentVNI, SlotIndex Idx, // This may change during the DFS as we create new phi-defs. typedef DenseMap MBBValueMap; MBBValueMap DomValue; - - for (idf_iterator - IDFI = idf_begin(IdxMBB), - IDFE = idf_end(IdxMBB); IDFI != IDFE;) { + typedef SplitAnalysis::BlockPtrSet BlockPtrSet; + BlockPtrSet Visited; + + // Iterate over IdxMBB predecessors in a depth-first order. + // Skip begin() since that is always IdxMBB. + for (idf_ext_iterator + IDFI = llvm::next(idf_ext_begin(IdxMBB, Visited)), + IDFE = idf_ext_end(IdxMBB, Visited); IDFI != IDFE;) { MachineBasicBlock *MBB = *IDFI; SlotIndex End = lis_.getMBBEndIdx(MBB).getPrevSlot(); @@ -444,7 +448,10 @@ VNInfo *LiveIntervalMap::mapValue(const VNInfo *ParentVNI, SlotIndex Idx, continue; } - // Yes, VNI dominates MBB. Track the path back to IdxMBB, creating phi-defs + // Yes, VNI dominates MBB. Make sure we visit MBB again from other paths. + Visited.erase(MBB); + + // Track the path back to IdxMBB, creating phi-defs // as needed along the way. for (unsigned PI = IDFI.getPathLength()-1; PI != 0; --PI) { // Start from MBB's immediate successor. End at IdxMBB. -- cgit v1.1