[llvm-branch-commits] [llvm-branch] r115883 - /llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp
Gabor Greif
ggreif at gmail.com
Wed Oct 6 17:41:24 PDT 2010
Author: ggreif
Date: Wed Oct 6 19:41:24 2010
New Revision: 115883
URL: http://llvm.org/viewvc/llvm-project?rev=115883&view=rev
Log:
checkpoint PHI updater (no workee)
Modified:
llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp
Modified: llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=115883&r1=115882&r2=115883&view=diff
==============================================================================
--- llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/branches/ggreif/switch-opts/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Oct 6 19:41:24 2010
@@ -895,6 +895,18 @@
OldBranch->replaceAllUsesWith(Old->getTerminator());
OldBranch->eraseFromParent();
+
+ BasicBlock *TrueBB = Old->getTerminator()->getSuccessor(0);
+ // Add incoming edges to PHIs where not yet present.
+ for (BasicBlock::use_iterator U = TrueBB->use_begin(),
+ E = TrueBB->use_end(); U != E; ++U)
+ if (PHINode *PHI = dyn_cast<PHINode>(*U)) {
+ int IDX = PHI->getBasicBlockIndex(New);
+ if (IDX >= 0
+ && PHI->getBasicBlockIndex(Old) < 0)
+ PHI->addIncoming(PHI->getIncomingValue(IDX), Old);
+ }
+
return New;
}
More information about the llvm-branch-commits
mailing list