[llvm] r216367 - CodeGen/LiveVariables: switch to std::vector

David Blaikie dblaikie at gmail.com
Mon Aug 25 09:50:52 PDT 2014


On Sun, Aug 24, 2014 at 6:59 PM, Dylan Noblesmith <nobled at dreamwidth.org> wrote:
> Author: nobled
> Date: Sun Aug 24 20:59:42 2014
> New Revision: 216367
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216367&view=rev
> Log:
> CodeGen/LiveVariables: switch to std::vector
>
> No functionality change.
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/LiveVariables.h
>     llvm/trunk/lib/CodeGen/LiveVariables.cpp
>
> Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=216367&r1=216366&r2=216367&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Sun Aug 24 20:59:42 2014
> @@ -134,14 +134,14 @@ private:   // Intermediate data structur
>    // PhysRegInfo - Keep track of which instruction was the last def of a
>    // physical register. This is a purely local property, because all physical
>    // register references are presumed dead across basic blocks.
> -  MachineInstr **PhysRegDef;
> +  std::vector<MachineInstr *> PhysRegDef;
>
>    // PhysRegInfo - Keep track of which instruction was the last use of a
>    // physical register. This is a purely local property, because all physical
>    // register references are presumed dead across basic blocks.
> -  MachineInstr **PhysRegUse;
> +  std::vector<MachineInstr *> PhysRegUse;
>
> -  SmallVector<unsigned, 4> *PHIVarInfo;
> +  std::vector<SmallVector<unsigned, 4>> PHIVarInfo;
>
>    // DistanceMap - Keep track the distance of a MI from the start of the
>    // current basic block.
>
> Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=216367&r1=216366&r2=216367&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original)
> +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Sun Aug 24 20:59:42 2014
> @@ -502,12 +502,12 @@ bool LiveVariables::runOnMachineFunction
>    MRI = &mf.getRegInfo();
>    TRI = MF->getSubtarget().getRegisterInfo();
>
> -  unsigned NumRegs = TRI->getNumRegs();
> -  PhysRegDef  = new MachineInstr*[NumRegs];
> -  PhysRegUse  = new MachineInstr*[NumRegs];
> -  PHIVarInfo = new SmallVector<unsigned, 4>[MF->getNumBlockIDs()];
> -  std::fill(PhysRegDef,  PhysRegDef  + NumRegs, nullptr);
> -  std::fill(PhysRegUse,  PhysRegUse  + NumRegs, nullptr);
> +  const unsigned NumRegs = TRI->getNumRegs();
> +  PhysRegDef.clear();
> +  PhysRegUse.clear();
> +  PhysRegDef.resize(NumRegs, nullptr);
> +  PhysRegUse.resize(NumRegs, nullptr);
> +  PHIVarInfo.resize(MF->getNumBlockIDs());

clear + resize -> assign, I think.

>    PHIJoins.clear();
>
>    // FIXME: LiveIntervals will be updated to remove its dependence on
> @@ -637,8 +637,10 @@ bool LiveVariables::runOnMachineFunction
>        if ((PhysRegDef[i] || PhysRegUse[i]) && !LiveOuts.count(i))
>          HandlePhysRegDef(i, nullptr, Defs);
>
> -    std::fill(PhysRegDef,  PhysRegDef  + NumRegs, nullptr);
> -    std::fill(PhysRegUse,  PhysRegUse  + NumRegs, nullptr);
> +    PhysRegDef.clear();
> +    PhysRegUse.clear();
> +    PhysRegDef.resize(NumRegs, nullptr);
> +    PhysRegUse.resize(NumRegs, nullptr);

 & here.

>    }
>
>    // Convert and transfer the dead / killed information we have gathered into
> @@ -660,9 +662,9 @@ bool LiveVariables::runOnMachineFunction
>      assert(Visited.count(&*i) != 0 && "unreachable basic block found");
>  #endif
>
> -  delete[] PhysRegDef;
> -  delete[] PhysRegUse;
> -  delete[] PHIVarInfo;
> +  PhysRegDef.clear();
> +  PhysRegUse.clear();
> +  PHIVarInfo.clear();
>
>    return false;
>  }
>
>
> _______________________________________________
> 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