[PATCH] D11911: Initialize base class by move constructor instead of copy constructor

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 10:29:02 PDT 2015


On Mon, Aug 10, 2015 at 9:57 AM, Aaron Ballman <aaron.ballman at gmail.com>
wrote:

> aaron.ballman created this revision.
> aaron.ballman added a reviewer: dblaikie.
> aaron.ballman added a subscriber: llvm-commits.
>
> The move constructor for FullDependence is initializing the base class via
> a copy constructor instead of a move constructor. This patch adds a default
> move constructor to the base class,


Defaulted moves still aren't supported by the min-spec of MSVC that LLVM
requires, I believe? So we have to write them out by hand.


> and makes use of it from the derived class instead of
> half-moving/half-copying the object.
>
> I'm not certain if this was accidentally forgotten as part of r243791, or
> was purposeful.
>

I don't think there was any particular intent on my part. Other than the
fact that Dependence has only trivial members, so move and copy are the
same operation, so I don't think this change actually makes any difference
to the optimization opportunities/behavior/etc?

(we could keep the std::move in the derived class's dtor (& leave the base
class as-is) - so that if the base class ever grows interesting move
semantics it'll 'just work' there)


>
> ~Aaron
>
> http://reviews.llvm.org/D11911
>
> Files:
>   include/llvm/Analysis/DependenceAnalysis.h
>
> Index: include/llvm/Analysis/DependenceAnalysis.h
> ===================================================================
> --- include/llvm/Analysis/DependenceAnalysis.h
> +++ include/llvm/Analysis/DependenceAnalysis.h
> @@ -71,6 +71,7 @@
>    class Dependence {
>    protected:
>      Dependence(const Dependence &) = default;
> +    Dependence(Dependence &&) = default;
>
>    public:
>      Dependence(Instruction *Source,
> @@ -225,7 +226,7 @@
>                     unsigned Levels);
>
>      FullDependence(FullDependence &&RHS)
> -        : Dependence(RHS), Levels(RHS.Levels),
> +        : Dependence(std::move(RHS)), Levels(RHS.Levels),
>            LoopIndependent(RHS.LoopIndependent),
> Consistent(RHS.Consistent),
>            DV(std::move(RHS.DV)) {}
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150810/1a24b24e/attachment.html>


More information about the llvm-commits mailing list