[llvm-commits] [llvm] r58726 - /llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
Evan Cheng
evan.cheng at apple.com
Tue Nov 4 17:05:32 PST 2008
Thanks. Please add comment to createsNewJoin. Also, the function name
sounds like it's creating a new join. How about SplitWillCreateNewJoin?
Evan
On Nov 4, 2008, at 2:22 PM, Owen Anderson wrote:
> Author: resistor
> Date: Tue Nov 4 16:22:41 2008
> New Revision: 58726
>
> URL: http://llvm.org/viewvc/llvm-project?rev=58726&view=rev
> Log:
> First pass at checking for the creation of a new join point when
> doing pre-alloc splitting. This is not turned on yet.
>
> Modified:
> llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
>
> Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=58726&r1=58725&r2=58726&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original)
> +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Tue Nov 4 16:22:41
> 2008
> @@ -17,6 +17,7 @@
> #define DEBUG_TYPE "pre-alloc-split"
> #include "llvm/CodeGen/LiveIntervalAnalysis.h"
> #include "llvm/CodeGen/LiveStackAnalysis.h"
> +#include "llvm/CodeGen/MachineDominators.h"
> #include "llvm/CodeGen/MachineFrameInfo.h"
> #include "llvm/CodeGen/MachineFunctionPass.h"
> #include "llvm/CodeGen/MachineLoopInfo.h"
> @@ -89,6 +90,10 @@
> AU.addPreservedID(StrongPHIEliminationID);
> else
> AU.addPreservedID(PHIEliminationID);
> + AU.addRequired<MachineDominatorTree>();
> + AU.addRequired<MachineLoopInfo>();
> + AU.addPreserved<MachineDominatorTree>();
> + AU.addPreserved<MachineLoopInfo>();
> MachineFunctionPass::getAnalysisUsage(AU);
> }
>
> @@ -145,6 +150,9 @@
> bool SplitRegLiveInterval(LiveInterval*);
>
> bool SplitRegLiveIntervals(const TargetRegisterClass **);
> +
> + bool createsNewJoin(LiveRange* LR, MachineBasicBlock* DefMBB,
> + MachineBasicBlock* BarrierMBB);
> };
> } // end anonymous namespace
>
> @@ -817,6 +825,71 @@
> return Change;
> }
>
> +bool PreAllocSplitting::createsNewJoin(LiveRange* LR,
> + MachineBasicBlock* DefMBB,
> + MachineBasicBlock*
> BarrierMBB) {
> + if (DefMBB == BarrierMBB)
> + return false;
> +
> + if (LR->valno->hasPHIKill)
> + return false;
> +
> + unsigned MBBEnd = LIs->getMBBEndIdx(BarrierMBB);
> + if (LR->end < MBBEnd)
> + return false;
> +
> + MachineLoopInfo& MLI = getAnalysis<MachineLoopInfo>();
> + if (MLI.getLoopFor(DefMBB) != MLI.getLoopFor(BarrierMBB))
> + return true;
> +
> + MachineDominatorTree& MDT = getAnalysis<MachineDominatorTree>();
> + SmallPtrSet<MachineBasicBlock*, 4> Visited;
> + typedef std::pair<MachineBasicBlock*,
> + MachineBasicBlock::succ_iterator> ItPair;
> + SmallVector<ItPair, 4> Stack;
> + Stack.push_back(std::make_pair(BarrierMBB, BarrierMBB-
> >succ_begin()));
> +
> + while (!Stack.empty()) {
> + ItPair P = Stack.back();
> + Stack.pop_back();
> +
> + MachineBasicBlock* PredMBB = P.first;
> + MachineBasicBlock::succ_iterator S = P.second;
> +
> + if (S == PredMBB->succ_end())
> + continue;
> + else if (Visited.count(*S)) {
> + Stack.push_back(std::make_pair(PredMBB, ++S));
> + continue;
> + } else
> + Stack.push_back(std::make_pair(PredMBB, ++S));
> +
> + MachineBasicBlock* MBB = *S;
> + Visited.insert(MBB);
> +
> + if (MBB == BarrierMBB)
> + return true;
> +
> + MachineDomTreeNode* DefMDTN = MDT.getNode(DefMBB);
> + MachineDomTreeNode* BarrierMDTN = MDT.getNode(BarrierMBB);
> + MachineDomTreeNode* MDTN = MDT.getNode(MBB)->getIDom();
> + while (MDTN) {
> + if (MDTN == DefMDTN)
> + return true;
> + else if (MDTN == BarrierMDTN)
> + break;
> + MDTN = MDTN->getIDom();
> + }
> +
> + MBBEnd = LIs->getMBBEndIdx(MBB);
> + if (LR->end > MBBEnd)
> + Stack.push_back(std::make_pair(MBB, MBB->succ_begin()));
> + }
> +
> + return false;
> +}
> +
> +
> bool PreAllocSplitting::runOnMachineFunction(MachineFunction &MF) {
> CurrMF = &MF;
> TM = &MF.getTarget();
>
>
> _______________________________________________
> 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