[llvm-commits] [llvm] r52475 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
Evan Cheng
evan.cheng at apple.com
Wed Jun 18 17:38:48 PDT 2008
On Jun 18, 2008, at 5:10 PM, Owen Anderson wrote:
> Author: resistor
> Date: Wed Jun 18 19:10:49 2008
> New Revision: 52475
>
> URL: http://llvm.org/viewvc/llvm-project?rev=52475&view=rev
> Log:
> Insert empty slots into the instruction numbering in live intervals,
> so that we can more easily
> add new instructions.
>
> Modified:
> llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
>
> Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=52475&r1=52474&r2=52475&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
> +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Jun 18
> 19:10:49 2008
> @@ -78,6 +78,7 @@
>
> void LiveIntervals::computeNumbering() {
> Index2MiMap OldI2MI = i2miMap_;
> + std::vector<IdxMBBPair> OldI2MBB = Idx2MBBMap;
>
> Idx2MBBMap.clear();
> MBB2IdxMap.clear();
> @@ -93,19 +94,22 @@
> MBB != E; ++MBB) {
> unsigned StartIdx = MIIndex;
>
> + // Insert an empty slot at the beginning of each block.
> + MIIndex += InstrSlots::NUM;
> + i2miMap_.push_back(0);
> +
> for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
> I != E; ++I) {
> bool inserted = mi2iMap_.insert(std::make_pair(I,
> MIIndex)).second;
> assert(inserted && "multiple MachineInstr -> index mappings");
> i2miMap_.push_back(I);
> MIIndex += InstrSlots::NUM;
> - }
> -
> - if (StartIdx == MIIndex) {
> - // Empty MBB
> +
> + // Insert an empty slot after every instruction.
> MIIndex += InstrSlots::NUM;
> i2miMap_.push_back(0);
> }
> +
> // Set the MBB2IdxMap entry for this MBB.
> MBB2IdxMap[MBB->getNumber()] = std::make_pair(StartIdx, MIIndex
> - 1);
> Idx2MBBMap.push_back(std::make_pair(StartIdx, MBB));
> @@ -113,90 +117,82 @@
> std::sort(Idx2MBBMap.begin(), Idx2MBBMap.end(), Idx2MBBCompare());
>
> if (!OldI2MI.empty())
> - for (iterator I = begin(), E = end(); I != E; ++I)
> - for (LiveInterval::iterator LI = I->second.begin(), LE = I-
> >second.end();
> - LI != LE; ++LI) {
> + for (iterator OI = begin(), OE = end(); OI != OE; ++OI)
> + for (LiveInterval::iterator LI = OI->second.begin(),
> + LE = OI->second.end(); LI != LE; ++LI) {
>
> // Remap the start index of the live range to the
> corresponding new
> // number, or our best guess at what it _should_ correspond
> to if the
> // original instruction has been erased. This is either the
> following
> // instruction or its predecessor.
> + unsigned index = LI->start / InstrSlots::NUM;
> unsigned offset = LI->start % InstrSlots::NUM;
> - if (OldI2MI[LI->start / InstrSlots::NUM])
> - LI->start = mi2iMap_[OldI2MI[LI->start /
> InstrSlots::NUM]] + offset;
> - else {
> - unsigned i = 0;
> - MachineInstr* newInstr = 0;
> - do {
> - newInstr = OldI2MI[LI->start / InstrSlots::NUM + i];
> - i++;
> - } while (!newInstr);
> + if (offset == InstrSlots::LOAD) {
> + std::vector<IdxMBBPair>::const_iterator I =
> + std::lower_bound(OldI2MBB.begin(),
> OldI2MBB.end(), index);
> + // Take the pair containing the index
> + std::vector<IdxMBBPair>::const_iterator J =
> + ((I != OldI2MBB.end() && I->first > index) ||
> + (I == OldI2MBB.end() && OldI2MBB.size()>0)) ?
> (I-1): I;
I have hard time following this. The code was so easy to understand
before! :-) Can you factor these 6-7 lines out and add a bit of
comments? I see it's used at at least two places.
Thanks.
Evan
>
>
>
> _______________________________________________
> 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