[cfe-commits] r133435 - /cfe/trunk/lib/CodeGen/CGCleanup.cpp

Jay Foad jay.foad at gmail.com
Mon Jun 20 07:38:01 PDT 2011


Author: foad
Date: Mon Jun 20 09:38:01 2011
New Revision: 133435

URL: http://llvm.org/viewvc/llvm-project?rev=133435&view=rev
Log:
Change how PHINodes store their operands.

Change PHINodes to store simple pointers to their incoming basic blocks,
instead of full-blown Uses.

Note that this loses an optimization in SplitCriticalEdge(), because we
can no longer walk the use list of a BasicBlock to find phi nodes. See
the comment I removed starting "However, the foreach loop is slow for
blocks with lots of predecessors".

Extend replaceAllUsesWith() on a BasicBlock to also update any phi
nodes in the block's successors. This mimics what would have happened
when PHINodes were proper Users of their incoming blocks. (Note that
this only works if OldBB->replaceAllUsesWith(NewBB) is called when
OldBB still has a terminator instruction, so it still has some
successors.)

Modified:
    cfe/trunk/lib/CodeGen/CGCleanup.cpp

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=133435&r1=133434&r2=133435&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Mon Jun 20 09:38:01 2011
@@ -420,13 +420,13 @@
   // Kill the branch.
   Br->eraseFromParent();
 
-  // Merge the blocks.
-  Pred->getInstList().splice(Pred->end(), Entry->getInstList());
-
   // Replace all uses of the entry with the predecessor, in case there
   // are phis in the cleanup.
   Entry->replaceAllUsesWith(Pred);
 
+  // Merge the blocks.
+  Pred->getInstList().splice(Pred->end(), Entry->getInstList());
+
   // Kill the entry block.
   Entry->eraseFromParent();
 





More information about the cfe-commits mailing list