Skip to content

[llvm] Use llvm::copy (NFC) #137470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2025

@llvm/pr-subscribers-objectyaml
@llvm/pr-subscribers-llvm-binary-utilities
@llvm/pr-subscribers-llvm-globalisel
@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-debuginfo

Author: Kazu Hirata (kazutakahirata)

Changes

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

14 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/CallLowering.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/LiveDebugVariables.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/ExecutionEngine.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/COFF/COFFWriter.cpp (+3-3)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp (+1-1)
  • (modified) llvm/lib/ObjectYAML/COFFEmitter.cpp (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+2-2)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6c932651750ee..5dcb1cde25331 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3935,7 +3935,7 @@ DwarfDebug::getMD5AsBytes(const DIFile *File) const {
   // An MD5 checksum is 16 bytes.
   std::string ChecksumString = fromHex(Checksum->Value);
   MD5::MD5Result CKMem;
-  std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
+  llvm::copy(ChecksumString, CKMem.data());
   return CKMem;
 }
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 0af70f333f864..012d8735180be 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -354,7 +354,7 @@ mergeVectorRegsToResultRegs(MachineIRBuilder &B, ArrayRef<Register> DstRegs,
   int NumDst = LCMTy.getSizeInBits() / LLTy.getSizeInBits();
 
   SmallVector<Register, 8> PadDstRegs(NumDst);
-  std::copy(DstRegs.begin(), DstRegs.end(), PadDstRegs.begin());
+  llvm::copy(DstRegs, PadDstRegs.begin());
 
   // Create the excess dead defs for the unmerge.
   for (int I = DstRegs.size(); I != NumDst; ++I)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 0e7571bbf5ab1..36e53c83bcfc1 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -134,7 +134,7 @@ class DbgVariableValue {
       LocNoCount = LocNoVec.size();
       if (LocNoCount > 0) {
         LocNos = std::make_unique<unsigned[]>(LocNoCount);
-        std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+        llvm::copy(LocNoVec, loc_nos_begin());
       }
     } else {
       LLVM_DEBUG(dbgs() << "Found debug value with 64+ unique machine "
diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
index 17086876ad537..f631d84f73082 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
@@ -165,8 +165,8 @@ class SDDbgValue {
         IsVariadic(IsVariadic) {
     assert(IsVariadic || L.size() == 1);
     assert(!(IsVariadic && IsIndirect));
-    std::copy(L.begin(), L.end(), LocationOps);
-    std::copy(Dependencies.begin(), Dependencies.end(), AdditionalDependencies);
+    llvm::copy(L, LocationOps);
+    llvm::copy(Dependencies, AdditionalDependencies);
   }
 
   // We allocate arrays with the BumpPtrAllocator and never free or copy them,
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 872b24e59932c..9455a3847692b 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -347,7 +347,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
     LLVM_DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void *)Dest.get()
                       << "\n");
 
-    std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest.get());
+    llvm::copy(InputArgv[i], Dest.get());
     Dest[Size-1] = 0;
 
     // Endian safe: Array[i] = (PointerTy)Dest;
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 3ae88bd54d719..a37b2a2423391 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -936,7 +936,7 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
 
   // Set operands in order of their index to match use-list-order
   // prediction.
-  std::copy(Args.begin(), Args.end(), op_begin());
+  llvm::copy(Args, op_begin());
   NumIndirectDests = IndirectDests.size();
   setDefaultDest(Fallthrough);
   for (unsigned i = 0; i != NumIndirectDests; ++i)
diff --git a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
index 1f4893592915f..734a1698d515b 100644
--- a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
+++ b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
@@ -317,7 +317,7 @@ void COFFWriter::writeSections() {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    S.Header.PointerToRawData;
     ArrayRef<uint8_t> Contents = S.getContents();
-    std::copy(Contents.begin(), Contents.end(), Ptr);
+    llvm::copy(Contents, Ptr);
 
     // For executable sections, pad the remainder of the raw data size with
     // 0xcc, which is int3 on x86.
@@ -355,7 +355,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // For file symbols, just write the string into the aux symbol slots,
       // assuming that the unwritten parts are initialized to zero in the memory
       // mapped file.
-      std::copy(S.AuxFile.begin(), S.AuxFile.end(), Ptr);
+      llvm::copy(S.AuxFile, Ptr);
       Ptr += S.Sym.NumberOfAuxSymbols * sizeof(SymbolTy);
     } else {
       // For other auxillary symbols, write their opaque payload into one symbol
@@ -364,7 +364,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // entry.
       for (const AuxSymbol &AuxSym : S.AuxData) {
         ArrayRef<uint8_t> Ref = AuxSym.getRef();
-        std::copy(Ref.begin(), Ref.end(), Ptr);
+        llvm::copy(Ref, Ptr);
         Ptr += sizeof(SymbolTy);
       }
     }
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 45c7ea49b5d93..e5de17e093dfd 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -488,7 +488,7 @@ Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
                                  "': " + toString(std::move(E)));
 
   uint8_t *Buf = reinterpret_cast<uint8_t *>(Out.getBufferStart()) + Sec.Offset;
-  std::copy(Decompressed.begin(), Decompressed.end(), Buf);
+  llvm::copy(Decompressed, Buf);
 
   return Error::success();
 }
diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
index cbc8e471b3090..e9a371ffa926f 100644
--- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
@@ -161,7 +161,7 @@ static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
 
   LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
   LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
-  std::copy(S.begin(), S.end(), LC.Payload.begin());
+  llvm::copy(S, LC.Payload.begin());
 }
 
 static LoadCommand buildRPathLoadCommand(StringRef Path) {
@@ -172,7 +172,7 @@ static LoadCommand buildRPathLoadCommand(StringRef Path) {
   RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size() + 1, 8);
   LC.MachOLoadCommand.rpath_command_data = RPathLC;
   LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
-  std::copy(Path.begin(), Path.end(), LC.Payload.begin());
+  llvm::copy(Path, LC.Payload.begin());
   return LC;
 }
 
