[llvm-branch-commits] [llvm-branch] r93218 - in /llvm/branches/Apple/Zoidberg: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Mon Jan 11 17:19:56 PST 2010


Author: stoklund
Date: Mon Jan 11 19:19:56 2010
New Revision: 93218

URL: http://llvm.org/viewvc/llvm-project?rev=93218&view=rev
Log:
Merge r93184 PHI arguments

Added:
    llvm/branches/Apple/Zoidberg/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll
      - copied unchanged from r93184, llvm/trunk/test/CodeGen/X86/2010-01-11-ExtraPHIArg.ll
Modified:
    llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=93218&r1=93217&r2=93218&view=diff

==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Jan 11 19:19:56 2010
@@ -1013,8 +1013,7 @@
       for (unsigned j = 0, ej = SDL->BitTestCases[i].Cases.size();
            j != ej; ++j) {
         MachineBasicBlock* cBB = SDL->BitTestCases[i].Cases[j].ThisBB;
-        if (cBB->succ_end() !=
-            std::find(cBB->succ_begin(),cBB->succ_end(), PHIBB)) {
+        if (cBB->isSuccessor(PHIBB)) {
           PHI->addOperand(MachineOperand::CreateReg(SDL->PHINodesToUpdate[pi].second,
                                                     false));
           PHI->addOperand(MachineOperand::CreateMBB(cBB));
@@ -1063,7 +1062,7 @@
           (MachineOperand::CreateMBB(SDL->JTCases[i].first.HeaderBB));
       }
       // JT BB. Just iterate over successors here
-      if (BB->succ_end() != std::find(BB->succ_begin(),BB->succ_end(), PHIBB)) {
+      if (BB->isSuccessor(PHIBB)) {
         PHI->addOperand
           (MachineOperand::CreateReg(SDL->PHINodesToUpdate[pi].second, false));
         PHI->addOperand(MachineOperand::CreateMBB(BB));
@@ -1109,17 +1108,23 @@
         SDL->EdgeMapping.find(BB);
       if (EI != SDL->EdgeMapping.end())
         ThisBB = EI->second;
-      for (MachineBasicBlock::iterator Phi = BB->begin();
-           Phi != BB->end() && Phi->getOpcode() == TargetInstrInfo::PHI; ++Phi){
-        // This value for this PHI node is recorded in PHINodesToUpdate, get it.
-        for (unsigned pn = 0; ; ++pn) {
-          assert(pn != SDL->PHINodesToUpdate.size() &&
-                 "Didn't find PHI entry!");
-          if (SDL->PHINodesToUpdate[pn].first == Phi) {
-            Phi->addOperand(MachineOperand::CreateReg(SDL->PHINodesToUpdate[pn].
-                                                      second, false));
-            Phi->addOperand(MachineOperand::CreateMBB(ThisBB));
-            break;
+
+      // BB may have been removed from the CFG if a branch was constant folded.
+      if (ThisBB->isSuccessor(BB)) {
+        for (MachineBasicBlock::iterator Phi = BB->begin();
+             Phi != BB->end() && Phi->getOpcode() == TargetInstrInfo::PHI;
+             ++Phi) {
+          // This value for this PHI node is recorded in PHINodesToUpdate.
+          for (unsigned pn = 0; ; ++pn) {
+            assert(pn != SDL->PHINodesToUpdate.size() &&
+                   "Didn't find PHI entry!");
+            if (SDL->PHINodesToUpdate[pn].first == Phi) {
+              Phi->addOperand(MachineOperand::
+                              CreateReg(SDL->PHINodesToUpdate[pn].second,
+                                        false));
+              Phi->addOperand(MachineOperand::CreateMBB(ThisBB));
+              break;
+            }
           }
         }
       }





More information about the llvm-branch-commits mailing list