Enable -split-phi-edges by default, except when -regalloc=local.

The local register allocator doesn't like it when LiveVariables is run.
We should also disable edge splitting under -O0, but that has to wait a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89125 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp
index c4f2cc7..fc65742 100644
--- a/lib/CodeGen/PHIElimination.cpp
+++ b/lib/CodeGen/PHIElimination.cpp
@@ -21,6 +21,7 @@
 #include "llvm/CodeGen/MachineInstr.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/RegAllocRegistry.h"
 #include "llvm/Function.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/ADT/SmallPtrSet.h"
@@ -39,7 +40,7 @@
 static cl::opt<bool>
 SplitEdges("split-phi-edges",
            cl::desc("Split critical edges during phi elimination"),
-           cl::init(false), cl::Hidden);
+           cl::init(true), cl::Hidden);
 
 char PHIElimination::ID = 0;
 static RegisterPass<PHIElimination>
@@ -47,10 +48,21 @@
 
 const PassInfo *const llvm::PHIEliminationID = &X;
 
+namespace llvm { FunctionPass *createLocalRegisterAllocator(); }
+
+// Should we run edge splitting?
+static bool shouldSplitEdges() {
+  // Edge splitting breaks the local register allocator. It cannot tolerate
+  // LiveVariables being run.
+  if (RegisterRegAlloc::getDefault() == createLocalRegisterAllocator)
+    return false;
+  return SplitEdges;
+}
+
 void llvm::PHIElimination::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addPreserved<LiveVariables>();
   AU.addPreserved<MachineDominatorTree>();
-  if (SplitEdges) {
+  if (shouldSplitEdges()) {
     AU.addRequired<LiveVariables>();
   } else {
     AU.setPreservesCFG();
@@ -67,7 +79,7 @@
   bool Changed = false;
 
   // Split critical edges to help the coalescer
-  if (SplitEdges)
+  if (shouldSplitEdges())
     for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
       Changed |= SplitPHIEdges(Fn, *I);