[llvm-commits] [llvm] r89213 - in /llvm/trunk/lib/CodeGen: PHIElimination.cpp PHIElimination.h
Evan Cheng
evan.cheng at apple.com
Wed Nov 18 10:21:16 PST 2009
Thanks.
Evan
On Nov 18, 2009, at 10:01 AM, Jakob Stoklund Olesen wrote:
> Author: stoklund
> Date: Wed Nov 18 12:01:35 2009
> New Revision: 89213
>
> URL: http://llvm.org/viewvc/llvm-project?rev=89213&view=rev
> Log:
> Don't require LiveVariables for PHIElimination. Enable critical edge splitting
> when LiveVariables is available.
>
> The -split-phi-edges is now gone, and so is the hack to disable it when using
> the local register allocator. The PHIElimination pass no longer has
> LiveVariables as a prerequisite - that is what broke the local allocator.
> Instead we do critical edge splitting when possible - that is when
> LiveVariables is available.
>
> Modified:
> llvm/trunk/lib/CodeGen/PHIElimination.cpp
> llvm/trunk/lib/CodeGen/PHIElimination.h
>
> Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=89213&r1=89212&r2=89213&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original)
> +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Wed Nov 18 12:01:35 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/trunk/lib/CodeGen/PHIElimination.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=89213&r1=89212&r2=89213&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/PHIElimination.h (original)
> +++ llvm/trunk/lib/CodeGen/PHIElimination.h Wed Nov 18 12:01:35 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
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list