Fixed some tests to avoid LiveIntervals::getInstructionFromIndex(..) overhead where...
authorLang Hames <lhames@gmail.com>
Sun, 26 Sep 2010 03:37:09 +0000 (03:37 +0000)
committerLang Hames <lhames@gmail.com>
Sun, 26 Sep 2010 03:37:09 +0000 (03:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114798 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/InlineSpiller.cpp
lib/CodeGen/PreAllocSplitting.cpp
lib/CodeGen/SimpleRegisterCoalescing.cpp

index 12f6d070aaa47c02b7ca42eebdaab14c195e335b..a79f7a892b115ab73d9e871fc5186094243f667a 100644 (file)
@@ -282,7 +282,7 @@ void InlineSpiller::reMaterializeAll() {
     lis_.RemoveMachineInstrFromMaps(DefMI);
     vrm_.RemoveMachineInstrFromMaps(DefMI);
     DefMI->eraseFromParent();
-    VNI->def = lis_.getZeroIndex();
+    VNI->def = SlotIndex();
     anyRemoved = true;
   }
 
index ee228a9f619bef96176a172586c54bf22424f0df..68d28e4f9717da4d629b804b399ac287c0c75e13 100644 (file)
@@ -807,8 +807,7 @@ bool PreAllocSplitting::Rematerialize(unsigned VReg, VNInfo* ValNo,
   MachineBasicBlock& MBB = *RestorePt->getParent();
   
   MachineBasicBlock::iterator KillPt = BarrierMBB->end();
-  if (LIs->getInstructionFromIndex(ValNo->def) == 0 ||
-      DefMI->getParent() == BarrierMBB)
+  if (!DefMI || DefMI->getParent() == BarrierMBB)
     KillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB);
   else
     KillPt = llvm::next(MachineBasicBlock::iterator(DefMI));
@@ -1005,7 +1004,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) {
   SlotIndex SpillIndex;
   MachineInstr *SpillMI = NULL;
   int SS = -1;
-  if (LIs->getInstructionFromIndex(ValNo->def) == 0) {
+  if (!DefMI) {
     // If we don't know where the def is we must split just before the barrier.
     if ((SpillMI = FoldSpill(LI->reg, RC, 0, Barrier,
                             BarrierMBB, SS, RefsInMBB))) {
index a839edd6f4bbfba232f9a9e8ca47a9aa4ea4bbd8..c111261acf471a098c884c8e323a930916da2ac0 100644 (file)
@@ -349,10 +349,9 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(const CoalescerPair &CP,
   VNInfo *AValNo = ALR->valno;
   // If other defs can reach uses of this def, then it's not safe to perform
   // the optimization.
-  MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def);
-  if (AValNo->isPHIDef() || DefMI == 0 || AValNo->isUnused() ||
-      AValNo->hasPHIKill())
+  if (AValNo->isPHIDef() || AValNo->isUnused() || AValNo->hasPHIKill())
     return false;
+  MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def);
   if (!DefMI)
     return false;
   const TargetInstrDesc &TID = DefMI->getDesc();
@@ -649,10 +648,11 @@ bool SimpleRegisterCoalescing::ReMaterializeTrivialDef(LiveInterval &SrcInt,
   VNInfo *ValNo = SrcLR->valno;
   // If other defs can reach uses of this def, then it's not safe to perform
   // the optimization.
-  if (ValNo->isPHIDef() || li_->getInstructionFromIndex(ValNo->def)==0 ||
-      ValNo->isUnused() || ValNo->hasPHIKill())
+  if (ValNo->isPHIDef() || ValNo->isUnused() || ValNo->hasPHIKill())
     return false;
   MachineInstr *DefMI = li_->getInstructionFromIndex(ValNo->def);
+  if (!DefMI)
+    return false;
   assert(DefMI && "Defining instruction disappeared");
   const TargetInstrDesc &TID = DefMI->getDesc();
   if (!TID.isAsCheapAsAMove())