[llvm-commits] [llvm] r62834 - /llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp

Evan Cheng evan.cheng at apple.com
Thu Jan 22 21:49:24 PST 2009


The code can really use some comments. :-)

Evan
On Jan 22, 2009, at 7:28 PM, Owen Anderson wrote:

> Author: resistor
> Date: Thu Jan 22 21:28:53 2009
> New Revision: 62834
>
> URL: http://llvm.org/viewvc/llvm-project?rev=62834&view=rev
> Log:
> Stage two of fixing pre-alloc-splitting's code size issues: filter  
> out restores that are just
> going to be re-spilled again.
>
> This also helps performance.  Pre-alloc-splitting now seems to be an  
> overall win on SPEC.
>
> 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=62834&r1=62833&r2=62834&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original)
> +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Thu Jan 22 21:28:53  
> 2009
> @@ -1388,7 +1388,7 @@
>
>   for (SmallPtrSet<LiveInterval*, 8>::iterator LI = split.begin(),
>        LE = split.end(); LI != LE; ++LI) {
> -    DenseMap<VNInfo*, unsigned > VNUseCount;
> +    DenseMap<VNInfo*, SmallPtrSet<MachineInstr*, 4> > VNUseCount;
>
>     for (MachineRegisterInfo::use_iterator UI = MRI->use_begin((*LI)- 
> >reg),
>          UE = MRI->use_end(); UI != UE; ++UI) {
> @@ -1396,27 +1396,55 @@
>       index = LiveIntervals::getUseIndex(index);
>
>       const LiveRange* LR = (*LI)->getLiveRangeContaining(index);
> -      VNUseCount[LR->valno]++;
> +      VNUseCount[LR->valno].insert(&*UI);
>     }
>
>     for (LiveInterval::vni_iterator VI = (*LI)->vni_begin(),
>          VE = (*LI)->vni_end(); VI != VE; ++VI) {
>       VNInfo* CurrVN = *VI;
>       if (CurrVN->hasPHIKill) continue;
> -      if (VNUseCount[CurrVN] > 0) continue;
>
>       unsigned DefIdx = CurrVN->def;
>       if (DefIdx == ~0U || DefIdx == ~1U) continue;
> -
> +
>       MachineInstr* DefMI = LIs->getInstructionFromIndex(DefIdx);
>       int FrameIndex;
>       if (!TII->isLoadFromStackSlot(DefMI, FrameIndex)) continue;
>
> -      LIs->RemoveMachineInstrFromMaps(DefMI);
> -      (*LI)->removeValNo(CurrVN);
> -      DefMI->eraseFromParent();
> -      NumDeadSpills++;
> -      changed = true;
> +      if (VNUseCount[CurrVN].size() == 0) {
> +        LIs->RemoveMachineInstrFromMaps(DefMI);
> +        (*LI)->removeValNo(CurrVN);
> +        DefMI->eraseFromParent();
> +        NumDeadSpills++;
> +        changed = true;
> +      } else {
> +        bool NonRestore = false;
> +        for (SmallPtrSet<MachineInstr*, 4>::iterator UI =
> +             VNUseCount[CurrVN].begin(), UE =  
> VNUseCount[CurrVN].end();
> +             UI != UI; ++UI) {
> +          int StoreFrameIndex;
> +          unsigned StoreVReg = TII->isStoreToStackSlot(*UI,  
> StoreFrameIndex);
> +          if (StoreVReg != (*LI)->reg || StoreFrameIndex !=  
> FrameIndex) {
> +            NonRestore = false;
> +            break;
> +          }
> +        }
> +
> +        if (NonRestore) continue;
> +
> +        for (SmallPtrSet<MachineInstr*, 4>::iterator UI =
> +             VNUseCount[CurrVN].begin(), UE =  
> VNUseCount[CurrVN].end();
> +             UI != UI; ++UI) {
> +          LIs->RemoveMachineInstrFromMaps(*UI);
> +          (*UI)->eraseFromParent();
> +        }
> +
> +        LIs->RemoveMachineInstrFromMaps(DefMI);
> +        (*LI)->removeValNo(CurrVN);
> +        DefMI->eraseFromParent();
> +        NumDeadSpills++;
> +        changed = true;
> +      }
>     }
>   }
>
>
>
> _______________________________________________
> 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