From: Dylan Noblesmith Date: Mon, 25 Aug 2014 01:59:38 +0000 (+0000) Subject: AArch64: unique_ptr-ify map structures X-Git-Tag: android-x86-7.1-r4~58174 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=2c6a26dc68d5f4dc5f8d0c054494e4228ff195d9;p=android-x86%2Fexternal-llvm.git AArch64: unique_ptr-ify map structures git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216366 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AArch64/AArch64CollectLOH.cpp b/lib/Target/AArch64/AArch64CollectLOH.cpp index 38dbeb95927..bb57d76a8cd 100644 --- a/lib/Target/AArch64/AArch64CollectLOH.cpp +++ b/lib/Target/AArch64/AArch64CollectLOH.cpp @@ -195,12 +195,14 @@ typedef SetVector SetOfMachineInstr; /// 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 +typedef MapVector> 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 +typedef MapVector> 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(BlockToSetOfInstrsPerColor &sets, 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(nbRegs)).get(); return result[reg]; } @@ -289,9 +291,9 @@ static void initReachingDef(MachineFunction &MF, 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(NbReg); + memset(BBGen.get(), 0, sizeof(const MachineInstr *) * NbReg); BitVector &BBKillSet = Kill[&MBB]; BBKillSet.resize(NbReg); @@ -422,22 +424,6 @@ static void reachingDefAlgorithm(MachineFunction &MF, } 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 &MF, if (!DummyOp) reachingDefAlgorithm(MF, ColorOpToReachedUses, In, Out, Gen, Kill, ReachableUses, RegToId.size()); - - // finit. - finitReachingDef(In, Out, Gen, ReachableUses); } #ifndef NDEBUG