[llvm] r216357 - Analysis: unique_ptr-ify DependenceAnalysis::depends
David Blaikie
dblaikie at gmail.com
Mon Aug 25 08:54:27 PDT 2014
On Aug 24, 2014 5:43 PM, "Dylan Noblesmith" <nobled at dreamwidth.org> wrote:
>
> Author: nobled
> Date: Sun Aug 24 19:28:39 2014
> New Revision: 216357
>
> URL: http://llvm.org/viewvc/llvm-project?rev=216357&view=rev
> Log:
> Analysis: unique_ptr-ify DependenceAnalysis::depends
>
> Modified:
> llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h
> llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
>
> Modified: llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h
> URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h?rev=216357&r1=216356&r2=216357&view=diff
>
==============================================================================
> --- llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h (original)
> +++ llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h Sun Aug 24
19:28:39 2014
> @@ -287,9 +287,9 @@ namespace llvm {
> /// The flag PossiblyLoopIndependent should be set by the caller
> /// if it appears that control flow can reach from Src to Dst
> /// without traversing a loop back edge.
> - Dependence *depends(Instruction *Src,
> - Instruction *Dst,
> - bool PossiblyLoopIndependent);
> + std::unique_ptr<Dependence> depends(Instruction *Src,
> + Instruction *Dst,
> + bool PossiblyLoopIndependent);
>
> /// getSplitIteration - Give a dependence that's splittable at some
> /// particular level, return the iteration that should be used to
split
>
> Modified: llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
> URL:
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DependenceAnalysis.cpp?rev=216357&r1=216356&r2=216357&view=diff
>
==============================================================================
> --- llvm/trunk/lib/Analysis/DependenceAnalysis.cpp (original)
> +++ llvm/trunk/lib/Analysis/DependenceAnalysis.cpp Sun Aug 24 19:28:39
2014
> @@ -163,7 +163,7 @@ void dumpExampleDependence(raw_ostream &
> DstI != DstE; ++DstI) {
> if (isa<StoreInst>(*DstI) || isa<LoadInst>(*DstI)) {
> OS << "da analyze - ";
> - if (Dependence *D = DA->depends(&*SrcI, &*DstI, true)) {
> + if (auto D = DA->depends(&*SrcI, &*DstI, true)) {
> D->dump(OS);
> for (unsigned Level = 1; Level <= D->getLevels(); Level++) {
> if (D->isSplitable(Level)) {
> @@ -172,7 +172,6 @@ void dumpExampleDependence(raw_ostream &
> OS << "!\n";
> }
> }
> - delete D;
> }
> else
> OS << "none!\n";
> @@ -3277,9 +3276,9 @@ static void dumpSmallBitVector(SmallBitV
> //
> // Care is required to keep the routine below, getSplitIteration(),
> // up to date with respect to this routine.
> -Dependence *DependenceAnalysis::depends(Instruction *Src,
> - Instruction *Dst,
> - bool PossiblyLoopIndependent) {
> +std::unique_ptr<Dependence>
> +DependenceAnalysis::depends(Instruction *Src, Instruction *Dst,
> + bool PossiblyLoopIndependent) {
> if (Src == Dst)
> PossiblyLoopIndependent = false;
>
> @@ -3291,7 +3290,7 @@ Dependence *DependenceAnalysis::depends(
> if (!isLoadOrStore(Src) || !isLoadOrStore(Dst)) {
> // can only analyze simple loads and stores, i.e., no calls,
invokes, etc.
> DEBUG(dbgs() << "can only handle simple loads and stores\n");
> - return new Dependence(Src, Dst);
> + return make_unique<Dependence>(Src, Dst);
> }
>
> Value *SrcPtr = getPointerOperand(Src);
> @@ -3302,7 +3301,7 @@ Dependence *DependenceAnalysis::depends(
> case AliasAnalysis::PartialAlias:
> // cannot analyse objects if we don't understand their aliasing.
> DEBUG(dbgs() << "can't analyze may or partial alias\n");
> - return new Dependence(Src, Dst);
> + return make_unique<Dependence>(Src, Dst);
> case AliasAnalysis::NoAlias:
> // If the objects noalias, they are distinct, accesses are
independent.
> DEBUG(dbgs() << "no alias\n");
> @@ -3675,7 +3674,8 @@ Dependence *DependenceAnalysis::depends(
> return nullptr;
> }
>
> - FullDependence *Final = new FullDependence(Result);
> + std::unique_ptr<Dependence> Final;
> + Final.reset(new FullDependence(Result));
This might be more simply written as:
auto Final = llvm::make_unique<FullDependence>(Result)
...
return std::move(Final); // move not required in C++14, I believe
or:
std::unique_ptr<Dependence> Final(new FullDependence(Result));
...
return Final;
It's a tradeoff either way, but either is a strict improvement over the
explicit "reset" usage you have, I think.
> Result.DV = nullptr;
> return Final;
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140825/450d1766/attachment.html>
More information about the llvm-commits
mailing list