On 16 June 2011 12:09, Jay Foad <[email protected]> wrote:
> 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.)
>
> This has only been split out from the previous patch for ease of review.
> They will be committed together to keep things bisectable.
> ---
>  include/llvm/BasicBlock.h                |    4 ++++
>  lib/Transforms/Scalar/LoopUnswitch.cpp   |    8 ++++----
>  lib/Transforms/Utils/BasicBlockUtils.cpp |    6 +++---
>  lib/Transforms/Utils/CloneFunction.cpp   |    6 +++---
>  lib/Transforms/Utils/InlineFunction.cpp  |   10 +++++-----
>  lib/Transforms/Utils/Local.cpp           |    8 ++++----
>  lib/Transforms/Utils/LoopUnroll.cpp      |    6 +++---
>  lib/VMCore/BasicBlock.cpp                |   16 ++++++++++++++++
>  lib/VMCore/Value.cpp                     |    3 +++
>  9 files changed, 45 insertions(+), 22 deletions(-)

I forgot that this part also requires a small change in Clang, attached.

Jay.
diff --git a/lib/CodeGen/CGCleanup.cpp b/lib/CodeGen/CGCleanup.cpp
index 41ecd81..97129f3 100644
--- a/lib/CodeGen/CGCleanup.cpp
+++ b/lib/CodeGen/CGCleanup.cpp
@@ -421,13 +421,13 @@ static llvm::BasicBlock *SimplifyCleanupEntry(CodeGenFunction &CGF,
   // 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();
 
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to