diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2016-05-27 12:30:51 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2016-05-27 12:30:51 +0000 |
commit | 4fed928f53dbea24914bc0db307e0988c6e44c8c (patch) | |
tree | d6c73577b5531048e54fb19c78b8e316b7fc66ad /llvm/lib | |
parent | c91e38c5ebf6f0cfbb29eff66c5ff6db43c3ee45 (diff) | |
download | bcm5719-llvm-4fed928f53dbea24914bc0db307e0988c6e44c8c.tar.gz bcm5719-llvm-4fed928f53dbea24914bc0db307e0988c6e44c8c.zip |
Avoid some copies by using const references.
clang-tidy's performance-unnecessary-copy-initialization with some manual
fixes. No functional changes intended.
llvm-svn: 270988
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/SpecialCaseList.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/SampleProfile.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 8 |
9 files changed, 11 insertions, 14 deletions
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp index ea417c41c0a..0ffe4444a17 100644 --- a/llvm/lib/Support/SpecialCaseList.cpp +++ b/llvm/lib/Support/SpecialCaseList.cpp @@ -50,7 +50,7 @@ std::unique_ptr<SpecialCaseList> SpecialCaseList::create(const std::vector<std::string> &Paths, std::string &Error) { std::unique_ptr<SpecialCaseList> SCL(new SpecialCaseList()); - for (auto Path : Paths) { + for (const auto &Path : Paths) { ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFile(Path); if (std::error_code EC = FileOrErr.getError()) { diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp index 8fec80307a6..1e66b3b0934 100644 --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUAsmBackend.cpp @@ -190,8 +190,6 @@ public: MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU) { - Triple TargetTriple(TT); - // Use 64-bit ELF for amdgcn - return new ELFAMDGPUAsmBackend(T, TargetTriple.getArch() == Triple::amdgcn); + return new ELFAMDGPUAsmBackend(T, TT.getArch() == Triple::amdgcn); } diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 71823e47009..9ad7f9cc9d5 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -642,7 +642,7 @@ void ARMAsmPrinter::emitAttributes() { static_cast<const ARMBaseTargetMachine &>(TM); const ARMSubtarget STI(TT, CPU, ArchFS, ATM, ATM.isLittleEndian()); - std::string CPUString = STI.getCPUString(); + const std::string &CPUString = STI.getCPUString(); if (CPUString.find("generic") != 0) { //CPUString doesn't start with "generic" // FIXME: remove krait check when GNU tools support krait cpu diff --git a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp index c54a6b26c69..633d1a47689 100644 --- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -1401,7 +1401,6 @@ bool HexagonAsmParser::parseInstruction(OperandVector &Operands) { AsmToken const &Token = Parser.getTok(); if (Token.is(AsmToken::Identifier)) { StringRef String = Token.getString(); - AsmToken IDToken = Token; if (String.lower() == "hi") { HiOnly = true; } else if (String.lower() == "lo") { diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 16ec118aba6..b22a7fb0078 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -438,7 +438,7 @@ public: IsCpRestoreSet = false; CpRestoreOffset = -1; - Triple TheTriple(sti.getTargetTriple()); + const Triple &TheTriple = sti.getTargetTriple(); if ((TheTriple.getArch() == Triple::mips) || (TheTriple.getArch() == Triple::mips64)) IsLittleEndian = false; diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 50232c384dd..a3c9657e964 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -117,7 +117,7 @@ void NVPTXAsmPrinter::emitLineNumberAsDotLoc(const MachineInstr &MI) { if (ignoreLoc(MI)) return; - DebugLoc curLoc = MI.getDebugLoc(); + const DebugLoc &curLoc = MI.getDebugLoc(); if (!prevDebugLoc && !curLoc) return; diff --git a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp index 4b526fc6efe..cf8ee1d6a16 100644 --- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp @@ -292,7 +292,7 @@ public: const MCInstrInfo &MII, const MCTargetOptions &Options) : MCTargetAsmParser(Options, STI), MII(MII) { // Check for 64-bit vs. 32-bit pointer mode. - Triple TheTriple(STI.getTargetTriple()); + const Triple &TheTriple = STI.getTargetTriple(); IsPPC64 = (TheTriple.getArch() == Triple::ppc64 || TheTriple.getArch() == Triple::ppc64le); IsDarwin = TheTriple.isMacOSX(); diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index afafd45bec0..deba6ea0661 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -445,7 +445,7 @@ void SampleProfileLoader::printBlockWeight(raw_ostream &OS, /// \returns the weight of \p Inst. ErrorOr<uint64_t> SampleProfileLoader::getInstWeight(const Instruction &Inst) const { - DebugLoc DLoc = Inst.getDebugLoc(); + const DebugLoc &DLoc = Inst.getDebugLoc(); if (!DLoc) return std::error_code(); diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index 823696d88e6..3d2ee73669b 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -77,15 +77,15 @@ static SetVector<BasicBlock *> buildExtractionBlockSet(IteratorT BBBegin, // Loop over the blocks, adding them to our set-vector, and aborting with an // empty set if we encounter invalid blocks. - for (IteratorT I = BBBegin, E = BBEnd; I != E; ++I) { - if (!Result.insert(*I)) + do { + if (!Result.insert(*BBBegin)) llvm_unreachable("Repeated basic blocks in extraction input"); - if (!isBlockValidForExtraction(**I)) { + if (!isBlockValidForExtraction(**BBBegin)) { Result.clear(); return Result; } - } + } while (++BBBegin != BBEnd); #ifndef NDEBUG for (SetVector<BasicBlock *>::iterator I = std::next(Result.begin()), |