[llvm-branch-commits] [llvm-branch] r89169 - in /llvm/branches/Apple/Leela: lib/CodeGen/PHIElimination.cpp test/CodeGen/X86/2008-04-15-LiveVariableBug.ll test/CodeGen/X86/stack-color-with-reg.ll

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Nov 17 16:23:27 PST 2009


Author: stoklund
Date: Tue Nov 17 18:23:27 2009
New Revision: 89169

URL: http://llvm.org/viewvc/llvm-project?rev=89169&view=rev
Log:
Merge 89125 89139 89142 89150

Modified:
    llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp
    llvm/branches/Apple/Leela/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll
    llvm/branches/Apple/Leela/test/CodeGen/X86/stack-color-with-reg.ll

Modified: llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp?rev=89169&r1=89168&r2=89169&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp Tue Nov 17 18:23:27 2009
@@ -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"
@@ -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);
 
@@ -433,9 +445,21 @@
 MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A,
                                                      MachineBasicBlock *B) {
   assert(A && B && "Missing MBB end point");
-  ++NumSplits;
 
   MachineFunction *MF = A->getParent();
+
+  // We may need to update A's terminator, but we can't do that if AnalyzeBranch
+  // fails.
+  if (A->isLayoutSuccessor(B)) {
+    const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
+    MachineBasicBlock *TBB = 0, *FBB = 0;
+    SmallVector<MachineOperand, 4> Cond;
+    if (!TII->AnalyzeBranch(*A, TBB, FBB, Cond))
+      return NULL;
+  }
+
+  ++NumSplits;
+
   MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock();
   MF->push_back(NMBB);
   const unsigned NewNum = NMBB->getNumber();

Modified: llvm/branches/Apple/Leela/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll?rev=89169&r1=89168&r2=89169&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll (original)
+++ llvm/branches/Apple/Leela/test/CodeGen/X86/2008-04-15-LiveVariableBug.ll Tue Nov 17 18:23:27 2009
@@ -1,5 +1,6 @@
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin -relocation-model=pic -disable-fp-elim -O0 -regalloc=local
+; PR5534
 
 	%struct.CGPoint = type { double, double }
 	%struct.NSArray = type { %struct.NSObject }

Modified: llvm/branches/Apple/Leela/test/CodeGen/X86/stack-color-with-reg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela/test/CodeGen/X86/stack-color-with-reg.ll?rev=89169&r1=89168&r2=89169&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/test/CodeGen/X86/stack-color-with-reg.ll (original)
+++ llvm/branches/Apple/Leela/test/CodeGen/X86/stack-color-with-reg.ll Tue Nov 17 18:23:27 2009
@@ -1,6 +1,5 @@
 ; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -relocation-model=pic -disable-fp-elim -color-ss-with-regs -stats -info-output-file - > %t
 ; RUN:   grep stackcoloring %t | grep "stack slot refs replaced with reg refs"  | grep 6
-; RUN:   grep asm-printer %t   | grep 177
 
 	type { [62 x %struct.Bitvec*] }		; type %0
 	type { i8* }		; type %1





More information about the llvm-branch-commits mailing list