diff --git a/llvm/docs/CommandGuide/dsymutil.rst b/llvm/docs/CommandGuide/dsymutil.rst index 6026e2f534ed708..8764e1fbc7a4cef 100644 --- a/llvm/docs/CommandGuide/dsymutil.rst +++ b/llvm/docs/CommandGuide/dsymutil.rst @@ -83,6 +83,10 @@ OPTIONS used in conjunction with ``--update`` option, this option will cause redundant accelerator tables to be removed. +.. option:: --no-object-timestamp + + Don't check timestamp for object files. + .. option:: --no-odr Do not use ODR (One Definition Rule) for uniquing C++ types. diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h index 00efa474a91b57e..b7c6349d38c36ae 100644 --- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h +++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -1389,7 +1389,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase { bool IsUnary = isa(Operands[1]); NumSubElts = VecSrcTy->getElementCount().getKnownMinValue(); - SmallVector AdjustMask(Mask.begin(), Mask.end()); + SmallVector AdjustMask(Mask); // Widening shuffle - widening the source(s) to the new length // (treated as free - see above), and then perform the adjusted diff --git a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h index 24a4accab845a87..5a84fac5f590343 100644 --- a/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h +++ b/llvm/include/llvm/DebugInfo/CodeView/TypeRecord.h @@ -669,8 +669,7 @@ class BuildInfoRecord : public TypeRecord { BuildInfoRecord() = default; explicit BuildInfoRecord(TypeRecordKind Kind) : TypeRecord(Kind) {} BuildInfoRecord(ArrayRef ArgIndices) - : TypeRecord(TypeRecordKind::BuildInfo), - ArgIndices(ArgIndices.begin(), ArgIndices.end()) {} + : TypeRecord(TypeRecordKind::BuildInfo), ArgIndices(ArgIndices) {} ArrayRef getArgs() const { return ArgIndices; } diff --git a/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h b/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h index 1a422fcc0be6ed3..af6d7216b77b547 100644 --- a/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h +++ b/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h @@ -43,7 +43,7 @@ struct RandomIRBuilder { uint64_t MinFunctionNum = 1; RandomIRBuilder(int Seed, ArrayRef AllowedTypes) - : Rand(Seed), KnownTypes(AllowedTypes.begin(), AllowedTypes.end()) {} + : Rand(Seed), KnownTypes(AllowedTypes) {} // TODO: Try to make this a bit less of a random mishmash of functions. diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h index 8ad405ef9cf8386..4331a76d319c843 100644 --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -3986,7 +3986,7 @@ class DIArgList : public Metadata, ReplaceableMetadataImpl { DIArgList(LLVMContext &Context, ArrayRef Args) : Metadata(DIArgListKind, Uniqued), ReplaceableMetadataImpl(Context), - Args(Args.begin(), Args.end()) { + Args(Args) { track(); } ~DIArgList() { untrack(); } diff --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h index 7b54c74fb1b9d7a..495db79362f09b7 100644 --- a/llvm/include/llvm/IR/Metadata.h +++ b/llvm/include/llvm/IR/Metadata.h @@ -1489,8 +1489,7 @@ class MDTuple : public MDNode { TempMDTuple cloneImpl() const { ArrayRef Operands = operands(); - return getTemporary(getContext(), SmallVector( - Operands.begin(), Operands.end())); + return getTemporary(getContext(), SmallVector(Operands)); } public: diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h index ee93cb94100ec4d..dbd217e4aee8d69 100644 --- a/llvm/include/llvm/MC/MCFragment.h +++ b/llvm/include/llvm/MC/MCFragment.h @@ -543,8 +543,7 @@ class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> { ArrayRef> Ranges, StringRef FixedSizePortion) : MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false), - Ranges(Ranges.begin(), Ranges.end()), - FixedSizePortion(FixedSizePortion) {} + Ranges(Ranges), FixedSizePortion(FixedSizePortion) {} ArrayRef> getRanges() const { return Ranges; diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h index cee8e5ef4c25d0b..892865a0a26fea9 100644 --- a/llvm/include/llvm/ProfileData/MemProf.h +++ b/llvm/include/llvm/ProfileData/MemProf.h @@ -352,7 +352,7 @@ struct IndexedAllocationInfo { IndexedAllocationInfo(ArrayRef CS, CallStackId CSId, const MemInfoBlock &MB, const MemProfSchema &Schema = getFullSchema()) - : CallStack(CS.begin(), CS.end()), CSId(CSId), Info(MB, Schema) {} + : CallStack(CS), CSId(CSId), Info(MB, Schema) {} // Returns the size in bytes when this allocation info struct is serialized. size_t serializedSize(const MemProfSchema &Schema, diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index a8e178d6461e032..3e0ef1110363231 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -578,7 +578,7 @@ class DominatorTreeBase { // The PostViewCFG is created with updates reversed (equivalent to changes // made to the CFG), so the PreViewCFG needs all the updates reverse // applied. - SmallVector AllUpdates(Updates.begin(), Updates.end()); + SmallVector AllUpdates(Updates); append_range(AllUpdates, PostViewUpdates); GraphDiff PreViewCFG(AllUpdates, /*ReverseApplyUpdates=*/true); diff --git a/llvm/include/llvm/Support/ScopedPrinter.h b/llvm/include/llvm/Support/ScopedPrinter.h index 675c0ea4457cf26..419ab97366796e2 100644 --- a/llvm/include/llvm/Support/ScopedPrinter.h +++ b/llvm/include/llvm/Support/ScopedPrinter.h @@ -161,7 +161,7 @@ class ScopedPrinter { void printFlags(StringRef Label, T Value, ArrayRef> Flags, TFlag EnumMask1 = {}, TFlag EnumMask2 = {}, TFlag EnumMask3 = {}, ArrayRef ExtraFlags = {}) { - SmallVector SetFlags(ExtraFlags.begin(), ExtraFlags.end()); + SmallVector SetFlags(ExtraFlags); for (const auto &Flag : Flags) { if (Flag.Value == 0) diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp index 0d7eb7da8d6b660..e908be4ad512727 100644 --- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp +++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp @@ -807,7 +807,7 @@ MDNode *AAMDNodes::extendToTBAA(MDNode *MD, ssize_t Len) { // Otherwise, create TBAA with the new Len ArrayRef MDOperands = MD->operands(); - SmallVector NextNodes(MDOperands.begin(), MDOperands.end()); + SmallVector NextNodes(MDOperands); ConstantInt *PreviousSize = mdconst::extract(NextNodes[3]); // Don't create a new MDNode if it is the same length. diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 3460a2a30af91e2..5580146b6ea346c 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -6122,7 +6122,7 @@ static Value *BuildSubAggregate(Value *From, ArrayRef idx_range, Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(), idx_range); Value *To = PoisonValue::get(IndexedType); - SmallVector Idxs(idx_range.begin(), idx_range.end()); + SmallVector Idxs(idx_range); unsigned IdxSkip = Idxs.size(); return BuildSubAggregate(From, To, IndexedType, Idxs, IdxSkip, InsertBefore); diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index b2fdd218e5d4bf1..abd05e316bec148 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -1040,7 +1040,7 @@ AttributeSetNode::AttributeSetNode(ArrayRef Attrs) AttributeSetNode *AttributeSetNode::get(LLVMContext &C, ArrayRef Attrs) { - SmallVector SortedAttrs(Attrs.begin(), Attrs.end()); + SmallVector SortedAttrs(Attrs); llvm::sort(SortedAttrs); return getSorted(C, SortedAttrs); } diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index a1a760a1c6d0850..ea01f81d6965c25 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -1870,7 +1870,7 @@ DIExpression *DIExpression::appendOpsToArg(const DIExpression *Expr, [](auto Op) { return Op.getOp() == dwarf::DW_OP_LLVM_arg; })) { assert(ArgNo == 0 && "Location Index must be 0 for a non-variadic expression."); - SmallVector NewOps(Ops.begin(), Ops.end()); + SmallVector NewOps(Ops); return DIExpression::prependOpcodes(Expr, NewOps, StackValue); } diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index beab194a52b8177..3a6c2678cd157f1 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -1371,8 +1371,7 @@ Error IRLinker::linkModuleFlagsMetadata() { return dyn_cast(DstValue); ArrayRef DstOperands = DstValue->operands(); MDTuple *New = MDTuple::getDistinct( - DstM.getContext(), - SmallVector(DstOperands.begin(), DstOperands.end())); + DstM.getContext(), SmallVector(DstOperands)); Metadata *FlagOps[] = {DstOp->getOperand(0), ID, New}; MDNode *Flag = MDTuple::getDistinct(DstM.getContext(), FlagOps); DstModFlags->setOperand(DstIndex, Flag); diff --git a/llvm/lib/Object/BuildID.cpp b/llvm/lib/Object/BuildID.cpp index ef21458060abd6c..d3c58a919731fff 100644 --- a/llvm/lib/Object/BuildID.cpp +++ b/llvm/lib/Object/BuildID.cpp @@ -50,7 +50,7 @@ BuildID llvm::object::parseBuildID(StringRef Str) { return {}; ArrayRef BuildID(reinterpret_cast(Bytes.data()), Bytes.size()); - return SmallVector(BuildID.begin(), BuildID.end()); + return SmallVector(BuildID); } BuildIDRef llvm::object::getBuildID(const ObjectFile *Obj) { diff --git a/llvm/lib/Support/SourceMgr.cpp b/llvm/lib/Support/SourceMgr.cpp index b8bf02d59675d1e..4a69ccc7605bc3b 100644 --- a/llvm/lib/Support/SourceMgr.cpp +++ b/llvm/lib/Support/SourceMgr.cpp @@ -398,7 +398,7 @@ SMDiagnostic::SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN, int Line, ArrayRef Hints) : SM(&sm), Loc(L), Filename(std::string(FN)), LineNo(Line), ColumnNo(Col), Kind(Kind), Message(Msg), LineContents(LineStr), Ranges(Ranges.vec()), - FixIts(Hints.begin(), Hints.end()) { + FixIts(Hints) { llvm::sort(FixIts); } diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index f394f004ec7d9ec..be80e60ef2e1054 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -611,7 +611,7 @@ class CombiningDirIterImpl : public llvm::vfs::detail::DirIterImpl { CombiningDirIterImpl(ArrayRef DirIters, std::error_code &EC) - : IterList(DirIters.begin(), DirIters.end()) { + : IterList(DirIters) { EC = incrementImpl(true); } diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp index 7aeaebc584c64cc..856c952e785dac4 100644 --- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp @@ -2274,7 +2274,7 @@ HexagonTargetLowering::LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) // Normalize the mask so that the first non-negative index comes from // the first operand. - SmallVector Mask(AM.begin(), AM.end()); + SmallVector Mask(AM); unsigned F = llvm::find_if(AM, [](int M) { return M >= 0; }) - AM.data(); if (F == AM.size()) return DAG.getUNDEF(VecTy); diff --git a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp index 81035849491bcb2..cdccc18403771f4 100644 --- a/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp +++ b/llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp @@ -1725,7 +1725,7 @@ HexagonTargetLowering::LowerHvxConcatVectors(SDValue Op, SelectionDAG &DAG) return DAG.getNode(HexagonISD::QCAT, dl, VecTy, Op0, Op.getOperand(1)); ArrayRef U(Op.getNode()->ops()); - SmallVector SV(U.begin(), U.end()); + SmallVector SV(U); ArrayRef Ops(SV); MVT HalfTy = typeSplit(VecTy).first; @@ -2128,7 +2128,7 @@ SDValue HexagonTargetLowering::LowerHvxIntrinsic(SDValue Op, SelectionDAG &DAG) const { const SDLoc &dl(Op); unsigned IntNo = Op.getConstantOperandVal(0); - SmallVector Ops(Op->ops().begin(), Op->ops().end()); + SmallVector Ops(Op->ops()); auto Swap = [&](SDValue P) { return DAG.getMergeValues({P.getValue(1), P.getValue(0)}, dl); @@ -3589,7 +3589,7 @@ HexagonTargetLowering::PerformHvxDAGCombine(SDNode *N, DAGCombinerInfo &DCI) SDValue Op(N, 0); unsigned Opc = Op.getOpcode(); - SmallVector Ops(N->ops().begin(), N->ops().end()); + SmallVector Ops(N->ops()); if (Opc == ISD::TRUNCATE) return combineTruncateBeforeLegal(Op, DCI); diff --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp index 847646a00a9f674..2e66c81c3324492 100644 --- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp @@ -2691,7 +2691,7 @@ auto HexagonVectorCombine::joinVectorElements(IRBuilderBase &Builder, // joins, the shuffles will hopefully be folded into a perfect shuffle. // The output will need to be sign-extended to a type with element width // being a power-of-2 anyways. - SmallVector Inputs(Values.begin(), Values.end()); + SmallVector Inputs(Values); unsigned ToWidth = ToType->getScalarSizeInBits(); unsigned Width = Inputs.front()->getType()->getScalarSizeInBits(); diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 7ca8f77032b102f..298cc86d8ae49d9 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -4292,7 +4292,7 @@ static SDValue getAVX512Node(unsigned Opcode, const SDLoc &DL, MVT VT, DstVT = MVT::getVectorVT(SVT, 512 / SVT.getSizeInBits()); // Canonicalize src operands. - SmallVector SrcOps(Ops.begin(), Ops.end()); + SmallVector SrcOps(Ops); for (SDValue &Op : SrcOps) { MVT OpVT = Op.getSimpleValueType(); // Just pass through scalar operands. @@ -39292,7 +39292,7 @@ static SDValue combineX86ShuffleChainWithExtract( // Attempt to peek through inputs and adjust mask when we extract from an // upper subvector. int AdjustedMasks = 0; - SmallVector WideInputs(Inputs.begin(), Inputs.end()); + SmallVector WideInputs(Inputs); for (unsigned I = 0; I != NumInputs; ++I) { SDValue &Input = WideInputs[I]; Input = peekThroughBitcasts(Input); @@ -39977,8 +39977,7 @@ static SDValue combineX86ShufflesRecursively( HasVariableMask |= IsOpVariableMask; // Update the list of shuffle nodes that have been combined so far. - SmallVector CombinedNodes(SrcNodes.begin(), - SrcNodes.end()); + SmallVector CombinedNodes(SrcNodes); CombinedNodes.push_back(Op.getNode()); // See if we can recurse into each shuffle source op (if it's a target diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp index 6f8ce174ea4daec..07389a5ffb2b8a2 100644 --- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -312,7 +312,7 @@ int llvm::libDriverMain(ArrayRef ArgsArr) { StringSaver Saver(Alloc); // Parse command line arguments. - SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end()); + SmallVector NewArgs(ArgsArr); cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs); ArgsArr = NewArgs; diff --git a/llvm/test/tools/dsymutil/X86/timestamp-mismatch.test b/llvm/test/tools/dsymutil/X86/timestamp-mismatch.test index e75a7f1ddde3d98..4665c75cfe0b7d6 100644 --- a/llvm/test/tools/dsymutil/X86/timestamp-mismatch.test +++ b/llvm/test/tools/dsymutil/X86/timestamp-mismatch.test @@ -3,10 +3,14 @@ RUN: cp %p/../Inputs/basic.macho.x86_64 %t/Inputs RUN: cp %p/../Inputs/basic1.macho.x86_64.o %t/Inputs RUN: cp %p/../Inputs/basic2.macho.x86_64.o %t/Inputs RUN: cp %p/../Inputs/basic3.macho.x86_64.o %t/Inputs -RUN: dsymutil -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s +RUN: dsymutil -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s --check-prefix=WARN +RUN: dsymutil -no-object-timestamp -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s --allow-empty --check-prefix=NOWARN -RUN: dsymutil --linker parallel -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s +RUN: dsymutil --linker parallel -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s --check-prefix=WARN +RUN: dsymutil --linker parallel -no-object-timestamp -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 -o %t.dSYM 2>&1 | FileCheck %s --allow-empty --check-prefix=NOWARN -CHECK: warning: {{.*}}/Inputs/basic1.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) -CHECK: warning: {{.*}}/Inputs/basic2.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) -CHECK: warning: {{.*}}/Inputs/basic3.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) +WARN: warning: {{.*}}/Inputs/basic1.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) +WARN: warning: {{.*}}/Inputs/basic2.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) +WARN: warning: {{.*}}/Inputs/basic3.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) + +NOWARN-NOT: warning: {{.*}}/Inputs/basic3.macho.x86_64.o: timestamp mismatch between object file ({{.*}}) and debug map ({{.*}}) diff --git a/llvm/test/tools/dsymutil/cmdline.test b/llvm/test/tools/dsymutil/cmdline.test index 6c67ac7cd723873..1574fe35f52546e 100644 --- a/llvm/test/tools/dsymutil/cmdline.test +++ b/llvm/test/tools/dsymutil/cmdline.test @@ -15,6 +15,7 @@ CHECK: -flat CHECK: -gen-reproducer CHECK: -help CHECK: -keep-function-for-static +CHECK: -no-object-timestamp CHECK: -no-odr CHECK: -no-output CHECK: -no-swiftmodule-timestamp diff --git a/llvm/tools/dsymutil/BinaryHolder.cpp b/llvm/tools/dsymutil/BinaryHolder.cpp index 646fe4fc8f8043f..5daaa6755b2957f 100644 --- a/llvm/tools/dsymutil/BinaryHolder.cpp +++ b/llvm/tools/dsymutil/BinaryHolder.cpp @@ -41,9 +41,13 @@ getMachOFatMemoryBuffers(StringRef Filename, MemoryBuffer &Mem, return Buffers; } +BinaryHolder::BinaryHolder(IntrusiveRefCntPtr VFS, + BinaryHolder::Options Opts) + : VFS(VFS), Opts(Opts) {} + Error BinaryHolder::ArchiveEntry::load(IntrusiveRefCntPtr VFS, StringRef Filename, - TimestampTy Timestamp, bool Verbose) { + TimestampTy Timestamp, Options Opts) { StringRef ArchiveFilename = getArchiveAndObjectName(Filename).first; // Try to load archive and force it to be memory mapped. @@ -55,7 +59,7 @@ Error BinaryHolder::ArchiveEntry::load(IntrusiveRefCntPtr VFS, MemBuffer = std::move(*ErrOrBuff); - if (Verbose) + if (Opts.Verbose) WithColor::note() << "loaded archive '" << ArchiveFilename << "'\n"; // Load one or more archive buffers, depending on whether we're dealing with @@ -88,7 +92,7 @@ Error BinaryHolder::ArchiveEntry::load(IntrusiveRefCntPtr VFS, Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr VFS, StringRef Filename, TimestampTy Timestamp, - bool Verbose) { + Options Opts) { // Try to load regular binary and force it to be memory mapped. auto ErrOrBuff = (Filename == "-") ? MemoryBuffer::getSTDIN() @@ -96,7 +100,7 @@ Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr VFS, if (auto Err = ErrOrBuff.getError()) return errorCodeToError(Err); - if (Filename != "-" && Timestamp != sys::TimePoint<>()) { + if (Opts.Warn && Filename != "-" && Timestamp != sys::TimePoint<>()) { llvm::ErrorOr Stat = VFS->status(Filename); if (!Stat) return errorCodeToError(Stat.getError()); @@ -110,7 +114,7 @@ Error BinaryHolder::ObjectEntry::load(IntrusiveRefCntPtr VFS, MemBuffer = std::move(*ErrOrBuff); - if (Verbose) + if (Opts.Verbose) WithColor::note() << "loaded object.\n"; // Load one or more object buffers, depending on whether we're dealing with a @@ -164,7 +168,7 @@ BinaryHolder::ObjectEntry::getObject(const Triple &T) const { Expected BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, TimestampTy Timestamp, - bool Verbose) { + Options Opts) { StringRef ArchiveFilename; StringRef ObjectFilename; std::tie(ArchiveFilename, ObjectFilename) = getArchiveAndObjectName(Filename); @@ -192,7 +196,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, if (Timestamp != sys::TimePoint<>() && Timestamp != std::chrono::time_point_cast( ModTimeOrErr.get())) { - if (Verbose) + if (Opts.Verbose) WithColor::warning() << *NameOrErr << ": timestamp mismatch between archive member (" @@ -201,7 +205,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, continue; } - if (Verbose) + if (Opts.Verbose) WithColor::note() << "found member in archive.\n"; auto ErrOrMem = Child.getMemoryBufferRef(); @@ -230,7 +234,7 @@ BinaryHolder::ArchiveEntry::getObjectEntry(StringRef Filename, Expected BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) { - if (Verbose) + if (Opts.Verbose) WithColor::note() << "trying to open '" << Filename << "'\n"; // If this is an archive, we might have either the object or the archive @@ -241,17 +245,17 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) { ArchiveRefCounter[ArchiveFilename]++; if (ArchiveCache.count(ArchiveFilename)) { return ArchiveCache[ArchiveFilename]->getObjectEntry(Filename, Timestamp, - Verbose); + Opts); } else { auto AE = std::make_unique(); - auto Err = AE->load(VFS, Filename, Timestamp, Verbose); + auto Err = AE->load(VFS, Filename, Timestamp, Opts); if (Err) { // Don't return the error here: maybe the file wasn't an archive. llvm::consumeError(std::move(Err)); } else { ArchiveCache[ArchiveFilename] = std::move(AE); - return ArchiveCache[ArchiveFilename]->getObjectEntry( - Filename, Timestamp, Verbose); + return ArchiveCache[ArchiveFilename]->getObjectEntry(Filename, + Timestamp, Opts); } } } @@ -262,7 +266,7 @@ BinaryHolder::getObjectEntry(StringRef Filename, TimestampTy Timestamp) { ObjectRefCounter[Filename]++; if (!ObjectCache.count(Filename)) { auto OE = std::make_unique(); - auto Err = OE->load(VFS, Filename, Timestamp, Verbose); + auto Err = OE->load(VFS, Filename, Timestamp, Opts); if (Err) return std::move(Err); ObjectCache[Filename] = std::move(OE); @@ -279,7 +283,7 @@ void BinaryHolder::clear() { } void BinaryHolder::eraseObjectEntry(StringRef Filename) { - if (Verbose) + if (Opts.Verbose) WithColor::note() << "erasing '" << Filename << "' from cache\n"; if (isArchive(Filename)) { diff --git a/llvm/tools/dsymutil/BinaryHolder.h b/llvm/tools/dsymutil/BinaryHolder.h index c4fc5a6110e775e..cb5bd959781440f 100644 --- a/llvm/tools/dsymutil/BinaryHolder.h +++ b/llvm/tools/dsymutil/BinaryHolder.h @@ -38,8 +38,15 @@ class BinaryHolder { public: using TimestampTy = sys::TimePoint; - BinaryHolder(IntrusiveRefCntPtr VFS, bool Verbose = false) - : VFS(VFS), Verbose(Verbose) {} + struct Options { + Options(bool Verbose = false, bool Warn = true) + : Verbose(Verbose), Warn(Warn) {} + bool Verbose; + bool Warn; + }; + + BinaryHolder(IntrusiveRefCntPtr VFS, + BinaryHolder::Options Opts = {}); // Forward declarations for friend declaration. class ObjectEntry; @@ -58,7 +65,7 @@ class BinaryHolder { public: /// Load the given object binary in memory. Error load(IntrusiveRefCntPtr VFS, StringRef Filename, - TimestampTy Timestamp, bool Verbose = false); + TimestampTy Timestamp, BinaryHolder::Options = {}); /// Access all owned ObjectFiles. std::vector getObjects() const; @@ -110,11 +117,11 @@ class BinaryHolder { /// Load the given object binary in memory. Error load(IntrusiveRefCntPtr VFS, StringRef Filename, - TimestampTy Timestamp, bool Verbose = false); + TimestampTy Timestamp, BinaryHolder::Options = {}); Expected getObjectEntry(StringRef Filename, TimestampTy Timestamp, - bool Verbose = false); + BinaryHolder::Options = {}); private: std::vector> Archives; @@ -143,7 +150,7 @@ class BinaryHolder { /// Virtual File System instance. IntrusiveRefCntPtr VFS; - bool Verbose; + Options Opts; }; } // namespace dsymutil diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp index 8724b70422f3260..b38d502dda7c970 100644 --- a/llvm/tools/dsymutil/DebugMap.cpp +++ b/llvm/tools/dsymutil/DebugMap.cpp @@ -126,6 +126,9 @@ void DebugMap::dump() const { print(errs()); } namespace { struct YAMLContext { + YAMLContext(BinaryHolder &BinHolder, StringRef PrependPath) + : BinHolder(BinHolder), PrependPath(PrependPath) {} + BinaryHolder &BinHolder; StringRef PrependPath; Triple BinaryTriple; }; @@ -133,15 +136,13 @@ struct YAMLContext { } // end anonymous namespace ErrorOr>> -DebugMap::parseYAMLDebugMap(StringRef InputFile, StringRef PrependPath, - bool Verbose) { +DebugMap::parseYAMLDebugMap(BinaryHolder &BinHolder, StringRef InputFile, + StringRef PrependPath, bool Verbose) { auto ErrOrFile = MemoryBuffer::getFileOrSTDIN(InputFile); if (auto Err = ErrOrFile.getError()) return Err; - YAMLContext Ctxt; - - Ctxt.PrependPath = PrependPath; + YAMLContext Ctxt(BinHolder, PrependPath); std::unique_ptr Res; yaml::Input yin((*ErrOrFile)->getBuffer(), &Ctxt); @@ -244,14 +245,13 @@ MappingTraits::YamlDMO::YamlDMO( dsymutil::DebugMapObject MappingTraits::YamlDMO::denormalize(IO &IO) { - BinaryHolder BinHolder(vfs::getRealFileSystem(), /* Verbose =*/false); const auto &Ctxt = *reinterpret_cast(IO.getContext()); SmallString<80> Path(Ctxt.PrependPath); StringMap SymbolAddresses; sys::path::append(Path, Filename); - auto ObjectEntry = BinHolder.getObjectEntry(Path); + auto ObjectEntry = Ctxt.BinHolder.getObjectEntry(Path); if (!ObjectEntry) { auto Err = ObjectEntry.takeError(); WithColor::warning() << "Unable to open " << Path << " " diff --git a/llvm/tools/dsymutil/DebugMap.h b/llvm/tools/dsymutil/DebugMap.h index 9c3a698fa1191d0..8e2a4de94c89efe 100644 --- a/llvm/tools/dsymutil/DebugMap.h +++ b/llvm/tools/dsymutil/DebugMap.h @@ -21,6 +21,7 @@ #ifndef LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H #define LLVM_TOOLS_DSYMUTIL_DEBUGMAP_H +#include "BinaryHolder.h" #include "RelocationMap.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringMap.h" @@ -127,7 +128,8 @@ class DebugMap { /// Read a debug map for \a InputFile. static ErrorOr>> - parseYAMLDebugMap(StringRef InputFile, StringRef PrependPath, bool Verbose); + parseYAMLDebugMap(BinaryHolder &BinHolder, StringRef InputFile, + StringRef PrependPath, bool Verbose); }; /// The DebugMapObject represents one object file described by the DebugMap. It diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp index e28c976d6ace342..d4d43858be7fdc7 100644 --- a/llvm/tools/dsymutil/MachODebugMapParser.cpp +++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp @@ -27,15 +27,14 @@ using namespace llvm::object; class MachODebugMapParser { public: - MachODebugMapParser(llvm::IntrusiveRefCntPtr VFS, - StringRef BinaryPath, ArrayRef Archs, + MachODebugMapParser(BinaryHolder &BinHolder, StringRef BinaryPath, + ArrayRef Archs, ArrayRef DSYMSearchPaths, StringRef PathPrefix = "", StringRef VariantSuffix = "", bool Verbose = false) - : BinaryPath(std::string(BinaryPath)), Archs(Archs.begin(), Archs.end()), - DSYMSearchPaths(DSYMSearchPaths.begin(), DSYMSearchPaths.end()), - PathPrefix(std::string(PathPrefix)), - VariantSuffix(std::string(VariantSuffix)), BinHolder(VFS, Verbose), + : BinaryPath(std::string(BinaryPath)), Archs(Archs), + DSYMSearchPaths(DSYMSearchPaths), PathPrefix(std::string(PathPrefix)), + VariantSuffix(std::string(VariantSuffix)), BinHolder(BinHolder), CurrentDebugMapObject(nullptr), SkipDebugMapObject(false) {} /// Parses and returns the DebugMaps of the input binary. The binary contains @@ -57,7 +56,7 @@ class MachODebugMapParser { std::string VariantSuffix; /// Owns the MemoryBuffer for the main binary. - BinaryHolder BinHolder; + BinaryHolder &BinHolder; /// Map of the binary symbol addresses. StringMap MainBinarySymbolAddresses; StringRef MainBinaryStrings; @@ -855,24 +854,25 @@ void MachODebugMapParser::loadMainBinarySymbols( namespace llvm { namespace dsymutil { llvm::ErrorOr>> -parseDebugMap(llvm::IntrusiveRefCntPtr VFS, - StringRef InputFile, ArrayRef Archs, +parseDebugMap(BinaryHolder &BinHolder, StringRef InputFile, + ArrayRef Archs, ArrayRef DSYMSearchPaths, StringRef PrependPath, StringRef VariantSuffix, bool Verbose, bool InputIsYAML) { if (InputIsYAML) - return DebugMap::parseYAMLDebugMap(InputFile, PrependPath, Verbose); + return DebugMap::parseYAMLDebugMap(BinHolder, InputFile, PrependPath, + Verbose); - MachODebugMapParser Parser(VFS, InputFile, Archs, DSYMSearchPaths, + MachODebugMapParser Parser(BinHolder, InputFile, Archs, DSYMSearchPaths, PrependPath, VariantSuffix, Verbose); return Parser.parse(); } -bool dumpStab(llvm::IntrusiveRefCntPtr VFS, - StringRef InputFile, ArrayRef Archs, +bool dumpStab(BinaryHolder &BinHolder, StringRef InputFile, + ArrayRef Archs, ArrayRef DSYMSearchPaths, StringRef PrependPath, StringRef VariantSuffix) { - MachODebugMapParser Parser(VFS, InputFile, Archs, DSYMSearchPaths, + MachODebugMapParser Parser(BinHolder, InputFile, Archs, DSYMSearchPaths, PrependPath, VariantSuffix, false); return Parser.dumpStab(); } diff --git a/llvm/tools/dsymutil/Options.td b/llvm/tools/dsymutil/Options.td index b72ae1909a7274d..dcf33add42b842c 100644 --- a/llvm/tools/dsymutil/Options.td +++ b/llvm/tools/dsymutil/Options.td @@ -65,6 +65,10 @@ def no_swiftmodule_timestamp: F<"no-swiftmodule-timestamp">, HelpText<"Don't check timestamp for swiftmodule files.">, Group; +def no_object_timestamp: F<"no-object-timestamp">, + HelpText<"Don't check timestamp for object files.">, + Group; + def no_odr: F<"no-odr">, HelpText<"Do not use ODR (One Definition Rule) for type uniquing.">, Group; diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp index 728f2ed3e62aca0..d45f0f09d755a9b 100644 --- a/llvm/tools/dsymutil/dsymutil.cpp +++ b/llvm/tools/dsymutil/dsymutil.cpp @@ -108,6 +108,7 @@ struct DsymutilOptions { bool Flat = false; bool InputIsYAMLDebugMap = false; bool ForceKeepFunctionForStatic = false; + bool NoObjectTimestamp = false; std::string OutputFile; std::string Toolchain; std::string ReproducerPath; @@ -180,17 +181,6 @@ static Error verifyOptions(const DsymutilOptions &Options) { errc::invalid_argument); } - if (Options.LinkOpts.Update && llvm::is_contained(Options.InputFiles, "-")) { - // FIXME: We cannot use stdin for an update because stdin will be - // consumed by the BinaryHolder during the debugmap parsing, and - // then we will want to consume it again in DwarfLinker. If we - // used a unique BinaryHolder object that could cache multiple - // binaries this restriction would go away. - return make_error( - "standard input cannot be used as input for a dSYM update.", - errc::invalid_argument); - } - if (!Options.Flat && Options.OutputFile == "-") return make_error( "cannot emit to standard output without --flat.", @@ -303,6 +293,7 @@ static Expected getOptions(opt::InputArgList &Args) { Options.DumpStab = Args.hasArg(OPT_symtab); Options.Flat = Args.hasArg(OPT_flat); Options.InputIsYAMLDebugMap = Args.hasArg(OPT_yaml_input); + Options.NoObjectTimestamp = Args.hasArg(OPT_no_object_timestamp); if (Expected Verify = getVerifyKind(Args)) { Options.Verify = *Verify; @@ -674,9 +665,15 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) { } for (auto &InputFile : Options.InputFiles) { + // Shared a single binary holder for all the link steps. + BinaryHolder::Options BinOpts; + BinOpts.Verbose = Options.LinkOpts.Verbose; + BinOpts.Warn = !Options.NoObjectTimestamp; + BinaryHolder BinHolder(Options.LinkOpts.VFS, BinOpts); + // Dump the symbol table for each input file and requested arch if (Options.DumpStab) { - if (!dumpStab(Options.LinkOpts.VFS, InputFile, Options.Archs, + if (!dumpStab(BinHolder, InputFile, Options.Archs, Options.LinkOpts.DSYMSearchPaths, Options.LinkOpts.PrependPath, Options.LinkOpts.BuildVariantSuffix)) @@ -685,10 +682,9 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) { } auto DebugMapPtrsOrErr = parseDebugMap( - Options.LinkOpts.VFS, InputFile, Options.Archs, - Options.LinkOpts.DSYMSearchPaths, Options.LinkOpts.PrependPath, - Options.LinkOpts.BuildVariantSuffix, Options.LinkOpts.Verbose, - Options.InputIsYAMLDebugMap); + BinHolder, InputFile, Options.Archs, Options.LinkOpts.DSYMSearchPaths, + Options.LinkOpts.PrependPath, Options.LinkOpts.BuildVariantSuffix, + Options.LinkOpts.Verbose, Options.InputIsYAMLDebugMap); if (auto EC = DebugMapPtrsOrErr.getError()) { WithColor::error() << "cannot parse the debug map for '" << InputFile @@ -714,9 +710,6 @@ int dsymutil_main(int argc, char **argv, const llvm::ToolContext &) { return EXIT_FAILURE; } - // Shared a single binary holder for all the link steps. - BinaryHolder BinHolder(Options.LinkOpts.VFS); - // Compute the output location and update the resource directory. Expected OutputLocationOrErr = getOutputFileName(InputFile, Options); diff --git a/llvm/tools/dsymutil/dsymutil.h b/llvm/tools/dsymutil/dsymutil.h index 5504dd57c7e558a..7b97b8bcd3a2506 100644 --- a/llvm/tools/dsymutil/dsymutil.h +++ b/llvm/tools/dsymutil/dsymutil.h @@ -16,6 +16,7 @@ #ifndef LLVM_TOOLS_DSYMUTIL_DSYMUTIL_H #define LLVM_TOOLS_DSYMUTIL_DSYMUTIL_H +#include "BinaryHolder.h" #include "DebugMap.h" #include "LinkUtils.h" #include "llvm/ADT/ArrayRef.h" @@ -33,14 +34,14 @@ namespace dsymutil { /// The file has to be a MachO object file. Multiple debug maps can be /// returned when the file is universal (aka fat) binary. ErrorOr>> -parseDebugMap(llvm::IntrusiveRefCntPtr VFS, - StringRef InputFile, ArrayRef Archs, +parseDebugMap(BinaryHolder &BinHolder, StringRef InputFile, + ArrayRef Archs, ArrayRef DSYMSearchPaths, StringRef PrependPath, StringRef VariantSuffix, bool Verbose, bool InputIsYAML); /// Dump the symbol table. -bool dumpStab(llvm::IntrusiveRefCntPtr VFS, - StringRef InputFile, ArrayRef Archs, +bool dumpStab(BinaryHolder &BinHolder, StringRef InputFile, + ArrayRef Archs, ArrayRef DSYMSearchPaths, StringRef PrependPath = "", StringRef VariantSuffix = ""); diff --git a/llvm/tools/llvm-rc/ResourceScriptStmt.h b/llvm/tools/llvm-rc/ResourceScriptStmt.h index 0d8ec3e5b7875b1..8f099202c0b47b5 100644 --- a/llvm/tools/llvm-rc/ResourceScriptStmt.h +++ b/llvm/tools/llvm-rc/ResourceScriptStmt.h @@ -875,7 +875,7 @@ class VersionInfoResource : public RCResource { VersionInfoFixed() : IsTypePresent(FtNumTypes, false) {} void setValue(VersionInfoFixedType Type, ArrayRef Value) { - FixedInfo[Type] = SmallVector(Value.begin(), Value.end()); + FixedInfo[Type] = SmallVector(Value); IsTypePresent[Type] = true; } diff --git a/llvm/unittests/Analysis/VectorUtilsTest.cpp b/llvm/unittests/Analysis/VectorUtilsTest.cpp index 48b4d37558af17a..fca1ecff9ea8d0c 100644 --- a/llvm/unittests/Analysis/VectorUtilsTest.cpp +++ b/llvm/unittests/Analysis/VectorUtilsTest.cpp @@ -607,8 +607,7 @@ class VFShapeAPITest : public testing::Test { } bool validParams(ArrayRef Parameters) { - Shape.Parameters = - SmallVector(Parameters.begin(), Parameters.end()); + Shape.Parameters = SmallVector(Parameters); return Shape.hasValidParameterList(); } }; diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp index f241d47bbc0b5ec..617a0d1ec0cceb7 100644 --- a/llvm/unittests/Support/VirtualFileSystemTest.cpp +++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp @@ -766,7 +766,7 @@ TEST(VirtualFileSystemTest, BrokenSymlinkRealFSRecursiveIteration) { template static void checkContents(DirIter I, ArrayRef ExpectedOut) { std::error_code EC; - SmallVector Expected(ExpectedOut.begin(), ExpectedOut.end()); + SmallVector Expected(ExpectedOut); SmallVector InputToCheck; // Do not rely on iteration order to check for contents, sort both