From b1f9c060a1d2b78c8bb96dde8e524cb550b10375 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 24 Nov 2016 16:01:20 +0000 Subject: [PATCH] [CodeGen] Pass objects that are expensive to copy by const ref. No functionality change. Found by clang-tidy's performance-unnecessary-value-param. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@287894 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGLoopInfo.cpp | 12 +++++++----- lib/CodeGen/CGLoopInfo.h | 10 +++++----- lib/CodeGen/CGObjCGNU.cpp | 10 +++++----- lib/CodeGen/CGOpenMPRuntime.cpp | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/CodeGen/CGLoopInfo.cpp b/lib/CodeGen/CGLoopInfo.cpp index 7e44c9fc56..28998ce8db 100644 --- a/lib/CodeGen/CGLoopInfo.cpp +++ b/lib/CodeGen/CGLoopInfo.cpp @@ -20,7 +20,8 @@ using namespace clang::CodeGen; using namespace llvm; static MDNode *createMetadata(LLVMContext &Ctx, const LoopAttributes &Attrs, - llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc) { + const llvm::DebugLoc &StartLoc, + const llvm::DebugLoc &EndLoc) { if (!Attrs.IsParallel && Attrs.VectorizeWidth == 0 && Attrs.InterleaveCount == 0 && Attrs.UnrollCount == 0 && @@ -121,13 +122,13 @@ void LoopAttributes::clear() { } LoopInfo::LoopInfo(BasicBlock *Header, const LoopAttributes &Attrs, - llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc) + const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc) : LoopID(nullptr), Header(Header), Attrs(Attrs) { LoopID = createMetadata(Header->getContext(), Attrs, StartLoc, EndLoc); } -void LoopInfoStack::push(BasicBlock *Header, llvm::DebugLoc StartLoc, - llvm::DebugLoc EndLoc) { +void LoopInfoStack::push(BasicBlock *Header, const llvm::DebugLoc &StartLoc, + const llvm::DebugLoc &EndLoc) { Active.push_back(LoopInfo(Header, StagedAttrs, StartLoc, EndLoc)); // Clear the attributes so nested loops do not inherit them. StagedAttrs.clear(); @@ -135,7 +136,8 @@ void LoopInfoStack::push(BasicBlock *Header, llvm::DebugLoc StartLoc, void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx, ArrayRef Attrs, - llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc) { + const llvm::DebugLoc &StartLoc, + const llvm::DebugLoc &EndLoc) { // Identify loop hint attributes from Attrs. for (const auto *Attr : Attrs) { diff --git a/lib/CodeGen/CGLoopInfo.h b/lib/CodeGen/CGLoopInfo.h index e2c9770531..15608c105d 100644 --- a/lib/CodeGen/CGLoopInfo.h +++ b/lib/CodeGen/CGLoopInfo.h @@ -67,7 +67,7 @@ class LoopInfo { public: /// \brief Construct a new LoopInfo for the loop with entry Header. LoopInfo(llvm::BasicBlock *Header, const LoopAttributes &Attrs, - llvm::DebugLoc StartLoc, llvm::DebugLoc EndLoc); + const llvm::DebugLoc &StartLoc, const llvm::DebugLoc &EndLoc); /// \brief Get the loop id metadata for this loop. llvm::MDNode *getLoopID() const { return LoopID; } @@ -99,14 +99,14 @@ public: /// \brief Begin a new structured loop. The set of staged attributes will be /// applied to the loop and then cleared. - void push(llvm::BasicBlock *Header, llvm::DebugLoc StartLoc, - llvm::DebugLoc EndLoc); + void push(llvm::BasicBlock *Header, const llvm::DebugLoc &StartLoc, + const llvm::DebugLoc &EndLoc); /// \brief Begin a new structured loop. Stage attributes from the Attrs list. /// The staged attributes are applied to the loop and then cleared. void push(llvm::BasicBlock *Header, clang::ASTContext &Ctx, - llvm::ArrayRef Attrs, llvm::DebugLoc StartLoc, - llvm::DebugLoc EndLoc); + llvm::ArrayRef Attrs, const llvm::DebugLoc &StartLoc, + const llvm::DebugLoc &EndLoc); /// \brief End the current loop. void pop(); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 7fdd1bda16..9a99c6e530 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -175,14 +175,14 @@ protected: /// string value. This allows the linker to combine the strings between /// different modules. Used for EH typeinfo names, selector strings, and a /// few other things. - llvm::Constant *ExportUniqueString(const std::string &Str, - const std::string prefix) { - std::string name = prefix + Str; - auto *ConstStr = TheModule.getGlobalVariable(name); + llvm::Constant *ExportUniqueString(const std::string &Str, StringRef Prefix) { + std::string Name = Prefix.str() + Str; + auto *ConstStr = TheModule.getGlobalVariable(Name); if (!ConstStr) { llvm::Constant *value = llvm::ConstantDataArray::getString(VMContext,Str); ConstStr = new llvm::GlobalVariable(TheModule, value->getType(), true, - llvm::GlobalValue::LinkOnceODRLinkage, value, prefix + Str); + llvm::GlobalValue::LinkOnceODRLinkage, + value, Name); } return llvm::ConstantExpr::getGetElementPtr(ConstStr->getValueType(), ConstStr, Zeros); diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index 1e38e6e9ad..62ac3c28f0 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -6517,7 +6517,7 @@ static unsigned evaluateCDTSize(const FunctionDecl *FD, static void emitX86DeclareSimdFunction(const FunctionDecl *FD, llvm::Function *Fn, - llvm::APSInt VLENVal, + const llvm::APSInt &VLENVal, ArrayRef ParamAttrs, OMPDeclareSimdDeclAttr::BranchStateTy State) { struct ISADataTy { -- 2.40.0