[llvm] CoverageMapping.cpp: Apply std::move to MCDCRecord (PR #81220)
NAKAMURA Takumi via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 19:31:48 PST 2024
https://github.com/chapuni created https://github.com/llvm/llvm-project/pull/81220
None
>From 529b21ad67755647d27fad39ccb5eb539d0d620e Mon Sep 17 00:00:00 2001
From: NAKAMURA Takumi <geek4civic at gmail.com>
Date: Thu, 8 Feb 2024 18:38:27 +0900
Subject: [PATCH] CoverageMapping.cpp: Apply std::move to MCDCRecord
---
.../llvm/ProfileData/Coverage/CoverageMapping.h | 16 ++++++++++------
.../lib/ProfileData/Coverage/CoverageMapping.cpp | 8 ++++----
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
index 88ec60c7aa33c..b97ef42cd63de 100644
--- a/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
+++ b/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
@@ -407,11 +407,13 @@ struct MCDCRecord {
LineColPairMap CondLoc;
public:
- MCDCRecord(CounterMappingRegion Region, TestVectors TV,
- TVPairMap IndependencePairs, BoolVector Folded, CondIDMap PosToID,
- LineColPairMap CondLoc)
- : Region(Region), TV(TV), IndependencePairs(IndependencePairs),
- Folded(Folded), PosToID(PosToID), CondLoc(CondLoc){};
+ MCDCRecord(const CounterMappingRegion &Region, TestVectors &&TV,
+ TVPairMap &&IndependencePairs, BoolVector &&Folded,
+ CondIDMap &&PosToID, LineColPairMap &&CondLoc)
+ : Region(Region), TV(std::move(TV)),
+ IndependencePairs(std::move(IndependencePairs)),
+ Folded(std::move(Folded)), PosToID(std::move(PosToID)),
+ CondLoc(std::move(CondLoc)){};
CounterMappingRegion getDecisionRegion() const { return Region; }
unsigned getNumConditions() const {
@@ -614,7 +616,9 @@ struct FunctionRecord {
FunctionRecord(FunctionRecord &&FR) = default;
FunctionRecord &operator=(FunctionRecord &&) = default;
- void pushMCDCRecord(MCDCRecord Record) { MCDCRecords.push_back(Record); }
+ void pushMCDCRecord(MCDCRecord &&Record) {
+ MCDCRecords.push_back(std::move(Record));
+ }
void pushRegion(CounterMappingRegion Region, uint64_t Count,
uint64_t FalseCount) {
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 6b189c3146328..ec3c3c23bec9e 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -394,9 +394,9 @@ class MCDCRecordProcessor {
findIndependencePairs();
// Record Test vectors, executed vectors, and independence pairs.
- MCDCRecord Res(Region, ExecVectors, IndependencePairs, Folded, PosToID,
- CondLoc);
- return Res;
+ return MCDCRecord(Region, std::move(ExecVectors),
+ std::move(IndependencePairs), std::move(Folded),
+ std::move(PosToID), std::move(CondLoc));
}
};
@@ -770,7 +770,7 @@ Error CoverageMapping::loadFunctionRecord(
}
// Save the MC/DC Record so that it can be visualized later.
- Function.pushMCDCRecord(*Record);
+ Function.pushMCDCRecord(std::move(*Record));
}
// Don't create records for (filenames, function) pairs we've already seen.
More information about the llvm-commits
mailing list