Reverts wrong modification to MachineBlockPlacement & BranchFolding; uses a new strat...
[oota-llvm.git] / lib / CodeGen / BranchFolding.cpp
index 60803490a5de61001c9828d3b09e3945a5ffe99e..a56fec468cc94cd282e56543663cecaf565e41ad 100644 (file)
@@ -780,7 +780,7 @@ removeMMOsFromMemoryOperations(MachineBasicBlock::iterator MBBIStartPos,
     assert(MBBICommon->isIdenticalTo(&*MBBI) && "Expected matching MIIs!");
 
     if (MBBICommon->mayLoad() || MBBICommon->mayStore())
-      MBBICommon->setMemRefs(MBBI->mergeMemRefsWith(*MBBI));
+      MBBICommon->setMemRefs(MBBICommon->mergeMemRefsWith(*MBBI));
 
     ++MBBI;
     ++MBBICommon;
@@ -1116,6 +1116,12 @@ bool BranchFolder::OptimizeBranches(MachineFunction &MF) {
   for (MachineFunction::iterator I = std::next(MF.begin()), E = MF.end();
        I != E; ) {
     MachineBasicBlock *MBB = &*I++;
+    // XXX-disabled: Don't optimize blocks that contain intentionally added fake
+    // conditional branch.
+    if (!MBB->getCanEliminateMachineBB()) {
+      continue;
+    }
+
     MadeChange |= OptimizeBlock(MBB);
 
     // If it is dead, remove it.