[llvm] r216365 - AArch64: use std::vector for temp array

David Blaikie dblaikie at gmail.com
Mon Aug 25 09:46:34 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:36 2014
> New Revision: 216365
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216365&view=rev
> Log:
> AArch64: use std::vector for temp array
>
> 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=216365&r1=216364&r2=216365&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp (original)
> +++ llvm/trunk/lib/Target/AArch64/AArch64CollectLOH.cpp Sun Aug 24 20:59:36 2014
> @@ -1071,7 +1071,8 @@ bool AArch64CollectLOH::runOnMachineFunc
>    bool Modified = false;
>
>    // Start with ADRP.
> -  InstrToInstrs *ColorOpToReachedUses = new InstrToInstrs[NbReg];
> +  std::vector<InstrToInstrs> COTRUVector(NbReg);

Another case of vector where your previous patches seem to be using
uinque_ptr<T[]>

> +  auto ColorOpToReachedUses = COTRUVector.data();

Haven't looked at all the uses, but wouldn't mind skipping the extra
variable & just using [] and .data() as needed.

>
>    // Compute the reaching def in ADRP mode, meaning ADRP definitions
>    // are first considered as uses.
> @@ -1086,10 +1087,9 @@ bool AArch64CollectLOH::runOnMachineFunc
>
>    // Compute LOH for ADRP.
>    computeADRP(ADRPToReachingDefs, *AArch64FI, MDT);
> -  delete[] ColorOpToReachedUses;
> -
>    // Continue with general ADRP -> ADD/LDR -> LDR/STR pattern.
> -  ColorOpToReachedUses = new InstrToInstrs[NbReg];
> +  COTRUVector.clear();
> +  COTRUVector.resize(NbReg);

This looks like it's just "zero out the range", right? (the old size
and the new size are the same) perhaps it would be easier to write it
that way instead: std::fill(blah.begin(), blah.end(), 0); or
blah.assign(NbReg, 0) maybe...

>
>    // first perform a regular reaching def analysis.
>    reachingDef(MF, ColorOpToReachedUses, RegToId, false, DummyOp);
> @@ -1103,7 +1103,6 @@ bool AArch64CollectLOH::runOnMachineFunc
>    // Compute other than AdrpAdrp LOH.
>    computeOthers(UsesToReachingDefs, ColorOpToReachedUses, *AArch64FI, RegToId,
>                  MDT);
> -  delete[] ColorOpToReachedUses;
>
>    if (BasicBlockScopeOnly)
>      MF.DeleteMachineInstr(DummyOp);
>
>
> _______________________________________________
> 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