[llvm-branch-commits] [llvm-branch] r89249 - in /llvm/branches/Apple/Leela/lib/CodeGen: PHIElimination.cpp PHIElimination.h

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Nov 18 13:52:41 PST 2009


Author: stoklund
Date: Wed Nov 18 15:52:41 2009
New Revision: 89249

URL: http://llvm.org/viewvc/llvm-project?rev=89249&view=rev
Log:
89213

Modified:
    llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp
    llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.h

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=89249&r1=89248&r2=89249&view=diff

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.cpp Wed Nov 18 15:52:41 2009
@@ -21,7 +21,6 @@
 #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"
@@ -37,37 +36,17 @@
 STATISTIC(NumAtomic, "Number of atomic phis lowered");
 STATISTIC(NumSplits, "Number of critical edges split on demand");
 
-static cl::opt<bool>
-SplitEdges("split-phi-edges",
-           cl::desc("Split critical edges during phi elimination"),
-           cl::init(false), cl::Hidden);
-
 char PHIElimination::ID = 0;
 static RegisterPass<PHIElimination>
 X("phi-node-elimination", "Eliminate PHI nodes for register allocation");
 
 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 (shouldSplitEdges()) {
-    AU.addRequired<LiveVariables>();
-  } else {
-    AU.setPreservesCFG();
-    AU.addPreservedID(MachineLoopInfoID);
-  }
+  // rdar://7401784 This would be nice:
+  // AU.addPreservedID(MachineLoopInfoID);
   MachineFunctionPass::getAnalysisUsage(AU);
 }
 
@@ -79,9 +58,9 @@
   bool Changed = false;
 
   // Split critical edges to help the coalescer
-  if (shouldSplitEdges())
+  if (LiveVariables *LV = getAnalysisIfAvailable<LiveVariables>())
     for (MachineFunction::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
-      Changed |= SplitPHIEdges(Fn, *I);
+      Changed |= SplitPHIEdges(Fn, *I, *LV);
 
   // Populate VRegPHIUseCount
   analyzePHINodes(Fn);
@@ -361,10 +340,11 @@
 }
 
 bool llvm::PHIElimination::SplitPHIEdges(MachineFunction &MF,
-                                         MachineBasicBlock &MBB) {
+                                         MachineBasicBlock &MBB,
+                                         LiveVariables &LV) {
   if (MBB.empty() || MBB.front().getOpcode() != TargetInstrInfo::PHI)
     return false;   // Quick exit for basic blocks without PHIs.
-  LiveVariables &LV = getAnalysis<LiveVariables>();
+
   for (MachineBasicBlock::const_iterator BBI = MBB.begin(), BBE = MBB.end();
        BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI) {
     for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2) {

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

==============================================================================
--- llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.h (original)
+++ llvm/branches/Apple/Leela/lib/CodeGen/PHIElimination.h Wed Nov 18 15:52:41 2009
@@ -90,7 +90,8 @@
     void analyzePHINodes(const MachineFunction& Fn);
 
     /// Split critical edges where necessary for good coalescer performance.
-    bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB);
+    bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB,
+                       LiveVariables &LV);
 
     /// isLiveOut - Determine if Reg is live out from MBB, when not
     /// considering PHI nodes. This means that Reg is either killed by





More information about the llvm-branch-commits mailing list