llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-temporal-safety

@llvm/pr-subscribers-backend-loongarch

Author: Henry (sfu2)

<details>
<summary>Changes</summary>

A set of cleanup for redundant implicit container copies. Fixed with const 
reference or move semantics.

ece18dcd0 [AMDGPU] replace copy with const reference (NFC)
699b110b4 [-Wunsafe-buffer-usage] Replace vector copy with reference (NFC)
12c1d6000 [AMDGPU] Replace copy with move semantics (NFC)
008555245 [InstCombine] Replace vector copy with move semantic (NFC)
21ada655d [CommandLine] Avoid vector copy for const argument (NFC)
afd48098f [LoongArch] Remove unnecessary vector copy (NFC)
bee971162 [TextAPI] Replace map copy with const reference (NFC)
fb44e3ea7 [BlockExtract] Avoid copy semantic for ctor (NFC)
8ab5df0a7 [LifetimeSafety] Avoid map copy for dump methods (NFC)

---
Full diff: https://github.com/llvm/llvm-project/pull/174702.diff


10 Files Affected:

- (modified) clang/include/clang/Analysis/Analyses/LifetimeSafety/LiveOrigins.h 
(+1-1) 
- (modified) clang/lib/Analysis/LifetimeSafety/LiveOrigins.cpp (+2-2) 
- (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+1-1) 
- (modified) llvm/lib/Support/CommandLine.cpp (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp (+2-2) 
- (modified) llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp (+1-1) 
- (modified) llvm/lib/TextAPI/TextStubV5.cpp (+2-2) 
- (modified) llvm/lib/Transforms/IPO/BlockExtractor.cpp (+1-1) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp (+1-1) 


``````````diff
diff --git a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LiveOrigins.h 
b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LiveOrigins.h
index 8ad17db83499d..35b4224883cce 100644
--- a/clang/include/clang/Analysis/Analyses/LifetimeSafety/LiveOrigins.h
+++ b/clang/include/clang/Analysis/Analyses/LifetimeSafety/LiveOrigins.h
@@ -87,7 +87,7 @@ class LiveOriginsAnalysis {
 
   // Dump liveness values on all test points in the program.
   void dump(llvm::raw_ostream &OS,
-            llvm::StringMap<ProgramPoint> TestPoints) const;
+            const llvm::StringMap<ProgramPoint> &TestPoints) const;
 
 private:
   class Impl;
diff --git a/clang/lib/Analysis/LifetimeSafety/LiveOrigins.cpp 
b/clang/lib/Analysis/LifetimeSafety/LiveOrigins.cpp
index f567cdc548ba7..fbbd402e77192 100644
--- a/clang/lib/Analysis/LifetimeSafety/LiveOrigins.cpp
+++ b/clang/lib/Analysis/LifetimeSafety/LiveOrigins.cpp
@@ -165,7 +165,7 @@ class AnalysisImpl
 
   // Dump liveness values on all test points in the program.
   void dump(llvm::raw_ostream &OS,
-            llvm::StringMap<ProgramPoint> TestPoints) const {
+            const llvm::StringMap<ProgramPoint> &TestPoints) const {
     llvm::dbgs() << "==========================================\n";
     llvm::dbgs() << getAnalysisName() << " results:\n";
     llvm::dbgs() << "==========================================\n";
@@ -200,7 +200,7 @@ LivenessMap 
LiveOriginsAnalysis::getLiveOriginsAt(ProgramPoint P) const {
 }
 
 void LiveOriginsAnalysis::dump(llvm::raw_ostream &OS,
-                               llvm::StringMap<ProgramPoint> TestPoints) const 
{
+                               const llvm::StringMap<ProgramPoint> 
&TestPoints) const {
   PImpl->dump(OS, TestPoints);
 }
 } // namespace clang::lifetimes::internal
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index da19b9d3902f1..4c7ff12af8a0d 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -4241,7 +4241,7 @@ getNaiveStrategy(llvm::iterator_range<VarDeclIterTy> 
UnsafeVars) {
 
 //  Manages variable groups:
 class VariableGroupsManagerImpl : public VariableGroupsManager {
-  const std::vector<VarGrpTy> Groups;
+  const std::vector<VarGrpTy> &Groups;
   const std::map<const VarDecl *, unsigned> &VarGrpMap;
   const llvm::SetVector<const VarDecl *> &GrpsUnionForParms;
 
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp
index 5095b298fd42d..d7a28745a4669 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2557,7 +2557,7 @@ class HelpPrinterWrapper {
 namespace {
 class VersionPrinter {
 public:
-  void print(std::vector<VersionPrinterTy> ExtraPrinters = {}) {
+  void print(const std::vector<VersionPrinterTy> &ExtraPrinters) {
     raw_ostream &OS = outs();
 #ifdef PACKAGE_VENDOR
     OS << PACKAGE_VENDOR << " ";
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
index b7078825928be..581a3df70b994 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
@@ -991,7 +991,7 @@ void RecursiveSearchSplitting::run() {
   {
     SplitModuleTimer SMT("recursive_search_pick", "partitioning");
     SplitProposal SP(SG, NumParts);
-    pickPartition(/*BranchDepth=*/0, /*Idx=*/0, SP);
+    pickPartition(/*BranchDepth=*/0, /*Idx=*/0, std::move(SP));
   }
 }
 
@@ -1161,7 +1161,7 @@ void RecursiveSearchSplitting::pickPartition(unsigned 
Depth, unsigned Idx,
   SP.setName("recursive_search (depth=" + std::to_string(Depth) + ") #" +
              std::to_string(NumProposalsSubmitted++));
   LLVM_DEBUG(dbgs() << '\n');
-  SubmitProposal(SP);
+  SubmitProposal(std::move(SP));
 }
 
 std::pair<unsigned, CostType>
diff --git a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp 
b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
index 39a6a7762eea5..45891f5aa0c7a 100644
--- a/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp
@@ -1072,7 +1072,7 @@ void 
SIFixSGPRCopies::lowerVGPR2SGPRCopies(MachineFunction &MF) {
     unsigned CurID = LoweringWorklist.pop_back_val();
     auto *CurInfoIt = V2SCopies.find(CurID);
     if (CurInfoIt != V2SCopies.end()) {
-      V2SCopyInfo C = CurInfoIt->second;
+      const V2SCopyInfo &C = CurInfoIt->second;
       LLVM_DEBUG(dbgs() << "Processing ...\n"; C.dump());
       for (auto S : C.Siblings) {
         auto *SibInfoIt = V2SCopies.find(S);
@@ -1089,10 +1089,10 @@ void 
SIFixSGPRCopies::lowerVGPR2SGPRCopies(MachineFunction &MF) {
       }
       LLVM_DEBUG(dbgs() << "V2S copy " << *C.Copy
                         << " is being turned to VALU\n");
+      Copies.insert(C.Copy);
       // TODO: MapVector::erase is inefficient. Do bulk removal with remove_if
       // instead.
       V2SCopies.erase(C.ID);
-      Copies.insert(C.Copy);
     }
   }
 
diff --git a/llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp 
b/llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
index 2ab2a98c9434c..4b5cba716c638 100644
--- a/llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
@@ -276,7 +276,7 @@ void LoongArchAsmPrinter::emitJumpTableInfo() {
     return;
 
   unsigned Size = getDataLayout().getPointerSize();
-  auto JT = JTI->getJumpTables();
+  const auto &JT = JTI->getJumpTables();
 
   // Emit an additional section to store the correlation info as pairs of
   // addresses, each pair contains the address of a jump instruction (jr) and
diff --git a/llvm/lib/TextAPI/TextStubV5.cpp b/llvm/lib/TextAPI/TextStubV5.cpp
index f2687513bb854..de40d84f5e7a6 100644
--- a/llvm/lib/TextAPI/TextStubV5.cpp
+++ b/llvm/lib/TextAPI/TextStubV5.cpp
@@ -642,13 +642,13 @@ Expected<IFPtr> parseToInterfaceFile(const Object *File) {
   auto UmbrellasOrErr = getUmbrellaSection(File, Targets);
   if (!UmbrellasOrErr)
     return UmbrellasOrErr.takeError();
-  AttrToTargets Umbrellas = *UmbrellasOrErr;
+  const AttrToTargets &Umbrellas = *UmbrellasOrErr;
 
   auto ClientsOrErr =
       getLibSection(File, TBDKey::AllowableClients, TBDKey::Clients, Targets);
   if (!ClientsOrErr)
     return ClientsOrErr.takeError();
-  AttrToTargets Clients = *ClientsOrErr;
+  const AttrToTargets &Clients = *ClientsOrErr;
 
   auto RLOrErr =
       getLibSection(File, TBDKey::ReexportLibs, TBDKey::Names, Targets);
diff --git a/llvm/lib/Transforms/IPO/BlockExtractor.cpp 
b/llvm/lib/Transforms/IPO/BlockExtractor.cpp
index 44913533030e3..a88ca1f3d6bd9 100644
--- a/llvm/lib/Transforms/IPO/BlockExtractor.cpp
+++ b/llvm/lib/Transforms/IPO/BlockExtractor.cpp
@@ -196,7 +196,7 @@ bool BlockExtractor::runOnModule(Module &M) {
 BlockExtractorPass::BlockExtractorPass(
     std::vector<std::vector<BasicBlock *>> &&GroupsOfBlocks,
     bool EraseFunctions)
-    : GroupsOfBlocks(GroupsOfBlocks), EraseFunctions(EraseFunctions) {}
+    : GroupsOfBlocks(std::move(GroupsOfBlocks)), 
EraseFunctions(EraseFunctions) {}
 
 PreservedAnalyses BlockExtractorPass::run(Module &M,
                                           ModuleAnalysisManager &AM) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 8c64105b63fe4..f2e827221e8cf 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4831,7 +4831,7 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase 
&Call) {
       GCR.setOperand(2, ConstantInt::get(OpIntTy2, Val2Idx[DerivedPtr]));
     }
     // Create new statepoint instruction.
-    OperandBundleDef NewBundle("gc-live", NewLiveGc);
+    OperandBundleDef NewBundle("gc-live", std::move(NewLiveGc));
     return CallBase::Create(&Call, NewBundle);
   }
   default: { break; }

``````````

</details>


https://github.com/llvm/llvm-project/pull/174702
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to