llvm.org GIT mirror llvm / e5eb673
Apply another batch of fixes from clang-tidy's performance-unnecessary-value-param. Contains some manual fixes. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273047 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 3 years ago
20 changed file(s) with 79 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
7070 LLVMContext &Context);
7171
7272 /// Check if the given bitcode buffer contains a summary block.
73 bool hasGlobalValueSummary(MemoryBufferRef Buffer,
74 DiagnosticHandlerFunction DiagnosticHandler);
73 bool
74 hasGlobalValueSummary(MemoryBufferRef Buffer,
75 const DiagnosticHandlerFunction &DiagnosticHandler);
7576
7677 /// Parse the specified bitcode buffer, returning the module summary index.
7778 ErrorOr>
7879 getModuleSummaryIndex(MemoryBufferRef Buffer,
79 DiagnosticHandlerFunction DiagnosticHandler);
80 const DiagnosticHandlerFunction &DiagnosticHandler);
8081
8182 /// \brief Write the specified module to the specified raw output stream.
8283 ///
564564 typedef iterator_range value_range;
565565 typedef iterator_range const_value_range;
566566
567 value_iterator addValue(BumpPtrAllocator &Alloc, DIEValue V) {
567 value_iterator addValue(BumpPtrAllocator &Alloc, const DIEValue &V) {
568568 List.push_back(*new (Alloc) Node(V));
569569 return value_iterator(ListTy::toIterator(List.back()));
570570 }
13811381 void *&InsertPos);
13821382 SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef Ops,
13831383 void *&InsertPos);
1384 SDNode *UpdadeSDLocOnMergedSDNode(SDNode *N, SDLoc loc);
1384 SDNode *UpdadeSDLocOnMergedSDNode(SDNode *N, const SDLoc &loc);
13851385
13861386 void DeleteNodeNotInCSEMaps(SDNode *N);
13871387 void DeallocateNode(SDNode *N);
477477 /// specified function pointer is invoked to create it. If it returns null,
478478 /// the JIT will abort.
479479 void InstallLazyFunctionCreator(FunctionCreator C) {
480 LazyFunctionCreator = C;
480 LazyFunctionCreator = std::move(C);
481481 }
482482
483483 protected:
484 ExecutionEngine(const DataLayout DL) : DL(std::move(DL)){}
484 ExecutionEngine(DataLayout DL) : DL(std::move(DL)) {}
485485 explicit ExecutionEngine(DataLayout DL, std::unique_ptr M);
486486 explicit ExecutionEngine(std::unique_ptr M);
487487
8080
8181 /// \brief Looks for summary sections in the given memory buffer,
8282 /// returns true if found, else false.
83 static bool
84 hasGlobalValueSummaryInMemBuffer(MemoryBufferRef Object,
85 DiagnosticHandlerFunction DiagnosticHandler);
83 static bool hasGlobalValueSummaryInMemBuffer(
84 MemoryBufferRef Object,
85 const DiagnosticHandlerFunction &DiagnosticHandler);
8686
8787 /// \brief Parse module summary index in the given memory buffer.
8888 /// Return new ModuleSummaryIndexObjectFile instance containing parsed module
8989 /// summary/index.
9090 static ErrorOr>
91 create(MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler);
91 create(MemoryBufferRef Object,
92 const DiagnosticHandlerFunction &DiagnosticHandler);
9293 };
9394 }
9495
9596 /// Parse the module summary index out of an IR file and return the module
9697 /// summary index object if found, or nullptr if not.
97 ErrorOr>
98 getModuleSummaryIndexForFile(StringRef Path,
99 DiagnosticHandlerFunction DiagnosticHandler);
98 ErrorOr> getModuleSummaryIndexForFile(
99 StringRef Path, const DiagnosticHandlerFunction &DiagnosticHandler);
100100 }
101101
102102 #endif
3737 class Printable {
3838 public:
3939 std::function Print;
40 Printable(const std::function Print)
40 Printable(std::function Print)
4141 : Print(std::move(Print)) {}
4242 };
4343
5252
5353 public:
5454 InternalizePass();
55 InternalizePass(
56 const std::function MustPreserveGV)
55 InternalizePass(std::function MustPreserveGV)
5756 : MustPreserveGV(std::move(MustPreserveGV)) {}
5857
5958 /// Run the internalizer on \p TheModule, returns true if any changes was
6766 };
6867
6968 /// Helper function to internalize functions and variables in a Module.
70 inline bool internalizeModule(
71 Module &TheModule,
72 const std::function MustPreserveGV,
73 CallGraph *CG = nullptr) {
69 inline bool
70 internalizeModule(Module &TheModule,
71 std::function MustPreserveGV,
72 CallGraph *CG = nullptr) {
7473 return InternalizePass(std::move(MustPreserveGV))
7574 .internalizeModule(TheModule, CG);
7675 }
551551
552552 void BitcodeDiagnosticInfo::print(DiagnosticPrinter &DP) const { DP << Msg; }
553553
554 static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
554 static std::error_code error(const DiagnosticHandlerFunction &DiagnosticHandler,
555555 std::error_code EC, const Twine &Message) {
556556 BitcodeDiagnosticInfo DI(EC, DS_Error, Message);
557557 DiagnosticHandler(DI);
558558 return EC;
559559 }
560560
561 static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
561 static std::error_code error(const DiagnosticHandlerFunction &DiagnosticHandler,
562562 std::error_code EC) {
563563 return error(DiagnosticHandler, EC, EC.message());
564564 }
65546554 }
65556555
65566556 // Parse the specified bitcode buffer, returning the function info index.
6557 ErrorOr>
6558 llvm::getModuleSummaryIndex(MemoryBufferRef Buffer,
6559 DiagnosticHandlerFunction DiagnosticHandler) {
6557 ErrorOr> llvm::getModuleSummaryIndex(
6558 MemoryBufferRef Buffer,
6559 const DiagnosticHandlerFunction &DiagnosticHandler) {
65606560 std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Buffer, false);
65616561 ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler);
65626562
65756575 }
65766576
65776577 // Check if the given bitcode buffer contains a global value summary block.
6578 bool llvm::hasGlobalValueSummary(MemoryBufferRef Buffer,
6579 DiagnosticHandlerFunction DiagnosticHandler) {
6578 bool llvm::hasGlobalValueSummary(
6579 MemoryBufferRef Buffer,
6580 const DiagnosticHandlerFunction &DiagnosticHandler) {
65806581 std::unique_ptr Buf = MemoryBuffer::getMemBuffer(Buffer, false);
65816582 ModuleSummaryIndexBitcodeReader R(Buf.get(), DiagnosticHandler, true);
65826583
278278
279279 // Hash an individual attribute \param Attr based on the type of attribute and
280280 // the form.
281 void DIEHash::hashAttribute(DIEValue Value, dwarf::Tag Tag) {
281 void DIEHash::hashAttribute(const DIEValue &Value, dwarf::Tag Tag) {
282282 dwarf::Attribute Attribute = Value.getAttribute();
283283
284284 // Other attribute values use the letter 'A' as the marker, and the value
130130 void hashLocList(const DIELocList &LocList);
131131
132132 /// \brief Hashes an individual attribute.
133 void hashAttribute(DIEValue Value, dwarf::Tag Tag);
133 void hashAttribute(const DIEValue &Value, dwarf::Tag Tag);
134134
135135 /// \brief Hashes an attribute that refers to another DIE.
136136 void hashDIEEntry(dwarf::Attribute Attribute, dwarf::Tag Tag,
2424
2525 using namespace llvm;
2626
27 static void
28 codegen(Module *M, llvm::raw_pwrite_stream &OS,
29 std::function()> TMFactory,
30 TargetMachine::CodeGenFileType FileType) {
27 static void codegen(Module *M, llvm::raw_pwrite_stream &OS,
28 function_ref()> TMFactory,
29 TargetMachine::CodeGenFileType FileType) {
3130 std::unique_ptr TM = TMFactory();
3231 legacy::PassManager CodeGenPasses;
3332 if (TM->addPassesToEmitFile(CodeGenPasses, OS, FileType))
59765976 /// probability having other instructions associated with that line.
59775977 ///
59785978 /// For IROrder, we keep the smaller of the two
5979 SDNode *SelectionDAG::UpdadeSDLocOnMergedSDNode(SDNode *N, SDLoc OLoc) {
5979 SDNode *SelectionDAG::UpdadeSDLocOnMergedSDNode(SDNode *N, const SDLoc &OLoc) {
59805980 DebugLoc NLoc = N->getDebugLoc();
59815981 if (NLoc && OptLevel == CodeGenOpt::None && OLoc.getDebugLoc() != NLoc) {
59825982 N->setDebugLoc(DebugLoc());
583583 // Returns a pair containing the result of the slice operation, plus the
584584 // expression remaining to be parsed.
585585 std::pair
586 evalSliceExpr(std::pair Ctx) const {
586 evalSliceExpr(const std::pair &Ctx) const {
587587 EvalResult SubExprResult;
588588 StringRef RemainingExpr;
589589 std::tie(SubExprResult, RemainingExpr) = Ctx;
627627 // Returns a pair containing the ultimate result of evaluating the
628628 // expression, plus the expression remaining to be evaluated.
629629 std::pair
630 evalComplexExpr(std::pair LHSAndRemaining,
630 evalComplexExpr(const std::pair &LHSAndRemaining,
631631 ParseContext PCtx) const {
632632 EvalResult LHSResult;
633633 StringRef RemainingExpr;
6969 // Looks for module summary index in the given memory buffer.
7070 // returns true if found, else false.
7171 bool ModuleSummaryIndexObjectFile::hasGlobalValueSummaryInMemBuffer(
72 MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler) {
72 MemoryBufferRef Object,
73 const DiagnosticHandlerFunction &DiagnosticHandler) {
7374 ErrorOr BCOrErr = findBitcodeInMemBuffer(Object);
7475 if (!BCOrErr)
7576 return false;
8283 // module summary/index.
8384 ErrorOr>
8485 ModuleSummaryIndexObjectFile::create(
85 MemoryBufferRef Object, DiagnosticHandlerFunction DiagnosticHandler) {
86 MemoryBufferRef Object,
87 const DiagnosticHandlerFunction &DiagnosticHandler) {
8688 std::unique_ptr Index;
8789
8890 ErrorOr BCOrErr = findBitcodeInMemBuffer(Object);
104106 // Parse the module summary index out of an IR file and return the summary
105107 // index object if found, or nullptr if not.
106108 ErrorOr> llvm::getModuleSummaryIndexForFile(
107 StringRef Path, DiagnosticHandlerFunction DiagnosticHandler) {
109 StringRef Path, const DiagnosticHandlerFunction &DiagnosticHandler) {
108110 ErrorOr> FileOrErr =
109111 MemoryBuffer::getFileOrSTDIN(Path);
110112 std::error_code EC = FileOrErr.getError();
678678
679679 /// Parse the summary index out of an IR file and return the summary
680680 /// index object if found, or nullptr if not.
681 static std::unique_ptr
682 getModuleSummaryIndexForFile(StringRef Path, std::string &Error,
683 DiagnosticHandlerFunction DiagnosticHandler) {
681 static std::unique_ptr getModuleSummaryIndexForFile(
682 StringRef Path, std::string &Error,
683 const DiagnosticHandlerFunction &DiagnosticHandler) {
684684 std::unique_ptr Buffer;
685685 ErrorOr> BufferOrErr =
686686 MemoryBuffer::getFile(Path);
105105
106106 static inline GVN::Expression getTombstoneKey() { return ~1U; }
107107
108 static unsigned getHashValue(const GVN::Expression e) {
108 static unsigned getHashValue(const GVN::Expression &e) {
109109 using llvm::hash_value;
110110 return static_cast(hash_value(e));
111111 }
13981398 bool MadeChange = false;
13991399 MD = MD_;
14001400 TLI = TLI_;
1401 LookupAliasAnalysis = LookupAliasAnalysis_;
1402 LookupAssumptionCache = LookupAssumptionCache_;
1403 LookupDomTree = LookupDomTree_;
1401 LookupAliasAnalysis = std::move(LookupAliasAnalysis_);
1402 LookupAssumptionCache = std::move(LookupAssumptionCache_);
1403 LookupDomTree = std::move(LookupDomTree_);
14041404
14051405 // If we don't have at least memset and memcpy, there is little point of doing
14061406 // anything here. These are required by a freestanding implementation, so if
324324 // can be validly truncated to. The cost model has assumed this truncation
325325 // will happen when vectorizing.
326326 void vectorize(LoopVectorizationLegality *L,
327 MapVector MinimumBitWidths) {
328 MinBWs = MinimumBitWidths;
327 const MapVector &MinimumBitWidths) {
328 MinBWs = &MinimumBitWidths;
329329 Legal = L;
330330 // Create a new empty loop. Unlink the old loop and connect the new one.
331331 createEmptyLoop();
596596 /// Map of scalar integer values to the smallest bitwidth they can be legally
597597 /// represented as. The vector equivalents of these values should be truncated
598598 /// to this type.
599 MapVector MinBWs;
599 const MapVector *MinBWs;
600600 LoopVectorizationLegality *Legal;
601601
602602 // Record whether runtime checks are added.
14301430 /// Updates the vectorization state by adding \p Phi to the inductions list.
14311431 /// This can set \p Phi as the main induction of the loop if \p Phi is a
14321432 /// better choice for the main induction than the existing one.
1433 void addInductionPhi(PHINode *Phi, InductionDescriptor ID,
1433 void addInductionPhi(PHINode *Phi, const InductionDescriptor &ID,
14341434 SmallPtrSetImpl &AllowedExit);
14351435
14361436 /// Report an analysis message to assist the user in diagnosing loops that are
34933493 // later and will remove any ext/trunc pairs.
34943494 //
34953495 SmallPtrSet Erased;
3496 for (auto &KV : MinBWs) {
3496 for (const auto &KV : *MinBWs) {
34973497 VectorParts &Parts = WidenMap.get(KV.first);
34983498 for (Value *&I : Parts) {
34993499 if (Erased.count(I) || I->use_empty())
35883588 }
35893589
35903590 // We'll have created a bunch of ZExts that are now parentless. Clean up.
3591 for (auto &KV : MinBWs) {
3591 for (const auto &KV : *MinBWs) {
35923592 VectorParts &Parts = WidenMap.get(KV.first);
35933593 for (Value *&I : Parts) {
35943594 ZExtInst *Inst = dyn_cast(I);
47234723 }
47244724
47254725 void LoopVectorizationLegality::addInductionPhi(
4726 PHINode *Phi, InductionDescriptor ID,
4726 PHINode *Phi, const InductionDescriptor &ID,
47274727 SmallPtrSetImpl &AllowedExit) {
47284728 Inductions[Phi] = ID;
47294729 Type *PhiTy = Phi->getType();
320320 return 0;
321321 }
322322
323 static int showInstrProfile(std::string Filename, bool ShowCounts,
323 static int showInstrProfile(const std::string &Filename, bool ShowCounts,
324324 bool ShowIndirectCallTargets,
325325 bool ShowDetailedSummary,
326326 std::vector DetailedSummaryCutoffs,
327 bool ShowAllFunctions, std::string ShowFunction,
328 bool TextFormat, raw_fd_ostream &OS) {
327 bool ShowAllFunctions,
328 const std::string &ShowFunction, bool TextFormat,
329 raw_fd_ostream &OS) {
329330 auto ReaderOrErr = InstrProfReader::create(Filename);
330 std::vector Cutoffs(DetailedSummaryCutoffs);
331 if (ShowDetailedSummary && DetailedSummaryCutoffs.empty()) {
331 std::vector Cutoffs = std::move(DetailedSummaryCutoffs);
332 if (ShowDetailedSummary && Cutoffs.empty()) {
332333 Cutoffs = {800000, 900000, 950000, 990000, 999000, 999900, 999990};
333334 }
334 InstrProfSummaryBuilder Builder(Cutoffs);
335 InstrProfSummaryBuilder Builder(std::move(Cutoffs));
335336 if (Error E = ReaderOrErr.takeError())
336337 exitWithError(std::move(E), Filename);
337338
437438 return 0;
438439 }
439440
440 static int showSampleProfile(std::string Filename, bool ShowCounts,
441 bool ShowAllFunctions, std::string ShowFunction,
441 static int showSampleProfile(const std::string &Filename, bool ShowCounts,
442 bool ShowAllFunctions,
443 const std::string &ShowFunction,
442444 raw_fd_ostream &OS) {
443445 using namespace sampleprof;
444446 LLVMContext Context;
233233 }
234234
235235 private:
236 static std::string normalizeFilename(std::string FileName) {
236 static std::string normalizeFilename(const std::string &FileName) {
237237 SmallString<256> S(FileName);
238238 sys::path::remove_dots(S, /* remove_dot_dot */ true);
239239 return S.str().str();
283283 };
284284
285285 // Collect all debug info for given addresses.
286 static std::vector getAddrInfo(std::string ObjectFile,
286 static std::vector getAddrInfo(const std::string &ObjectFile,
287287 const std::set &Addrs,
288288 bool InlinedCode) {
289289 std::vector Result;
415415
416416 static void
417417 visitObjectFiles(const object::Archive &A,
418 std::function Fn) {
418 function_ref Fn) {
419419 for (auto &ErrorOrChild : A.children()) {
420420 FailIfError(ErrorOrChild);
421421 const object::Archive::Child &C = *ErrorOrChild;
429429 }
430430
431431 static void
432 visitObjectFiles(std::string FileName,
433 std::function Fn) {
432 visitObjectFiles(const std::string &FileName,
433 function_ref Fn) {
434434 Expected> BinaryOrErr =
435435 object::createBinary(FileName);
436436 if (!BinaryOrErr)
445445 FailIfError(object::object_error::invalid_file_type);
446446 }
447447
448 std::set findSanitizerCovFunctions(std::string FileName) {
448 std::set findSanitizerCovFunctions(const std::string &FileName) {
449449 std::set Result;
450450 visitObjectFiles(FileName, [&](const object::ObjectFile &O) {
451451 auto Addrs = findSanitizerCovFunctions(O);
457457 // Locate addresses of all coverage points in a file. Coverage point
458458 // is defined as the 'address of instruction following __sanitizer_cov
459459 // call - 1'.
460 std::set getCoveragePoints(std::string FileName) {
460 std::set getCoveragePoints(const std::string &FileName) {
461461 std::set Result;
462462 visitObjectFiles(FileName, [&](const object::ObjectFile &O) {
463463 getObjectCoveragePoints(O, &Result);
465465 return Result;
466466 }
467467
468 static void printCovPoints(std::string ObjFile, raw_ostream &OS) {
468 static void printCovPoints(const std::string &ObjFile, raw_ostream &OS) {
469469 for (uint64_t Addr : getCoveragePoints(ObjFile)) {
470470 OS << "0x";
471471 OS.write_hex(Addr);
514514 return Zeroes + Num;
515515 }
516516
517 static std::string anchorName(std::string Anchor) {
517 static std::string anchorName(const std::string &Anchor) {
518518 llvm::MD5 Hasher;
519519 llvm::MD5::MD5Result Hash;
520520 Hasher.update(Anchor);
525525 return HexString.str().str();
526526 }
527527
528 static ErrorOr isCoverageFile(std::string FileName) {
528 static ErrorOr isCoverageFile(const std::string &FileName) {
529529 ErrorOr> BufOrErr =
530530 MemoryBuffer::getFile(FileName);
531531 if (!BufOrErr) {
563563 class CoverageData {
564564 public:
565565 // Read single file coverage data.
566 static ErrorOr> read(std::string FileName) {
566 static ErrorOr>
567 read(const std::string &FileName) {
567568 ErrorOr> BufOrErr =
568569 MemoryBuffer::getFile(FileName);
569570 if (!BufOrErr)
846847 class CoverageDataWithObjectFile : public CoverageData {
847848 public:
848849 static ErrorOr>
849 readAndMerge(std::string ObjectFile,
850 readAndMerge(const std::string &ObjectFile,
850851 const std::vector &FileNames) {
851852 auto MergedDataOrError = CoverageData::readAndMerge(FileNames);
852853 if (!MergedDataOrError)