[llvm] r216366 - AArch64: unique_ptr-ify map structures
David Blaikie
dblaikie at gmail.com
Mon Aug 25 09:49:33 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:38 2014
> New Revision: 216366
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216366&view=rev
> Log:
> AArch64: unique_ptr-ify map structures
>
> Modified:
> llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp
>
> Modified: llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp?rev=216366&r1=216365&r2=216366&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp Sun Aug 24 20:59:38 2014
> @@ -195,12 +195,14 @@ typedef SetVector<const MachineInstr *>
> /// Map a basic block to a set of instructions per register.
> /// This is used to represent the exposed uses of a basic block
> /// per register.
> -typedef MapVector<const MachineBasicBlock *, SetOfMachineInstr *>
> +typedef MapVector<const MachineBasicBlock *,
> + std::unique_ptr<SetOfMachineInstr[]>>
> BlockToSetOfInstrsPerColor;
> /// Map a basic block to an instruction per register.
> /// This is used to represent the live-out definitions of a basic block
> /// per register.
> -typedef MapVector<const MachineBasicBlock *, const MachineInstr **>
> +typedef MapVector<const MachineBasicBlock *,
> + std::unique_ptr<const MachineInstr *[]>>
> BlockToInstrPerColor;
> /// Map an instruction to a set of instructions. Used to represent the
> /// mapping def to reachable uses or use to definitions.
> @@ -237,9 +239,9 @@ static SetOfMachineInstr &getSet(BlockTo
> SetOfMachineInstr *result;
> BlockToSetOfInstrsPerColor::iterator it = sets.find(&MBB);
> if (it != sets.end())
> - result = it->second;
> + result = it->second.get();
> else
> - result = sets[&MBB] = new SetOfMachineInstr[nbRegs];
> + result = (sets[&MBB] = make_unique<SetOfMachineInstr[]>(nbRegs)).get();
>
> return result[reg];
> }
> @@ -289,9 +291,9 @@ static void initReachingDef(MachineFunct
> unsigned NbReg = RegToId.size();
>
> for (MachineBasicBlock &MBB : MF) {
> - const MachineInstr **&BBGen = Gen[&MBB];
> - BBGen = new const MachineInstr *[NbReg];
> - memset(BBGen, 0, sizeof(const MachineInstr *) * NbReg);
> + auto &BBGen = Gen[&MBB];
> + BBGen = make_unique<const MachineInstr *[]>(NbReg);
> + memset(BBGen.get(), 0, sizeof(const MachineInstr *) * NbReg);
Might be nice to switch this to std::fill or something similarly type safe.
>
> BitVector &BBKillSet = Kill[&MBB];
> BBKillSet.resize(NbReg);
> @@ -422,22 +424,6 @@ static void reachingDefAlgorithm(Machine
> } while (HasChanged);
> }
>
> -/// Release all memory dynamically allocated during the reaching
> -/// definition algorithm.
> -static void finitReachingDef(BlockToSetOfInstrsPerColor &In,
> - BlockToSetOfInstrsPerColor &Out,
> - BlockToInstrPerColor &Gen,
> - BlockToSetOfInstrsPerColor &ReachableUses) {
> - for (auto &IT : Out)
> - delete[] IT.second;
> - for (auto &IT : In)
> - delete[] IT.second;
> - for (auto &IT : ReachableUses)
> - delete[] IT.second;
> - for (auto &IT : Gen)
> - delete[] IT.second;
> -}
> -
> /// Reaching definition algorithm.
> /// \param MF function on which the algorithm will operate.
> /// \param[out] ColorOpToReachedUses will contain the result of the reaching
> @@ -474,9 +460,6 @@ static void reachingDef(MachineFunction
> if (!DummyOp)
> reachingDefAlgorithm(MF, ColorOpToReachedUses, In, Out, Gen, Kill,
> ReachableUses, RegToId.size());
> -
> - // finit.
> - finitReachingDef(In, Out, Gen, ReachableUses);
> }
>
> #ifndef NDEBUG
>
>
> _______________________________________________
> 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