[llvm-commits] [llvm] r40916 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp

Reid Spencer rspencer at reidspencer.com
Tue Aug 7 21:18:18 PDT 2007


Evan,

On Wed, 2007-08-08 at 03:00 +0000, Evan Cheng wrote:
> Author: evancheng
> Date: Tue Aug  7 22:00:28 2007
> New Revision: 40916
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=40916&view=rev
> Log:
> - Each val# can have multiple kills.
> - Fix some minor bugs related to special markers on val# def. ~0U means
>   undefined, ~1U means dead val#.
> 
> Modified:
>     llvm/trunk/include/llvm/CodeGen/LiveInterval.h
>     llvm/trunk/lib/CodeGen/LiveInterval.cpp
>     llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
>     llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
> 
> Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=40916&r1=40915&r2=40916&view=diff
> 
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Aug  7 22:00:28 2007
> @@ -87,17 +87,14 @@
>      Ranges ranges;       // the ranges in which this register is live
>  
>      /// ValueNumberInfo - If the value number definition is undefined (e.g. phi
> -    /// merge point), it contains ~0,x,x. If the value number is not in use, it
> -    /// contains ~1,x,x to indicate that the value # is not used. The first
> -    /// entry is the instruction # of the definition, the second is the kill #.
> -    /// If the third value is non-zero, then the val# is defined by a copy and
> -    /// it represents the register number it is copied from.
> +    /// merge point), it contains ~0u,x. If the value number is not in use, it
> +    /// contains ~1u,x to indicate that the value # is not used. 
>      struct VNInfo {
> -      unsigned def;
> -      unsigned kill;
> -      unsigned reg;
> -      VNInfo() : def(~1U), kill(~0U), reg(0) {};
> -      VNInfo(unsigned d, unsigned k, unsigned r) : def(d), kill(k), reg(r) {};
> +      unsigned def;  // instruction # of the definition
> +      unsigned reg;  // src reg: non-zero iff val# is defined by a copy
> +      SmallVector<unsigned, 4> kills;  // instruction #s of the kills

Why loose the doxygen on these? The /// lines you removed were
previously included in the doxygen documentation, now they won't be.
Please use ///< to indicate a doxygen comment that applies to the
preceding field. You can do this for function parameters too.

Thanks,

Reid.

> +      VNInfo() : def(~1U), reg(0) {};
> +      VNInfo(unsigned d, unsigned r) : def(d), reg(r) {};
>      };
>    private:
>      SmallVector<VNInfo, 4> ValueNumberInfo;
> @@ -143,7 +140,7 @@
>      /// getNextValue - Create a new value number and return it.  MIIdx specifies
>      /// the instruction that defines the value number.
>      unsigned getNextValue(unsigned MIIdx, unsigned SrcReg) {
> -      ValueNumberInfo.push_back(VNInfo(MIIdx, ~0U, SrcReg));
> +      ValueNumberInfo.push_back(VNInfo(MIIdx, SrcReg));
>        return ValueNumberInfo.size()-1;
>      }
>      
> @@ -154,16 +151,22 @@
>        return ValueNumberInfo[ValNo].def;
>      }
>      
> -    /// getKillForValNum - Return the machine instruction index that kills the
> -    /// specified value number.
> -    unsigned getKillForValNum(unsigned ValNo) const {
> +    unsigned getSrcRegForValNum(unsigned ValNo) const {
>        //assert(ValNo < ValueNumberInfo.size());
> -      return ValueNumberInfo[ValNo].kill;
> +      return ValueNumberInfo[ValNo].reg;
>      }
>      
> -    unsigned getSrcRegForValNum(unsigned ValNo) const {
> +    /// getKillsForValNum - Return the kill instruction indexes of the specified
> +    /// value number.
> +    SmallVector<unsigned, 4> getKillsForValNum(unsigned ValNo) const {
>        //assert(ValNo < ValueNumberInfo.size());
> -      return ValueNumberInfo[ValNo].reg;
> +      return ValueNumberInfo[ValNo].kills;
> +    }
> +    
> +    /// addKillForValNum - Add a kill instruction index to the specified value
> +    /// number.
> +    void addKillForValNum(unsigned ValNo, unsigned KillIdx) {
> +      ValueNumberInfo[ValNo].kills.push_back(KillIdx);
>      }
>      
>      VNInfo getValNumInfo(unsigned ValNo) const {
> @@ -176,7 +179,7 @@
>      void setValueNumberInfo(unsigned ValNo, const VNInfo &I) {
>        ValueNumberInfo[ValNo] = I;
>      }
> -    
> +
>      /// MergeValueNumberInto - This method is called when two value nubmers
>      /// are found to be equivalent.  This eliminates V1, replacing all
>      /// LiveRanges with the V1 value number with the V2 value number.  This can
> 
> Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=40916&r1=40915&r2=40916&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original)
> +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Aug  7 22:00:28 2007
> @@ -300,7 +300,7 @@
>    // we want to avoid the interval scan if not.
>    bool MustMapCurValNos = false;
>    for (unsigned i = 0, e = getNumValNums(); i != e; ++i) {
> -    if (ValueNumberInfo[i].def == ~1U) continue;  // tombstone value #
> +    //if (ValueNumberInfo[i].def == ~1U) continue;  // tombstone value #
>      if (i != (unsigned)LHSValNoAssignments[i]) {
>        MustMapCurValNos = true;
>        break;
> @@ -508,14 +508,11 @@
>        OS << i << "@";
>        if (ValueNumberInfo[i].def == ~0U) {
>          OS << "?";
> +      } else if (ValueNumberInfo[i].def == ~1U) {
> +        OS << "x";
>        } else {
>          OS << ValueNumberInfo[i].def;
>        }
> -      if (ValueNumberInfo[i].kill == ~0U) {
> -        OS << ",?";
> -      } else {
> -        OS << "," << ValueNumberInfo[i].kill;
> -      }
>      }
>    }
>  }
> 
> Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=40916&r1=40915&r2=40916&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original)
> +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Aug  7 22:00:28 2007
> @@ -347,7 +347,6 @@
>  
>      // Get the Idx of the defining instructions.
>      unsigned defIndex = getDefIndex(MIIdx);
> -
>      unsigned ValNum;
>      unsigned SrcReg, DstReg;
>      if (!tii_->isMoveInstr(*mi, SrcReg, DstReg))
> @@ -378,6 +377,7 @@
>          LiveRange LR(defIndex, killIdx, ValNum);
>          interval.addRange(LR);
>          DOUT << " +" << LR << "\n";
> +        interval.addKillForValNum(ValNum, killIdx);
>          return;
>        }
>      }
> @@ -412,10 +412,11 @@
>      // block to the 'use' slot of the killing instruction.
>      for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
>        MachineInstr *Kill = vi.Kills[i];
> +      unsigned killIdx = getUseIndex(getInstructionIndex(Kill))+1;
>        LiveRange LR(getMBBStartIdx(Kill->getParent()),
> -                   getUseIndex(getInstructionIndex(Kill))+1,
> -                   ValNum);
> +                   killIdx, ValNum);
>        interval.addRange(LR);
> +      interval.addKillForValNum(ValNum, killIdx);
>        DOUT << " +" << LR;
>      }
>  
> @@ -450,7 +451,7 @@
>        interval.setValueNumberInfo(1, interval.getValNumInfo(0));
>        
>        // Value#0 is now defined by the 2-addr instruction.
> -      interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, ~0U, 0U));
> +      interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, 0U));
>        
>        // Add the new live interval which replaces the range for the input copy.
>        LiveRange LR(DefIndex, RedefIndex, ValNo);
> 
> Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=40916&r1=40915&r2=40916&view=diff
> 
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Aug  7 22:00:28 2007
> @@ -132,7 +132,7 @@
>    // We are about to delete CopyMI, so need to remove it as the 'instruction
>    // that defines this value #'. Update the the valnum with the new defining
>    // instruction #.
> -  IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, ~0U, 0));
> +  IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, 0));
>    
>    // Okay, we can merge them.  We need to insert a new liverange:
>    // [ValLR.end, BLR.begin) of either value number, then we merge the
> @@ -645,7 +645,7 @@
>            // Otherwise, use the specified value #.
>            LHSValNoAssignments[VN] = RHSValID;
>            if (VN != (unsigned)RHSValID)
> -            ValueNumberInfo[VN].def = ~1U;
> +            ValueNumberInfo[VN].def = RHSValNoInfo.def;
>            else
>              ValueNumberInfo[VN] = RHSValNoInfo;
>          }
> 
> 
> _______________________________________________
> 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