diff --git a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
index bae3128822e22..e8423ff84179b 100644
--- a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
+++ b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
@@ -75,7 +75,7 @@ void XCOFFWriter::writeSections() {
   for (const Section &Sec : Obj.Sections) {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    Sec.SectionHeader.FileOffsetToRawData;
-    Ptr = std::copy(Sec.Contents.begin(), Sec.Contents.end(), Ptr);
+    Ptr = llvm::copy(Sec.Contents, Ptr);
   }
 
   // Write relocations.
diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
index 57fd0f5ad233c..faf5b0fa56539 100644
--- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
+++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
@@ -47,7 +47,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
       if (!BufferOrErr)
         return createFileError(Filename, BufferOrErr.takeError());
       std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
-      std::copy(Contents.begin(), Contents.end(), Buf->getBufferStart());
+      llvm::copy(Contents, Buf->getBufferStart());
       if (Error E = Buf->commit())
         return createFileError(Filename, std::move(E));
       return Error::success();
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 1a512ba39ff76..b21197105cbde 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -65,7 +65,7 @@ struct COFFParser {
       StringRef Name = Sec.Name;
 
       if (Name.size() <= COFF::NameSize) {
-        std::copy(Name.begin(), Name.end(), Sec.Header.Name);
+        llvm::copy(Name, Sec.Header.Name);
       } else {
         // Add string to the string table and format the index for output.
         unsigned Index = getStringIndex(Name);
@@ -75,7 +75,7 @@ struct COFFParser {
           return false;
         }
         Sec.Header.Name[0] = '/';
-        std::copy(str.begin(), str.end(), Sec.Header.Name + 1);
+        llvm::copy(str, Sec.Header.Name + 1);
       }
 
       if (Sec.Alignment) {
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 02b0282bbddad..52fa678a600e9 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -1269,11 +1269,11 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
     return OpRef::fail();
 
   if (Vb.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     return Va;
   }
   if (Va.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     ShuffleVectorSDNode::commuteMask(NewMask);
     return Vb;
   }
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 61ba3698a0340..d06796660c444 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1267,14 +1267,14 @@ NewGVN::createAggregateValueExpression(Instruction *I) const {
         AggregateValueExpression(I->getNumOperands(), II->getNumIndices());
     setBasicExpressionInfo(I, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(II->idx_begin(), II->idx_end(), int_op_inserter(E));
+    llvm::copy(II->indices(), int_op_inserter(E));
     return E;
   } else if (auto *EI = dyn_cast<ExtractValueInst>(I)) {
     auto *E = new (ExpressionAllocator)
         AggregateValueExpression(I->getNumOperands(), EI->getNumIndices());
     setBasicExpressionInfo(EI, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(EI->idx_begin(), EI->idx_end(), int_op_inserter(E));
+    llvm::copy(EI->indices(), int_op_inserter(E));
     return E;
   }
   llvm_unreachable("Unhandled type of aggregate value operation");

@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2025

@llvm/pr-subscribers-backend-hexagon

Author: Kazu Hirata (kazutakahirata)

Changes

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

14 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/CallLowering.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/LiveDebugVariables.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/ExecutionEngine.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/COFF/COFFWriter.cpp (+3-3)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp (+1-1)
  • (modified) llvm/lib/ObjectYAML/COFFEmitter.cpp (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+2-2)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6c932651750ee..5dcb1cde25331 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3935,7 +3935,7 @@ DwarfDebug::getMD5AsBytes(const DIFile *File) const {
   // An MD5 checksum is 16 bytes.
   std::string ChecksumString = fromHex(Checksum->Value);
   MD5::MD5Result CKMem;
-  std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
+  llvm::copy(ChecksumString, CKMem.data());
   return CKMem;
 }
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 0af70f333f864..012d8735180be 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -354,7 +354,7 @@ mergeVectorRegsToResultRegs(MachineIRBuilder &B, ArrayRef<Register> DstRegs,
   int NumDst = LCMTy.getSizeInBits() / LLTy.getSizeInBits();
 
   SmallVector<Register, 8> PadDstRegs(NumDst);
-  std::copy(DstRegs.begin(), DstRegs.end(), PadDstRegs.begin());
+  llvm::copy(DstRegs, PadDstRegs.begin());
 
   // Create the excess dead defs for the unmerge.
   for (int I = DstRegs.size(); I != NumDst; ++I)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 0e7571bbf5ab1..36e53c83bcfc1 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -134,7 +134,7 @@ class DbgVariableValue {
       LocNoCount = LocNoVec.size();
       if (LocNoCount > 0) {
         LocNos = std::make_unique<unsigned[]>(LocNoCount);
-        std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+        llvm::copy(LocNoVec, loc_nos_begin());
       }
     } else {
       LLVM_DEBUG(dbgs() << "Found debug value with 64+ unique machine "
diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
index 17086876ad537..f631d84f73082 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
@@ -165,8 +165,8 @@ class SDDbgValue {
         IsVariadic(IsVariadic) {
     assert(IsVariadic || L.size() == 1);
     assert(!(IsVariadic && IsIndirect));
-    std::copy(L.begin(), L.end(), LocationOps);
-    std::copy(Dependencies.begin(), Dependencies.end(), AdditionalDependencies);
+    llvm::copy(L, LocationOps);
+    llvm::copy(Dependencies, AdditionalDependencies);
   }
 
   // We allocate arrays with the BumpPtrAllocator and never free or copy them,
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 872b24e59932c..9455a3847692b 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -347,7 +347,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
     LLVM_DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void *)Dest.get()
                       << "\n");
 
-    std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest.get());
+    llvm::copy(InputArgv[i], Dest.get());
     Dest[Size-1] = 0;
 
     // Endian safe: Array[i] = (PointerTy)Dest;
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 3ae88bd54d719..a37b2a2423391 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -936,7 +936,7 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
 
   // Set operands in order of their index to match use-list-order
   // prediction.
-  std::copy(Args.begin(), Args.end(), op_begin());
+  llvm::copy(Args, op_begin());
   NumIndirectDests = IndirectDests.size();
   setDefaultDest(Fallthrough);
   for (unsigned i = 0; i != NumIndirectDests; ++i)
diff --git a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
index 1f4893592915f..734a1698d515b 100644
--- a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
+++ b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
@@ -317,7 +317,7 @@ void COFFWriter::writeSections() {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    S.Header.PointerToRawData;
     ArrayRef<uint8_t> Contents = S.getContents();
-    std::copy(Contents.begin(), Contents.end(), Ptr);
+    llvm::copy(Contents, Ptr);
 
     // For executable sections, pad the remainder of the raw data size with
     // 0xcc, which is int3 on x86.
@@ -355,7 +355,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // For file symbols, just write the string into the aux symbol slots,
       // assuming that the unwritten parts are initialized to zero in the memory
       // mapped file.
-      std::copy(S.AuxFile.begin(), S.AuxFile.end(), Ptr);
+      llvm::copy(S.AuxFile, Ptr);
       Ptr += S.Sym.NumberOfAuxSymbols * sizeof(SymbolTy);
     } else {
       // For other auxillary symbols, write their opaque payload into one symbol
@@ -364,7 +364,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // entry.
       for (const AuxSymbol &AuxSym : S.AuxData) {
         ArrayRef<uint8_t> Ref = AuxSym.getRef();
-        std::copy(Ref.begin(), Ref.end(), Ptr);
+        llvm::copy(Ref, Ptr);
         Ptr += sizeof(SymbolTy);
       }
     }
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 45c7ea49b5d93..e5de17e093dfd 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -488,7 +488,7 @@ Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
                                  "': " + toString(std::move(E)));
 
   uint8_t *Buf = reinterpret_cast<uint8_t *>(Out.getBufferStart()) + Sec.Offset;
-  std::copy(Decompressed.begin(), Decompressed.end(), Buf);
+  llvm::copy(Decompressed, Buf);
 
   return Error::success();
 }
diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
index cbc8e471b3090..e9a371ffa926f 100644
--- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
@@ -161,7 +161,7 @@ static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
 
   LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
   LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
-  std::copy(S.begin(), S.end(), LC.Payload.begin());
+  llvm::copy(S, LC.Payload.begin());
 }
 
 static LoadCommand buildRPathLoadCommand(StringRef Path) {
@@ -172,7 +172,7 @@ static LoadCommand buildRPathLoadCommand(StringRef Path) {
   RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size() + 1, 8);
   LC.MachOLoadCommand.rpath_command_data = RPathLC;
   LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
-  std::copy(Path.begin(), Path.end(), LC.Payload.begin());
+  llvm::copy(Path, LC.Payload.begin());
   return LC;
 }
 
diff --git a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
index bae3128822e22..e8423ff84179b 100644
--- a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
+++ b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
@@ -75,7 +75,7 @@ void XCOFFWriter::writeSections() {
   for (const Section &Sec : Obj.Sections) {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    Sec.SectionHeader.FileOffsetToRawData;
-    Ptr = std::copy(Sec.Contents.begin(), Sec.Contents.end(), Ptr);
+    Ptr = llvm::copy(Sec.Contents, Ptr);
   }
 
   // Write relocations.
diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
index 57fd0f5ad233c..faf5b0fa56539 100644
--- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
+++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
@@ -47,7 +47,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
       if (!BufferOrErr)
         return createFileError(Filename, BufferOrErr.takeError());
       std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
-      std::copy(Contents.begin(), Contents.end(), Buf->getBufferStart());
+      llvm::copy(Contents, Buf->getBufferStart());
       if (Error E = Buf->commit())
         return createFileError(Filename, std::move(E));
       return Error::success();
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 1a512ba39ff76..b21197105cbde 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -65,7 +65,7 @@ struct COFFParser {
       StringRef Name = Sec.Name;
 
       if (Name.size() <= COFF::NameSize) {
-        std::copy(Name.begin(), Name.end(), Sec.Header.Name);
+        llvm::copy(Name, Sec.Header.Name);
       } else {
         // Add string to the string table and format the index for output.
         unsigned Index = getStringIndex(Name);
@@ -75,7 +75,7 @@ struct COFFParser {
           return false;
         }
         Sec.Header.Name[0] = '/';
-        std::copy(str.begin(), str.end(), Sec.Header.Name + 1);
+        llvm::copy(str, Sec.Header.Name + 1);
       }
 
       if (Sec.Alignment) {
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 02b0282bbddad..52fa678a600e9 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -1269,11 +1269,11 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
     return OpRef::fail();
 
   if (Vb.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     return Va;
   }
   if (Va.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     ShuffleVectorSDNode::commuteMask(NewMask);
     return Vb;
   }
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 61ba3698a0340..d06796660c444 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1267,14 +1267,14 @@ NewGVN::createAggregateValueExpression(Instruction *I) const {
         AggregateValueExpression(I->getNumOperands(), II->getNumIndices());
     setBasicExpressionInfo(I, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(II->idx_begin(), II->idx_end(), int_op_inserter(E));
+    llvm::copy(II->indices(), int_op_inserter(E));
     return E;
   } else if (auto *EI = dyn_cast<ExtractValueInst>(I)) {
     auto *E = new (ExpressionAllocator)
         AggregateValueExpression(I->getNumOperands(), EI->getNumIndices());
     setBasicExpressionInfo(EI, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(EI->idx_begin(), EI->idx_end(), int_op_inserter(E));
+    llvm::copy(EI->indices(), int_op_inserter(E));
     return E;
   }
   llvm_unreachable("Unhandled type of aggregate value operation");

@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

14 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/CallLowering.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/LiveDebugVariables.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/ExecutionEngine.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/COFF/COFFWriter.cpp (+3-3)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp (+1-1)
  • (modified) llvm/lib/ObjectYAML/COFFEmitter.cpp (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+2-2)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6c932651750ee..5dcb1cde25331 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3935,7 +3935,7 @@ DwarfDebug::getMD5AsBytes(const DIFile *File) const {
   // An MD5 checksum is 16 bytes.
   std::string ChecksumString = fromHex(Checksum->Value);
   MD5::MD5Result CKMem;
-  std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
+  llvm::copy(ChecksumString, CKMem.data());
   return CKMem;
 }
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 0af70f333f864..012d8735180be 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -354,7 +354,7 @@ mergeVectorRegsToResultRegs(MachineIRBuilder &B, ArrayRef<Register> DstRegs,
   int NumDst = LCMTy.getSizeInBits() / LLTy.getSizeInBits();
 
   SmallVector<Register, 8> PadDstRegs(NumDst);
-  std::copy(DstRegs.begin(), DstRegs.end(), PadDstRegs.begin());
+  llvm::copy(DstRegs, PadDstRegs.begin());
 
   // Create the excess dead defs for the unmerge.
   for (int I = DstRegs.size(); I != NumDst; ++I)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 0e7571bbf5ab1..36e53c83bcfc1 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -134,7 +134,7 @@ class DbgVariableValue {
       LocNoCount = LocNoVec.size();
       if (LocNoCount > 0) {
         LocNos = std::make_unique<unsigned[]>(LocNoCount);
-        std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+        llvm::copy(LocNoVec, loc_nos_begin());
       }
     } else {
       LLVM_DEBUG(dbgs() << "Found debug value with 64+ unique machine "
diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
index 17086876ad537..f631d84f73082 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
@@ -165,8 +165,8 @@ class SDDbgValue {
         IsVariadic(IsVariadic) {
     assert(IsVariadic || L.size() == 1);
     assert(!(IsVariadic && IsIndirect));
-    std::copy(L.begin(), L.end(), LocationOps);
-    std::copy(Dependencies.begin(), Dependencies.end(), AdditionalDependencies);
+    llvm::copy(L, LocationOps);
+    llvm::copy(Dependencies, AdditionalDependencies);
   }
 
   // We allocate arrays with the BumpPtrAllocator and never free or copy them,
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 872b24e59932c..9455a3847692b 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -347,7 +347,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
     LLVM_DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void *)Dest.get()
                       << "\n");
 
-    std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest.get());
+    llvm::copy(InputArgv[i], Dest.get());
     Dest[Size-1] = 0;
 
     // Endian safe: Array[i] = (PointerTy)Dest;
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 3ae88bd54d719..a37b2a2423391 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -936,7 +936,7 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
 
   // Set operands in order of their index to match use-list-order
   // prediction.
-  std::copy(Args.begin(), Args.end(), op_begin());
+  llvm::copy(Args, op_begin());
   NumIndirectDests = IndirectDests.size();
   setDefaultDest(Fallthrough);
   for (unsigned i = 0; i != NumIndirectDests; ++i)
diff --git a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
index 1f4893592915f..734a1698d515b 100644
--- a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
+++ b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
@@ -317,7 +317,7 @@ void COFFWriter::writeSections() {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    S.Header.PointerToRawData;
     ArrayRef<uint8_t> Contents = S.getContents();
-    std::copy(Contents.begin(), Contents.end(), Ptr);
+    llvm::copy(Contents, Ptr);
 
     // For executable sections, pad the remainder of the raw data size with
     // 0xcc, which is int3 on x86.
@@ -355,7 +355,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // For file symbols, just write the string into the aux symbol slots,
       // assuming that the unwritten parts are initialized to zero in the memory
       // mapped file.
-      std::copy(S.AuxFile.begin(), S.AuxFile.end(), Ptr);
+      llvm::copy(S.AuxFile, Ptr);
       Ptr += S.Sym.NumberOfAuxSymbols * sizeof(SymbolTy);
     } else {
       // For other auxillary symbols, write their opaque payload into one symbol
@@ -364,7 +364,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // entry.
       for (const AuxSymbol &AuxSym : S.AuxData) {
         ArrayRef<uint8_t> Ref = AuxSym.getRef();
-        std::copy(Ref.begin(), Ref.end(), Ptr);
+        llvm::copy(Ref, Ptr);
         Ptr += sizeof(SymbolTy);
       }
     }
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 45c7ea49b5d93..e5de17e093dfd 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -488,7 +488,7 @@ Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
                                  "': " + toString(std::move(E)));
 
   uint8_t *Buf = reinterpret_cast<uint8_t *>(Out.getBufferStart()) + Sec.Offset;
-  std::copy(Decompressed.begin(), Decompressed.end(), Buf);
+  llvm::copy(Decompressed, Buf);
 
   return Error::success();
 }
diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
index cbc8e471b3090..e9a371ffa926f 100644
--- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
@@ -161,7 +161,7 @@ static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
 
   LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
   LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
-  std::copy(S.begin(), S.end(), LC.Payload.begin());
+  llvm::copy(S, LC.Payload.begin());
 }
 
 static LoadCommand buildRPathLoadCommand(StringRef Path) {
@@ -172,7 +172,7 @@ static LoadCommand buildRPathLoadCommand(StringRef Path) {
   RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size() + 1, 8);
   LC.MachOLoadCommand.rpath_command_data = RPathLC;
   LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
-  std::copy(Path.begin(), Path.end(), LC.Payload.begin());
+  llvm::copy(Path, LC.Payload.begin());
   return LC;
 }
 
diff --git a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
index bae3128822e22..e8423ff84179b 100644
--- a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
+++ b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
@@ -75,7 +75,7 @@ void XCOFFWriter::writeSections() {
   for (const Section &Sec : Obj.Sections) {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    Sec.SectionHeader.FileOffsetToRawData;
-    Ptr = std::copy(Sec.Contents.begin(), Sec.Contents.end(), Ptr);
+    Ptr = llvm::copy(Sec.Contents, Ptr);
   }
 
   // Write relocations.
diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
index 57fd0f5ad233c..faf5b0fa56539 100644
--- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
+++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
@@ -47,7 +47,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
       if (!BufferOrErr)
         return createFileError(Filename, BufferOrErr.takeError());
       std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
-      std::copy(Contents.begin(), Contents.end(), Buf->getBufferStart());
+      llvm::copy(Contents, Buf->getBufferStart());
       if (Error E = Buf->commit())
         return createFileError(Filename, std::move(E));
       return Error::success();
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 1a512ba39ff76..b21197105cbde 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -65,7 +65,7 @@ struct COFFParser {
       StringRef Name = Sec.Name;
 
       if (Name.size() <= COFF::NameSize) {
-        std::copy(Name.begin(), Name.end(), Sec.Header.Name);
+        llvm::copy(Name, Sec.Header.Name);
       } else {
         // Add string to the string table and format the index for output.
         unsigned Index = getStringIndex(Name);
@@ -75,7 +75,7 @@ struct COFFParser {
           return false;
         }
         Sec.Header.Name[0] = '/';
-        std::copy(str.begin(), str.end(), Sec.Header.Name + 1);
+        llvm::copy(str, Sec.Header.Name + 1);
       }
 
       if (Sec.Alignment) {
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 02b0282bbddad..52fa678a600e9 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -1269,11 +1269,11 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
     return OpRef::fail();
 
   if (Vb.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     return Va;
   }
   if (Va.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     ShuffleVectorSDNode::commuteMask(NewMask);
     return Vb;
   }
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 61ba3698a0340..d06796660c444 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1267,14 +1267,14 @@ NewGVN::createAggregateValueExpression(Instruction *I) const {
         AggregateValueExpression(I->getNumOperands(), II->getNumIndices());
     setBasicExpressionInfo(I, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(II->idx_begin(), II->idx_end(), int_op_inserter(E));
+    llvm::copy(II->indices(), int_op_inserter(E));
     return E;
   } else if (auto *EI = dyn_cast<ExtractValueInst>(I)) {
     auto *E = new (ExpressionAllocator)
         AggregateValueExpression(I->getNumOperands(), EI->getNumIndices());
     setBasicExpressionInfo(EI, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(EI->idx_begin(), EI->idx_end(), int_op_inserter(E));
+    llvm::copy(EI->indices(), int_op_inserter(E));
     return E;
   }
   llvm_unreachable("Unhandled type of aggregate value operation");

@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Kazu Hirata (kazutakahirata)

Changes

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

14 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/CallLowering.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/LiveDebugVariables.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/ExecutionEngine.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/COFF/COFFWriter.cpp (+3-3)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp (+1-1)
  • (modified) llvm/lib/ObjectYAML/COFFEmitter.cpp (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+2-2)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6c932651750ee..5dcb1cde25331 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3935,7 +3935,7 @@ DwarfDebug::getMD5AsBytes(const DIFile *File) const {
   // An MD5 checksum is 16 bytes.
   std::string ChecksumString = fromHex(Checksum->Value);
   MD5::MD5Result CKMem;
-  std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
+  llvm::copy(ChecksumString, CKMem.data());
   return CKMem;
 }
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 0af70f333f864..012d8735180be 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -354,7 +354,7 @@ mergeVectorRegsToResultRegs(MachineIRBuilder &B, ArrayRef<Register> DstRegs,
   int NumDst = LCMTy.getSizeInBits() / LLTy.getSizeInBits();
 
   SmallVector<Register, 8> PadDstRegs(NumDst);
-  std::copy(DstRegs.begin(), DstRegs.end(), PadDstRegs.begin());
+  llvm::copy(DstRegs, PadDstRegs.begin());
 
   // Create the excess dead defs for the unmerge.
   for (int I = DstRegs.size(); I != NumDst; ++I)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 0e7571bbf5ab1..36e53c83bcfc1 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -134,7 +134,7 @@ class DbgVariableValue {
       LocNoCount = LocNoVec.size();
       if (LocNoCount > 0) {
         LocNos = std::make_unique<unsigned[]>(LocNoCount);
-        std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+        llvm::copy(LocNoVec, loc_nos_begin());
       }
     } else {
       LLVM_DEBUG(dbgs() << "Found debug value with 64+ unique machine "
diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
index 17086876ad537..f631d84f73082 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
@@ -165,8 +165,8 @@ class SDDbgValue {
         IsVariadic(IsVariadic) {
     assert(IsVariadic || L.size() == 1);
     assert(!(IsVariadic && IsIndirect));
-    std::copy(L.begin(), L.end(), LocationOps);
-    std::copy(Dependencies.begin(), Dependencies.end(), AdditionalDependencies);
+    llvm::copy(L, LocationOps);
+    llvm::copy(Dependencies, AdditionalDependencies);
   }
 
   // We allocate arrays with the BumpPtrAllocator and never free or copy them,
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 872b24e59932c..9455a3847692b 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -347,7 +347,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
     LLVM_DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void *)Dest.get()
                       << "\n");
 
-    std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest.get());
+    llvm::copy(InputArgv[i], Dest.get());
     Dest[Size-1] = 0;
 
     // Endian safe: Array[i] = (PointerTy)Dest;
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 3ae88bd54d719..a37b2a2423391 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -936,7 +936,7 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
 
   // Set operands in order of their index to match use-list-order
   // prediction.
-  std::copy(Args.begin(), Args.end(), op_begin());
+  llvm::copy(Args, op_begin());
   NumIndirectDests = IndirectDests.size();
   setDefaultDest(Fallthrough);
   for (unsigned i = 0; i != NumIndirectDests; ++i)
diff --git a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
index 1f4893592915f..734a1698d515b 100644
--- a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
+++ b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
@@ -317,7 +317,7 @@ void COFFWriter::writeSections() {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    S.Header.PointerToRawData;
     ArrayRef<uint8_t> Contents = S.getContents();
-    std::copy(Contents.begin(), Contents.end(), Ptr);
+    llvm::copy(Contents, Ptr);
 
     // For executable sections, pad the remainder of the raw data size with
     // 0xcc, which is int3 on x86.
@@ -355,7 +355,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // For file symbols, just write the string into the aux symbol slots,
       // assuming that the unwritten parts are initialized to zero in the memory
       // mapped file.
-      std::copy(S.AuxFile.begin(), S.AuxFile.end(), Ptr);
+      llvm::copy(S.AuxFile, Ptr);
       Ptr += S.Sym.NumberOfAuxSymbols * sizeof(SymbolTy);
     } else {
       // For other auxillary symbols, write their opaque payload into one symbol
@@ -364,7 +364,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // entry.
       for (const AuxSymbol &AuxSym : S.AuxData) {
         ArrayRef<uint8_t> Ref = AuxSym.getRef();
-        std::copy(Ref.begin(), Ref.end(), Ptr);
+        llvm::copy(Ref, Ptr);
         Ptr += sizeof(SymbolTy);
       }
     }
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 45c7ea49b5d93..e5de17e093dfd 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -488,7 +488,7 @@ Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
                                  "': " + toString(std::move(E)));
 
   uint8_t *Buf = reinterpret_cast<uint8_t *>(Out.getBufferStart()) + Sec.Offset;
-  std::copy(Decompressed.begin(), Decompressed.end(), Buf);
+  llvm::copy(Decompressed, Buf);
 
   return Error::success();
 }
diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
index cbc8e471b3090..e9a371ffa926f 100644
--- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
@@ -161,7 +161,7 @@ static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
 
   LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
   LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
-  std::copy(S.begin(), S.end(), LC.Payload.begin());
+  llvm::copy(S, LC.Payload.begin());
 }
 
 static LoadCommand buildRPathLoadCommand(StringRef Path) {
@@ -172,7 +172,7 @@ static LoadCommand buildRPathLoadCommand(StringRef Path) {
   RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size() + 1, 8);
   LC.MachOLoadCommand.rpath_command_data = RPathLC;
   LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
-  std::copy(Path.begin(), Path.end(), LC.Payload.begin());
+  llvm::copy(Path, LC.Payload.begin());
   return LC;
 }
 
diff --git a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
index bae3128822e22..e8423ff84179b 100644
--- a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
+++ b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
@@ -75,7 +75,7 @@ void XCOFFWriter::writeSections() {
   for (const Section &Sec : Obj.Sections) {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    Sec.SectionHeader.FileOffsetToRawData;
-    Ptr = std::copy(Sec.Contents.begin(), Sec.Contents.end(), Ptr);
+    Ptr = llvm::copy(Sec.Contents, Ptr);
   }
 
   // Write relocations.
diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
index 57fd0f5ad233c..faf5b0fa56539 100644
--- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
+++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
@@ -47,7 +47,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
       if (!BufferOrErr)
         return createFileError(Filename, BufferOrErr.takeError());
       std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
-      std::copy(Contents.begin(), Contents.end(), Buf->getBufferStart());
+      llvm::copy(Contents, Buf->getBufferStart());
       if (Error E = Buf->commit())
         return createFileError(Filename, std::move(E));
       return Error::success();
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 1a512ba39ff76..b21197105cbde 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -65,7 +65,7 @@ struct COFFParser {
       StringRef Name = Sec.Name;
 
       if (Name.size() <= COFF::NameSize) {
-        std::copy(Name.begin(), Name.end(), Sec.Header.Name);
+        llvm::copy(Name, Sec.Header.Name);
       } else {
         // Add string to the string table and format the index for output.
         unsigned Index = getStringIndex(Name);
@@ -75,7 +75,7 @@ struct COFFParser {
           return false;
         }
         Sec.Header.Name[0] = '/';
-        std::copy(str.begin(), str.end(), Sec.Header.Name + 1);
+        llvm::copy(str, Sec.Header.Name + 1);
       }
 
       if (Sec.Alignment) {
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 02b0282bbddad..52fa678a600e9 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -1269,11 +1269,11 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
     return OpRef::fail();
 
   if (Vb.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     return Va;
   }
   if (Va.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     ShuffleVectorSDNode::commuteMask(NewMask);
     return Vb;
   }
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 61ba3698a0340..d06796660c444 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1267,14 +1267,14 @@ NewGVN::createAggregateValueExpression(Instruction *I) const {
         AggregateValueExpression(I->getNumOperands(), II->getNumIndices());
     setBasicExpressionInfo(I, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(II->idx_begin(), II->idx_end(), int_op_inserter(E));
+    llvm::copy(II->indices(), int_op_inserter(E));
     return E;
   } else if (auto *EI = dyn_cast<ExtractValueInst>(I)) {
     auto *E = new (ExpressionAllocator)
         AggregateValueExpression(I->getNumOperands(), EI->getNumIndices());
     setBasicExpressionInfo(EI, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(EI->idx_begin(), EI->idx_end(), int_op_inserter(E));
+    llvm::copy(EI->indices(), int_op_inserter(E));
     return E;
   }
   llvm_unreachable("Unhandled type of aggregate value operation");

@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2025

@llvm/pr-subscribers-backend-webassembly

Author: Kazu Hirata (kazutakahirata)

Changes

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

14 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/GlobalISel/CallLowering.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/LiveDebugVariables.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (+2-2)
  • (modified) llvm/lib/ExecutionEngine/ExecutionEngine.cpp (+1-1)
  • (modified) llvm/lib/IR/Instructions.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/COFF/COFFWriter.cpp (+3-3)
  • (modified) llvm/lib/ObjCopy/ELF/ELFObject.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp (+2-2)
  • (modified) llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp (+1-1)
  • (modified) llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp (+1-1)
  • (modified) llvm/lib/ObjectYAML/COFFEmitter.cpp (+2-2)
  • (modified) llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp (+2-2)
  • (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+2-2)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 6c932651750ee..5dcb1cde25331 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3935,7 +3935,7 @@ DwarfDebug::getMD5AsBytes(const DIFile *File) const {
   // An MD5 checksum is 16 bytes.
   std::string ChecksumString = fromHex(Checksum->Value);
   MD5::MD5Result CKMem;
-  std::copy(ChecksumString.begin(), ChecksumString.end(), CKMem.data());
+  llvm::copy(ChecksumString, CKMem.data());
   return CKMem;
 }
 
diff --git a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
index 0af70f333f864..012d8735180be 100644
--- a/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
@@ -354,7 +354,7 @@ mergeVectorRegsToResultRegs(MachineIRBuilder &B, ArrayRef<Register> DstRegs,
   int NumDst = LCMTy.getSizeInBits() / LLTy.getSizeInBits();
 
   SmallVector<Register, 8> PadDstRegs(NumDst);
-  std::copy(DstRegs.begin(), DstRegs.end(), PadDstRegs.begin());
+  llvm::copy(DstRegs, PadDstRegs.begin());
 
   // Create the excess dead defs for the unmerge.
   for (int I = DstRegs.size(); I != NumDst; ++I)
diff --git a/llvm/lib/CodeGen/LiveDebugVariables.cpp b/llvm/lib/CodeGen/LiveDebugVariables.cpp
index 0e7571bbf5ab1..36e53c83bcfc1 100644
--- a/llvm/lib/CodeGen/LiveDebugVariables.cpp
+++ b/llvm/lib/CodeGen/LiveDebugVariables.cpp
@@ -134,7 +134,7 @@ class DbgVariableValue {
       LocNoCount = LocNoVec.size();
       if (LocNoCount > 0) {
         LocNos = std::make_unique<unsigned[]>(LocNoCount);
-        std::copy(LocNoVec.begin(), LocNoVec.end(), loc_nos_begin());
+        llvm::copy(LocNoVec, loc_nos_begin());
       }
     } else {
       LLVM_DEBUG(dbgs() << "Found debug value with 64+ unique machine "
diff --git a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
index 17086876ad537..f631d84f73082 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h
@@ -165,8 +165,8 @@ class SDDbgValue {
         IsVariadic(IsVariadic) {
     assert(IsVariadic || L.size() == 1);
     assert(!(IsVariadic && IsIndirect));
-    std::copy(L.begin(), L.end(), LocationOps);
-    std::copy(Dependencies.begin(), Dependencies.end(), AdditionalDependencies);
+    llvm::copy(L, LocationOps);
+    llvm::copy(Dependencies, AdditionalDependencies);
   }
 
   // We allocate arrays with the BumpPtrAllocator and never free or copy them,
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 872b24e59932c..9455a3847692b 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -347,7 +347,7 @@ void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
     LLVM_DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void *)Dest.get()
                       << "\n");
 
-    std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest.get());
+    llvm::copy(InputArgv[i], Dest.get());
     Dest[Size-1] = 0;
 
     // Endian safe: Array[i] = (PointerTy)Dest;
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 3ae88bd54d719..a37b2a2423391 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -936,7 +936,7 @@ void CallBrInst::init(FunctionType *FTy, Value *Fn, BasicBlock *Fallthrough,
 
   // Set operands in order of their index to match use-list-order
   // prediction.
-  std::copy(Args.begin(), Args.end(), op_begin());
+  llvm::copy(Args, op_begin());
   NumIndirectDests = IndirectDests.size();
   setDefaultDest(Fallthrough);
   for (unsigned i = 0; i != NumIndirectDests; ++i)
diff --git a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
index 1f4893592915f..734a1698d515b 100644
--- a/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
+++ b/llvm/lib/ObjCopy/COFF/COFFWriter.cpp
@@ -317,7 +317,7 @@ void COFFWriter::writeSections() {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    S.Header.PointerToRawData;
     ArrayRef<uint8_t> Contents = S.getContents();
-    std::copy(Contents.begin(), Contents.end(), Ptr);
+    llvm::copy(Contents, Ptr);
 
     // For executable sections, pad the remainder of the raw data size with
     // 0xcc, which is int3 on x86.
@@ -355,7 +355,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // For file symbols, just write the string into the aux symbol slots,
       // assuming that the unwritten parts are initialized to zero in the memory
       // mapped file.
-      std::copy(S.AuxFile.begin(), S.AuxFile.end(), Ptr);
+      llvm::copy(S.AuxFile, Ptr);
       Ptr += S.Sym.NumberOfAuxSymbols * sizeof(SymbolTy);
     } else {
       // For other auxillary symbols, write their opaque payload into one symbol
@@ -364,7 +364,7 @@ template <class SymbolTy> void COFFWriter::writeSymbolStringTables() {
       // entry.
       for (const AuxSymbol &AuxSym : S.AuxData) {
         ArrayRef<uint8_t> Ref = AuxSym.getRef();
-        std::copy(Ref.begin(), Ref.end(), Ptr);
+        llvm::copy(Ref, Ptr);
         Ptr += sizeof(SymbolTy);
       }
     }
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 45c7ea49b5d93..e5de17e093dfd 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -488,7 +488,7 @@ Error ELFSectionWriter<ELFT>::visit(const DecompressedSection &Sec) {
                                  "': " + toString(std::move(E)));
 
   uint8_t *Buf = reinterpret_cast<uint8_t *>(Out.getBufferStart()) + Sec.Offset;
-  std::copy(Decompressed.begin(), Decompressed.end(), Buf);
+  llvm::copy(Decompressed, Buf);
 
   return Error::success();
 }
diff --git a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
index cbc8e471b3090..e9a371ffa926f 100644
--- a/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
+++ b/llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
@@ -161,7 +161,7 @@ static void updateLoadCommandPayloadString(LoadCommand &LC, StringRef S) {
 
   LC.MachOLoadCommand.load_command_data.cmdsize = NewCmdsize;
   LC.Payload.assign(NewCmdsize - sizeof(LCType), 0);
-  std::copy(S.begin(), S.end(), LC.Payload.begin());
+  llvm::copy(S, LC.Payload.begin());
 }
 
 static LoadCommand buildRPathLoadCommand(StringRef Path) {
@@ -172,7 +172,7 @@ static LoadCommand buildRPathLoadCommand(StringRef Path) {
   RPathLC.cmdsize = alignTo(sizeof(MachO::rpath_command) + Path.size() + 1, 8);
   LC.MachOLoadCommand.rpath_command_data = RPathLC;
   LC.Payload.assign(RPathLC.cmdsize - sizeof(MachO::rpath_command), 0);
-  std::copy(Path.begin(), Path.end(), LC.Payload.begin());
+  llvm::copy(Path, LC.Payload.begin());
   return LC;
 }
 
diff --git a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
index bae3128822e22..e8423ff84179b 100644
--- a/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
+++ b/llvm/lib/ObjCopy/XCOFF/XCOFFWriter.cpp
@@ -75,7 +75,7 @@ void XCOFFWriter::writeSections() {
   for (const Section &Sec : Obj.Sections) {
     uint8_t *Ptr = reinterpret_cast<uint8_t *>(Buf->getBufferStart()) +
                    Sec.SectionHeader.FileOffsetToRawData;
-    Ptr = std::copy(Sec.Contents.begin(), Sec.Contents.end(), Ptr);
+    Ptr = llvm::copy(Sec.Contents, Ptr);
   }
 
   // Write relocations.
diff --git a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
index 57fd0f5ad233c..faf5b0fa56539 100644
--- a/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
+++ b/llvm/lib/ObjCopy/wasm/WasmObjcopy.cpp
@@ -47,7 +47,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
       if (!BufferOrErr)
         return createFileError(Filename, BufferOrErr.takeError());
       std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
-      std::copy(Contents.begin(), Contents.end(), Buf->getBufferStart());
+      llvm::copy(Contents, Buf->getBufferStart());
       if (Error E = Buf->commit())
         return createFileError(Filename, std::move(E));
       return Error::success();
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index 1a512ba39ff76..b21197105cbde 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -65,7 +65,7 @@ struct COFFParser {
       StringRef Name = Sec.Name;
 
       if (Name.size() <= COFF::NameSize) {
-        std::copy(Name.begin(), Name.end(), Sec.Header.Name);
+        llvm::copy(Name, Sec.Header.Name);
       } else {
         // Add string to the string table and format the index for output.
         unsigned Index = getStringIndex(Name);
@@ -75,7 +75,7 @@ struct COFFParser {
           return false;
         }
         Sec.Header.Name[0] = '/';
-        std::copy(str.begin(), str.end(), Sec.Header.Name + 1);
+        llvm::copy(str, Sec.Header.Name + 1);
       }
 
       if (Sec.Alignment) {
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 02b0282bbddad..52fa678a600e9 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -1269,11 +1269,11 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
     return OpRef::fail();
 
   if (Vb.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     return Va;
   }
   if (Va.isUndef()) {
-    std::copy(SM.Mask.begin(), SM.Mask.end(), NewMask.begin());
+    llvm::copy(SM.Mask, NewMask.begin());
     ShuffleVectorSDNode::commuteMask(NewMask);
     return Vb;
   }
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 61ba3698a0340..d06796660c444 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1267,14 +1267,14 @@ NewGVN::createAggregateValueExpression(Instruction *I) const {
         AggregateValueExpression(I->getNumOperands(), II->getNumIndices());
     setBasicExpressionInfo(I, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(II->idx_begin(), II->idx_end(), int_op_inserter(E));
+    llvm::copy(II->indices(), int_op_inserter(E));
     return E;
   } else if (auto *EI = dyn_cast<ExtractValueInst>(I)) {
     auto *E = new (ExpressionAllocator)
         AggregateValueExpression(I->getNumOperands(), EI->getNumIndices());
     setBasicExpressionInfo(EI, E);
     E->allocateIntOperands(ExpressionAllocator);
-    std::copy(EI->idx_begin(), EI->idx_end(), int_op_inserter(E));
+    llvm::copy(EI->indices(), int_op_inserter(E));
     return E;
   }
   llvm_unreachable("Unhandled type of aggregate value operation");

@kazutakahirata kazutakahirata merged commit 8ba3a23 into llvm:main Apr 26, 2025
21 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_llvm_copy branch April 26, 2025 22:50
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 26, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve2-vla-2stage running on linaro-g4-02 while building llvm at step 12 "ninja check 2".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/199/builds/3015

Here is the relevant piece of the build log for the reference
Step 12 (ninja check 2) failure: stage 2 checked (failure)
...
[679/1398] Linking CXX executable tools/clang/unittests/Format/FormatTests
clang++: warning: argument unused during compilation: '-mllvm -scalable-vectorization=preferred' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-mllvm -treat-scalable-fixed-error-as-warning=false' [-Wunused-command-line-argument]
[683/1398] Linking CXX executable tools/clang/unittests/AST/ASTTests
clang++: warning: argument unused during compilation: '-mllvm -scalable-vectorization=preferred' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-mllvm -treat-scalable-fixed-error-as-warning=false' [-Wunused-command-line-argument]
[780/1398] Linking CXX executable unittests/BinaryFormat/BinaryFormatTests
clang++: warning: argument unused during compilation: '-mllvm -scalable-vectorization=preferred' [-Wunused-command-line-argument]
clang++: warning: argument unused during compilation: '-mllvm -treat-scalable-fixed-error-as-warning=false' [-Wunused-command-line-argument]
[783/1398] Linking CXX executable unittests/AsmParser/AsmParserTests
FAILED: unittests/AsmParser/AsmParserTests 
: && /home/tcwg-buildbot/worker/clang-aarch64-sve2-vla-2stage/stage1.install/bin/clang++ -mcpu=neoverse-v2 -mllvm -scalable-vectorization=preferred -mllvm -treat-scalable-fixed-error-as-warning=false -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fuse-ld=lld -Wl,--color-diagnostics    -Wl,--gc-sections unittests/AsmParser/CMakeFiles/AsmParserTests.dir/AsmParserTest.cpp.o -o unittests/AsmParser/AsmParserTests  lib/libLLVMAsmParser.a  lib/libLLVMCore.a  lib/libLLVMSupport.a  lib/libLLVMSupport.a  lib/libllvm_gtest_main.a  lib/libllvm_gtest.a  lib/libLLVMRemarks.a  lib/libLLVMBitstreamReader.a  lib/libLLVMBinaryFormat.a  lib/libLLVMTargetParser.a  lib/libLLVMSupport.a  lib/libLLVMDemangle.a  -lrt  -ldl  -lm  /usr/lib/aarch64-linux-gnu/libz.so  -lpthread && :
clang++: error: no such file or directory: 'lib/libllvm_gtest.a'
[829/1398] Building CXX object unittests/CodeGen/CMakeFiles/CodeGenTests.dir/TestAsmPrinter.cpp.o
[831/1398] Building CXX object unittests/ADT/CMakeFiles/ADTTests.dir/SmallVectorTest.cpp.o
[832/1398] Building CXX object unittests/CodeGen/CMakeFiles/CodeGenTests.dir/InstrRefLDVTest.cpp.o
ninja: build stopped: subcommand failed.

jyli0116 pushed a commit to jyli0116/llvm-project that referenced this pull request Apr 28, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants