From cb3e0aa543743f58f527073385ffbdbb96a7f3ca Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sat, 17 Nov 2018 01:44:25 +0000 Subject: [PATCH] Use llvm::copy. NFC llvm-svn: 347126 --- lib/Analysis/LoopAccessAnalysis.cpp | 2 +- lib/Analysis/MemorySSAUpdater.cpp | 2 +- lib/Bitcode/Writer/BitcodeWriter.cpp | 2 +- lib/CodeGen/GlobalISel/IRTranslator.cpp | 2 +- lib/CodeGen/MIRCanonicalizerPass.cpp | 3 +-- lib/CodeGen/MachineFunction.cpp | 2 +- lib/CodeGen/MachineTraceMetrics.cpp | 3 +-- lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 6 +++--- lib/DebugInfo/DWARF/DWARFDebugLoc.cpp | 4 ++-- lib/IR/Attributes.cpp | 4 ++-- lib/IR/Constants.cpp | 2 +- lib/IR/Instructions.cpp | 8 ++++---- lib/IR/Metadata.cpp | 2 +- lib/Object/Object.cpp | 2 +- lib/Object/WindowsResource.cpp | 7 +++---- lib/Support/Path.cpp | 2 +- lib/Support/RandomNumberGenerator.cpp | 2 +- lib/Target/X86/X86ISelLowering.cpp | 4 ++-- .../Instrumentation/ControlHeightReduction.cpp | 2 +- lib/Transforms/Scalar/GVNSink.cpp | 6 +++--- lib/Transforms/Scalar/NewGVN.cpp | 3 +-- tools/llvm-objcopy/ELF/Object.cpp | 10 +++++----- 22 files changed, 38 insertions(+), 42 deletions(-) diff --git a/lib/Analysis/LoopAccessAnalysis.cpp b/lib/Analysis/LoopAccessAnalysis.cpp index 4b8e8afdabb..3c6c2ab9c99 100644 --- a/lib/Analysis/LoopAccessAnalysis.cpp +++ b/lib/Analysis/LoopAccessAnalysis.cpp @@ -420,7 +420,7 @@ void RuntimePointerChecking::groupChecks( // We've computed the grouped checks for this partition. // Save the results and continue with the next one. - std::copy(Groups.begin(), Groups.end(), std::back_inserter(CheckingGroups)); + llvm::copy(Groups, std::back_inserter(CheckingGroups)); } } diff --git a/lib/Analysis/MemorySSAUpdater.cpp b/lib/Analysis/MemorySSAUpdater.cpp index 880dc2f2785..1ac58188bd9 100644 --- a/lib/Analysis/MemorySSAUpdater.cpp +++ b/lib/Analysis/MemorySSAUpdater.cpp @@ -93,7 +93,7 @@ MemoryAccess *MemorySSAUpdater::getPreviousDefRecursive( // FIXME: Figure out whether this is dead code and if so remove it. if (!std::equal(Phi->op_begin(), Phi->op_end(), PhiOps.begin())) { // These will have been filled in by the recursive read we did above. - std::copy(PhiOps.begin(), PhiOps.end(), Phi->op_begin()); + llvm::copy(PhiOps, Phi->op_begin()); std::copy(pred_begin(BB), pred_end(BB), Phi->block_begin()); } } else { diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 31a633584c1..9f6027c34df 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4026,7 +4026,7 @@ void ModuleBitcodeWriter::writeModuleHash(size_t BlockStartPos) { if (ModHash) // Save the written hash value. - std::copy(std::begin(Vals), std::end(Vals), std::begin(*ModHash)); + llvm::copy(Vals, std::begin(*ModHash)); } } diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index 0a41877839a..8ea43dbb3d8 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -215,7 +215,7 @@ ArrayRef IRTranslator::getOrCreateVRegs(const Value &Val) { unsigned Idx = 0; while (auto Elt = C.getAggregateElement(Idx++)) { auto EltRegs = getOrCreateVRegs(*Elt); - std::copy(EltRegs.begin(), EltRegs.end(), std::back_inserter(*VRegs)); + llvm::copy(EltRegs, std::back_inserter(*VRegs)); } } else { assert(SplitTys.size() == 1 && "unexpectedly split LLT"); diff --git a/lib/CodeGen/MIRCanonicalizerPass.cpp b/lib/CodeGen/MIRCanonicalizerPass.cpp index bbd1dcdb744..f17c23619ed 100644 --- a/lib/CodeGen/MIRCanonicalizerPass.cpp +++ b/lib/CodeGen/MIRCanonicalizerPass.cpp @@ -677,8 +677,7 @@ static bool runOnBasicBlock(MachineBasicBlock *MBB, std::vector Candidates = populateCandidates(MBB); std::vector VisitedMIs; - std::copy(Candidates.begin(), Candidates.end(), - std::back_inserter(VisitedMIs)); + llvm::copy(Candidates, std::back_inserter(VisitedMIs)); std::vector VRegs; for (auto candidate : Candidates) { diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 488481cec37..3ded00b70fd 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -435,7 +435,7 @@ MachineFunction::createMIExtraInfo(ArrayRef MMOs, const char *MachineFunction::createExternalSymbolName(StringRef Name) { char *Dest = Allocator.Allocate(Name.size() + 1); - std::copy(Name.begin(), Name.end(), Dest); + llvm::copy(Name, Dest); Dest[Name.size()] = 0; return Dest; } diff --git a/lib/CodeGen/MachineTraceMetrics.cpp b/lib/CodeGen/MachineTraceMetrics.cpp index 79ca6adf95c..e62ed309465 100644 --- a/lib/CodeGen/MachineTraceMetrics.cpp +++ b/lib/CodeGen/MachineTraceMetrics.cpp @@ -218,8 +218,7 @@ computeHeightResources(const MachineBasicBlock *MBB) { // The trace tail is done. if (!TBI->Succ) { TBI->Tail = MBB->getNumber(); - std::copy(PRCycles.begin(), PRCycles.end(), - ProcResourceHeights.begin() + PROffset); + llvm::copy(PRCycles, ProcResourceHeights.begin() + PROffset); return; } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 524a48d03d0..95e499a8b6a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1685,7 +1685,7 @@ SDValue SelectionDAG::getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, // SDNode doesn't have access to it. This memory will be "leaked" when // the node is deallocated, but recovered when the NodeAllocator is released. int *MaskAlloc = OperandAllocator.Allocate(NElts); - std::copy(MaskVec.begin(), MaskVec.end(), MaskAlloc); + llvm::copy(MaskVec, MaskAlloc); auto *N = newSDNode(VT, dl.getIROrder(), dl.getDebugLoc(), MaskAlloc); @@ -7039,7 +7039,7 @@ SDVTList SelectionDAG::getVTList(ArrayRef VTs) { SDVTListNode *Result = VTListMap.FindNodeOrInsertPos(ID, IP); if (!Result) { EVT *Array = Allocator.Allocate(NumVTs); - std::copy(VTs.begin(), VTs.end(), Array); + llvm::copy(VTs, Array); Result = new (Allocator) SDVTListNode(ID.Intern(Allocator), Array, NumVTs); VTListMap.InsertNode(Result, IP); } @@ -7185,7 +7185,7 @@ void SelectionDAG::setNodeMemRefs(MachineSDNode *N, MachineMemOperand **MemRefsBuffer = Allocator.template Allocate(NewMemRefs.size()); - std::copy(NewMemRefs.begin(), NewMemRefs.end(), MemRefsBuffer); + llvm::copy(NewMemRefs, MemRefsBuffer); N->MemRefs = MemRefsBuffer; N->NumMemRefs = static_cast(NewMemRefs.size()); } diff --git a/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp index 6bf711cfdfe..f8b5ff6ec8f 100644 --- a/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp +++ b/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp @@ -124,7 +124,7 @@ DWARFDebugLoc::parseOneLocationList(DWARFDataExtractor Data, unsigned *Offset) { StringRef str = Data.getData().substr(*Offset, Bytes); *Offset += Bytes; E.Loc.reserve(str.size()); - std::copy(str.begin(), str.end(), std::back_inserter(E.Loc)); + llvm::copy(str, std::back_inserter(E.Loc)); LL.Entries.push_back(std::move(E)); } } @@ -189,7 +189,7 @@ DWARFDebugLoclists::parseOneLocationList(DataExtractor Data, unsigned *Offset, StringRef str = Data.getData().substr(*Offset, Bytes); *Offset += Bytes; E.Loc.resize(str.size()); - std::copy(str.begin(), str.end(), E.Loc.begin()); + llvm::copy(str, E.Loc.begin()); } LL.Entries.push_back(std::move(E)); diff --git a/lib/IR/Attributes.cpp b/lib/IR/Attributes.cpp index 63a0f6f22af..cdc13843465 100644 --- a/lib/IR/Attributes.cpp +++ b/lib/IR/Attributes.cpp @@ -639,7 +639,7 @@ LLVM_DUMP_METHOD void AttributeSet::dump() const { AttributeSetNode::AttributeSetNode(ArrayRef Attrs) : AvailableAttrs(0), NumAttrs(Attrs.size()) { // There's memory after the node where we can store the entries in. - std::copy(Attrs.begin(), Attrs.end(), getTrailingObjects()); + llvm::copy(Attrs, getTrailingObjects()); for (const auto I : *this) { if (!I.isStringAttribute()) { @@ -809,7 +809,7 @@ AttributeListImpl::AttributeListImpl(LLVMContext &C, assert(!Sets.empty() && "pointless AttributeListImpl"); // There's memory after the node where we can store the entries in. - std::copy(Sets.begin(), Sets.end(), getTrailingObjects()); + llvm::copy(Sets, getTrailingObjects()); // Initialize AvailableFunctionAttrs summary bitset. static_assert(Attribute::EndAttrKinds <= diff --git a/lib/IR/Constants.cpp b/lib/IR/Constants.cpp index 7368a4c8571..0410c758394 100644 --- a/lib/IR/Constants.cpp +++ b/lib/IR/Constants.cpp @@ -940,7 +940,7 @@ ConstantAggregate::ConstantAggregate(CompositeType *T, ValueTy VT, ArrayRef V) : Constant(T, VT, OperandTraits::op_end(this) - V.size(), V.size()) { - std::copy(V.begin(), V.end(), op_begin()); + llvm::copy(V, op_begin()); // Check that types match, unless this is an opaque struct. if (auto *ST = dyn_cast(T)) diff --git a/lib/IR/Instructions.cpp b/lib/IR/Instructions.cpp index 7d159039c27..4ee91aaf99a 100644 --- a/lib/IR/Instructions.cpp +++ b/lib/IR/Instructions.cpp @@ -275,7 +275,7 @@ void CallInst::init(FunctionType *FTy, Value *Func, ArrayRef Args, "Calling a function with a bad signature!"); #endif - std::copy(Args.begin(), Args.end(), op_begin()); + llvm::copy(Args, op_begin()); auto It = populateBundleOperandInfos(Bundles, Args.size()); (void)It; @@ -577,7 +577,7 @@ void InvokeInst::init(FunctionType *FTy, Value *Fn, BasicBlock *IfNormal, "Invoking a function with a bad signature!"); #endif - std::copy(Args.begin(), Args.end(), op_begin()); + llvm::copy(Args, op_begin()); auto It = populateBundleOperandInfos(Bundles, Args.size()); (void)It; @@ -834,7 +834,7 @@ void CatchSwitchInst::removeHandler(handler_iterator HI) { void FuncletPadInst::init(Value *ParentPad, ArrayRef Args, const Twine &NameStr) { assert(getNumOperands() == 1 + Args.size() && "NumOperands not set up?"); - std::copy(Args.begin(), Args.end(), op_begin()); + llvm::copy(Args, op_begin()); setParentPad(ParentPad); setName(NameStr); } @@ -1390,7 +1390,7 @@ void GetElementPtrInst::init(Value *Ptr, ArrayRef IdxList, assert(getNumOperands() == 1 + IdxList.size() && "NumOperands not initialized?"); Op<0>() = Ptr; - std::copy(IdxList.begin(), IdxList.end(), op_begin() + 1); + llvm::copy(IdxList, op_begin() + 1); setName(Name); } diff --git a/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index 204fecde32c..5536c2497f1 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -1484,7 +1484,7 @@ void GlobalObject::copyMetadata(const GlobalObject *Other, unsigned Offset) { std::vector Elements(OrigElements.size() + 2); Elements[0] = dwarf::DW_OP_plus_uconst; Elements[1] = Offset; - std::copy(OrigElements.begin(), OrigElements.end(), Elements.begin() + 2); + llvm::copy(OrigElements, Elements.begin() + 2); E = DIExpression::get(getContext(), Elements); Attachment = DIGlobalVariableExpression::get(getContext(), GV, E); } diff --git a/lib/Object/Object.cpp b/lib/Object/Object.cpp index c932e5b5504..f5de2e1d5ce 100644 --- a/lib/Object/Object.cpp +++ b/lib/Object/Object.cpp @@ -229,7 +229,7 @@ const char *LLVMGetRelocationTypeName(LLVMRelocationIteratorRef RI) { SmallVector ret; (*unwrap(RI))->getTypeName(ret); char *str = static_cast(safe_malloc(ret.size())); - std::copy(ret.begin(), ret.end(), str); + llvm::copy(ret, str); return str; } diff --git a/lib/Object/WindowsResource.cpp b/lib/Object/WindowsResource.cpp index 1b7282f13db..65413dd8bea 100644 --- a/lib/Object/WindowsResource.cpp +++ b/lib/Object/WindowsResource.cpp @@ -259,7 +259,7 @@ WindowsResourceParser::TreeNode::addChild(ArrayRef NameRef, std::vector EndianCorrectedName; if (sys::IsBigEndianHost) { EndianCorrectedName.resize(NameRef.size() + 1); - std::copy(NameRef.begin(), NameRef.end(), EndianCorrectedName.begin() + 1); + llvm::copy(NameRef, EndianCorrectedName.begin() + 1); EndianCorrectedName[0] = UNI_UTF16_BYTE_ORDER_MARK_SWAPPED; CorrectedName = makeArrayRef(EndianCorrectedName); } else @@ -501,8 +501,7 @@ void WindowsResourceCOFFWriter::writeFirstSection() { void WindowsResourceCOFFWriter::writeSecondSection() { // Now write the .rsrc$02 section. for (auto const &RawDataEntry : Data) { - std::copy(RawDataEntry.begin(), RawDataEntry.end(), - BufferStart + CurrentOffset); + llvm::copy(RawDataEntry, BufferStart + CurrentOffset); CurrentOffset += alignTo(RawDataEntry.size(), sizeof(uint64_t)); } @@ -672,7 +671,7 @@ void WindowsResourceCOFFWriter::writeDirectoryStringTable() { support::endian::write16le(BufferStart + CurrentOffset, Length); CurrentOffset += sizeof(uint16_t); auto *Start = reinterpret_cast(BufferStart + CurrentOffset); - std::copy(String.begin(), String.end(), Start); + llvm::copy(String, Start); CurrentOffset += Length * sizeof(UTF16); TotalStringTableSize += Length * sizeof(UTF16) + sizeof(uint16_t); } diff --git a/lib/Support/Path.cpp b/lib/Support/Path.cpp index 7eba5962774..a3e6941bd62 100644 --- a/lib/Support/Path.cpp +++ b/lib/Support/Path.cpp @@ -533,7 +533,7 @@ void replace_path_prefix(SmallVectorImpl &Path, // If prefixes have the same size we can simply copy the new one over. if (OldPrefix.size() == NewPrefix.size()) { - std::copy(NewPrefix.begin(), NewPrefix.end(), Path.begin()); + llvm::copy(NewPrefix, Path.begin()); return; } diff --git a/lib/Support/RandomNumberGenerator.cpp b/lib/Support/RandomNumberGenerator.cpp index f1f22af82a8..df0d87fab02 100644 --- a/lib/Support/RandomNumberGenerator.cpp +++ b/lib/Support/RandomNumberGenerator.cpp @@ -49,7 +49,7 @@ RandomNumberGenerator::RandomNumberGenerator(StringRef Salt) { Data[0] = Seed; Data[1] = Seed >> 32; - std::copy(Salt.begin(), Salt.end(), Data.begin() + 2); + llvm::copy(Salt, Data.begin() + 2); std::seed_seq SeedSeq(Data.begin(), Data.end()); Generator.seed(SeedSeq); diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 8f422ce524b..5d47d5fb7a6 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -37351,7 +37351,7 @@ static bool isHorizontalBinOp(SDValue &LHS, SDValue &RHS, bool IsCommutative) { if (!LHS.getOperand(1).isUndef()) B = LHS.getOperand(1); ArrayRef Mask = cast(LHS.getNode())->getMask(); - std::copy(Mask.begin(), Mask.end(), LMask.begin()); + llvm::copy(Mask, LMask.begin()); } else { A = LHS; for (unsigned i = 0; i != NumElts; ++i) @@ -37368,7 +37368,7 @@ static bool isHorizontalBinOp(SDValue &LHS, SDValue &RHS, bool IsCommutative) { if (!RHS.getOperand(1).isUndef()) D = RHS.getOperand(1); ArrayRef Mask = cast(RHS.getNode())->getMask(); - std::copy(Mask.begin(), Mask.end(), RMask.begin()); + llvm::copy(Mask, RMask.begin()); } else { C = RHS; for (unsigned i = 0; i != NumElts; ++i) diff --git a/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index 8f4159d3d19..10ad6d5eff6 100644 --- a/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -1416,7 +1416,7 @@ bool CHRScopeSorter(CHRScope *Scope1, CHRScope *Scope2) { void CHR::sortScopes(SmallVectorImpl &Input, SmallVectorImpl &Output) { Output.resize(Input.size()); - std::copy(Input.begin(), Input.end(), Output.begin()); + llvm::copy(Input, Output.begin()); std::stable_sort(Output.begin(), Output.end(), CHRScopeSorter); } diff --git a/lib/Transforms/Scalar/GVNSink.cpp b/lib/Transforms/Scalar/GVNSink.cpp index 187c668c338..1df5f5400c1 100644 --- a/lib/Transforms/Scalar/GVNSink.cpp +++ b/lib/Transforms/Scalar/GVNSink.cpp @@ -258,14 +258,14 @@ public: /// Create a PHI from an array of incoming values and incoming blocks. template ModelledPHI(const VArray &V, const BArray &B) { - std::copy(V.begin(), V.end(), std::back_inserter(Values)); - std::copy(B.begin(), B.end(), std::back_inserter(Blocks)); + llvm::copy(V, std::back_inserter(Values)); + llvm::copy(B, std::back_inserter(Blocks)); } /// Create a PHI from [I[OpNum] for I in Insts]. template ModelledPHI(ArrayRef Insts, unsigned OpNum, const BArray &B) { - std::copy(B.begin(), B.end(), std::back_inserter(Blocks)); + llvm::copy(B, std::back_inserter(Blocks)); for (auto *I : Insts) Values.push_back(I->getOperand(OpNum)); } diff --git a/lib/Transforms/Scalar/NewGVN.cpp b/lib/Transforms/Scalar/NewGVN.cpp index 9803bcb485d..6e9ab448874 100644 --- a/lib/Transforms/Scalar/NewGVN.cpp +++ b/lib/Transforms/Scalar/NewGVN.cpp @@ -3175,8 +3175,7 @@ bool NewGVN::singleReachablePHIPath( auto FilteredPhiArgs = make_filter_range(MP->operands(), ReachableOperandPred); SmallVector OperandList; - std::copy(FilteredPhiArgs.begin(), FilteredPhiArgs.end(), - std::back_inserter(OperandList)); + llvm::copy(FilteredPhiArgs, std::back_inserter(OperandList)); bool Okay = is_splat(OperandList); if (Okay) return singleReachablePHIPath(Visited, cast(OperandList[0]), diff --git a/tools/llvm-objcopy/ELF/Object.cpp b/tools/llvm-objcopy/ELF/Object.cpp index b9d211b58ec..ae02966b730 100644 --- a/tools/llvm-objcopy/ELF/Object.cpp +++ b/tools/llvm-objcopy/ELF/Object.cpp @@ -97,14 +97,14 @@ void SectionWriter::visit(const Section &Sec) { if (Sec.Type == SHT_NOBITS) return; uint8_t *Buf = Out.getBufferStart() + Sec.Offset; - std::copy(std::begin(Sec.Contents), std::end(Sec.Contents), Buf); + llvm::copy(Sec.Contents, Buf); } void Section::accept(SectionVisitor &Visitor) const { Visitor.visit(*this); } void SectionWriter::visit(const OwnedDataSection &Sec) { uint8_t *Buf = Out.getBufferStart() + Sec.Offset; - std::copy(std::begin(Sec.Data), std::end(Sec.Data), Buf); + llvm::copy(Sec.Data, Buf); } static const std::vector ZlibGnuMagic = {'Z', 'L', 'I', 'B'}; @@ -269,7 +269,7 @@ template void ELFSectionWriter::visit(const SectionIndexSection &Sec) { uint8_t *Buf = Out.getBufferStart() + Sec.Offset; auto *IndexesBuffer = reinterpret_cast(Buf); - std::copy(std::begin(Sec.Indexes), std::end(Sec.Indexes), IndexesBuffer); + llvm::copy(Sec.Indexes, IndexesBuffer); } void SectionIndexSection::initialize(SectionTableRef SecTable) { @@ -554,7 +554,7 @@ void RelocationSection::markSymbols() { } void SectionWriter::visit(const DynamicRelocationSection &Sec) { - std::copy(std::begin(Sec.Contents), std::end(Sec.Contents), + llvm::copy(Sec.Contents, Out.getBufferStart() + Sec.Offset); } @@ -641,7 +641,7 @@ void ELFSectionWriter::visit(const GnuDebugLinkSection &Sec) { Elf_Word *CRC = reinterpret_cast(Buf + Sec.Size - sizeof(Elf_Word)); *CRC = Sec.CRC32; - std::copy(std::begin(Sec.FileName), std::end(Sec.FileName), File); + llvm::copy(Sec.FileName, File); } void GnuDebugLinkSection::accept(SectionVisitor &Visitor) const {