[llvm] [llvm] Use llvm::copy (NFC) (PR #137470)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 26 13:00:34 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
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
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");
``````````
</details>
https://github.com/llvm/llvm-project/pull/137470
More information about the llvm-commits
mailing list