[llvm] r284069 - [unittests] Delete even more copy constructors (NFC)

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 11:02:12 PDT 2016


While we didn't have any cases where we'd copy InputFunctionCoverageData
objects, I wanted to prevent these copies from ever occurring because they
would be expensive. Each object contains a SmallDenseMap<unsigned, unsigned>
and a std::vector<CounterMappingRegion>.

This commit was motivated by a case where we called std::vector::resize on a
vector of OutputFunctionCoverageData. Deleting the copy constructor in that
case should have made the resize operation cheaper (caveat - I haven't actually
measured this).

vedant

> On Oct 17, 2016, at 9:58 AM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> Were these copies problematic in any way? If it's just a POD type, you might as well leave it copyable, etc?
> 
> On Wed, Oct 12, 2016 at 3:53 PM Vedant Kumar via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> Author: vedantk
> Date: Wed Oct 12 17:44:50 2016
> New Revision: 284069
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=284069&view=rev
> Log:
> [unittests] Delete even more copy constructors (NFC)
> 
> Modified:
>     llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
> 
> Modified: llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp?rev=284069&r1=284068&r2=284069&view=diff
> ==============================================================================
> --- llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp (original)
> +++ llvm/trunk/unittests/ProfileData/CoverageMappingTest.cpp Wed Oct 12 17:44:50 2016
> @@ -106,6 +106,16 @@ struct InputFunctionCoverageData {
> 
>    InputFunctionCoverageData(std::string Name, uint64_t Hash)
>        : Name(std::move(Name)), Hash(Hash) {}
> +
> +  InputFunctionCoverageData(InputFunctionCoverageData &&IFCD)
> +      : ReverseVirtualFileMapping(std::move(IFCD.ReverseVirtualFileMapping)),
> +        Name(std::move(IFCD.Name)), Hash(IFCD.Hash),
> +        Regions(std::move(IFCD.Regions)) {}
> +
> +  InputFunctionCoverageData(const InputFunctionCoverageData &) = delete;
> +  InputFunctionCoverageData &
> +  operator=(const InputFunctionCoverageData &) = delete;
> +  InputFunctionCoverageData &operator=(InputFunctionCoverageData &&) = delete;
>  };
> 
>  struct CoverageMappingTest : ::testing::Test {
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list