Apply most suggestions of clang-tidy's performance-unnecessary-value-param

Avoids unnecessary copies. All changes audited & pass tests with asan.
No functional change intended.

llvm-svn: 272190
This commit is contained in:
Benjamin Kramer 2016-06-08 19:09:22 +00:00
parent 19e88c1ff6
commit c321e53402
48 changed files with 108 additions and 108 deletions

View File

@ -177,7 +177,7 @@ class APInt {
/// provides a more convenient form of divide for internal use since KnuthDiv
/// has specific constraints on its inputs. If those constraints are not met
/// then it provides a simpler form of divide.
static void divide(const APInt LHS, unsigned lhsWords, const APInt &RHS,
static void divide(const APInt &LHS, unsigned lhsWords, const APInt &RHS,
unsigned rhsWords, APInt *Quotient, APInt *Remainder);
/// out-of-line slow case for inline constructor

View File

@ -335,8 +335,8 @@ namespace llvm {
/// where the value is not in the condition, thus computing the
/// exit count. If the iteration count can't be computed, an
/// instance of SCEVCouldNotCompute is returned.
const SCEV *getNumIterationsInRange(ConstantRange Range,
ScalarEvolution &SE) const;
const SCEV *getNumIterationsInRange(const ConstantRange &Range,
ScalarEvolution &SE) const;
/// Return an expression representing the value of this expression
/// one iteration of the loop ahead.

View File

@ -315,7 +315,7 @@ private:
StringMap<std::unique_ptr<TargetLibraryInfoImpl>> Impls;
TargetLibraryInfoImpl &lookupInfoImpl(Triple T);
TargetLibraryInfoImpl &lookupInfoImpl(const Triple &T);
};
class TargetLibraryInfoWrapperPass : public ImmutablePass {

View File

@ -31,7 +31,7 @@ class DIPrinter {
int PrintSourceContext;
void print(const DILineInfo &Info, bool Inlined);
void printContext(std::string FileName, int64_t Line);
void printContext(const std::string &FileName, int64_t Line);
public:
DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true,

View File

@ -334,13 +334,14 @@ private:
/// ErrorHandlerAddress will be used by the resulting compile callback
/// manager if a compile callback fails.
std::unique_ptr<JITCompileCallbackManager>
createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress);
createLocalCompileCallbackManager(const Triple &T,
TargetAddress ErrorHandlerAddress);
/// @brief Create a local indriect stubs manager builder.
///
/// The given target triple will determine the ABI.
std::function<std::unique_ptr<IndirectStubsManager>()>
createLocalIndirectStubsManagerBuilder(Triple T);
createLocalIndirectStubsManagerBuilder(const Triple &T);
/// @brief Build a function pointer of FunctionType with the given constant
/// address.

View File

@ -77,7 +77,7 @@ struct LTOCodeGenerator {
/// Resets \a HasVerifiedInput.
void setModule(std::unique_ptr<LTOModule> M);
void setTargetOptions(TargetOptions Options);
void setTargetOptions(const TargetOptions &Options);
void setDebugInfo(lto_debug_model);
void setCodePICModel(Optional<Reloc::Model> Model) { RelocModel = Model; }

View File

@ -91,19 +91,22 @@ public:
/// InitializeAllAsmPrinters();
/// InitializeAllAsmParsers();
static ErrorOr<std::unique_ptr<LTOModule>>
createFromFile(LLVMContext &Context, const char *path, TargetOptions options);
createFromFile(LLVMContext &Context, const char *path,
const TargetOptions &options);
static ErrorOr<std::unique_ptr<LTOModule>>
createFromOpenFile(LLVMContext &Context, int fd, const char *path,
size_t size, TargetOptions options);
size_t size, const TargetOptions &options);
static ErrorOr<std::unique_ptr<LTOModule>>
createFromOpenFileSlice(LLVMContext &Context, int fd, const char *path,
size_t map_size, off_t offset, TargetOptions options);
size_t map_size, off_t offset,
const TargetOptions &options);
static ErrorOr<std::unique_ptr<LTOModule>>
createFromBuffer(LLVMContext &Context, const void *mem, size_t length,
TargetOptions options, StringRef path = "");
const TargetOptions &options, StringRef path = "");
static ErrorOr<std::unique_ptr<LTOModule>>
createInLocalContext(std::unique_ptr<LLVMContext> Context, const void *mem,
size_t length, TargetOptions options, StringRef path);
size_t length, const TargetOptions &options,
StringRef path);
const Module &getModule() const {
return const_cast<LTOModule*>(this)->getModule();
@ -202,7 +205,7 @@ private:
/// Create an LTOModule (private version).
static ErrorOr<std::unique_ptr<LTOModule>>
makeLTOModule(MemoryBufferRef Buffer, TargetOptions options,
makeLTOModule(MemoryBufferRef Buffer, const TargetOptions &options,
LLVMContext &Context, bool ShouldBeLazy);
};
}

View File

@ -356,9 +356,9 @@ private:
MCContext *Ctx;
Triple TT;
void initMachOMCObjectFileInfo(Triple T);
void initELFMCObjectFileInfo(Triple T);
void initCOFFMCObjectFileInfo(Triple T);
void initMachOMCObjectFileInfo(const Triple &T);
void initELFMCObjectFileInfo(const Triple &T);
void initCOFFMCObjectFileInfo(const Triple &T);
public:
const Triple &getTargetTriple() const { return TT; }

View File

@ -204,8 +204,8 @@ public:
}
sampleprof_error addCalledTargetSamples(uint32_t LineOffset,
uint32_t Discriminator,
std::string FName, uint64_t Num,
uint64_t Weight = 1) {
const std::string &FName,
uint64_t Num, uint64_t Weight = 1) {
return BodySamples[LineLocation(LineOffset, Discriminator)].addCalledTarget(
FName, Num, Weight);
}

View File

@ -946,7 +946,7 @@ public:
// getValueName - Overload in subclass to provide a better default value.
const char *getValueName() const override { return "string"; }
void printOptionDiff(const Option &O, StringRef V, OptVal Default,
void printOptionDiff(const Option &O, StringRef V, const OptVal &Default,
size_t GlobalWidth) const;
// An out-of-line virtual method to provide a 'home' for this class.

View File

@ -190,7 +190,7 @@ public:
startLine() << Label << ": " << int(Value) << "\n";
}
void printNumber(StringRef Label, APSInt Value) {
void printNumber(StringRef Label, const APSInt &Value) {
startLine() << Label << ": " << Value << "\n";
}

View File

@ -1326,9 +1326,8 @@ bool DependenceInfo::weakCrossingSIVtest(
// Computes the GCD of AM and BM.
// Also finds a solution to the equation ax - by = gcd(a, b).
// Returns true if dependence disproved; i.e., gcd does not divide Delta.
static
bool findGCD(unsigned Bits, APInt AM, APInt BM, APInt Delta,
APInt &G, APInt &X, APInt &Y) {
static bool findGCD(unsigned Bits, const APInt &AM, const APInt &BM,
const APInt &Delta, APInt &G, APInt &X, APInt &Y) {
APInt A0(Bits, 1, true), A1(Bits, 0, true);
APInt B0(Bits, 0, true), B1(Bits, 1, true);
APInt G0 = AM.abs();
@ -1357,9 +1356,7 @@ bool findGCD(unsigned Bits, APInt AM, APInt BM, APInt Delta,
return false;
}
static
APInt floorOfQuotient(APInt A, APInt B) {
static APInt floorOfQuotient(const APInt &A, const APInt &B) {
APInt Q = A; // these need to be initialized
APInt R = A;
APInt::sdivrem(A, B, Q, R);
@ -1372,9 +1369,7 @@ APInt floorOfQuotient(APInt A, APInt B) {
return Q - 1;
}
static
APInt ceilingOfQuotient(APInt A, APInt B) {
static APInt ceilingOfQuotient(const APInt &A, const APInt &B) {
APInt Q = A; // these need to be initialized
APInt R = A;
APInt::sdivrem(A, B, Q, R);

View File

@ -297,7 +297,7 @@ raw_ostream &operator<<(raw_ostream &OS, const LVILatticeVal &Val) {
/// Returns true if this lattice value represents at most one possible value.
/// This is as precise as any lattice value can get while still representing
/// reachable code.
static bool hasSingleValue(LVILatticeVal Val) {
static bool hasSingleValue(const LVILatticeVal &Val) {
if (Val.isConstantRange() &&
Val.getConstantRange().isSingleElement())
// Integer constants are single element ranges

View File

@ -25,7 +25,7 @@
using namespace llvm;
static bool isAligned(const Value *Base, APInt Offset, unsigned Align,
static bool isAligned(const Value *Base, const APInt &Offset, unsigned Align,
const DataLayout &DL) {
APInt BaseAlign(Offset.getBitWidth(), Base->getPointerAlignment(DL));
@ -52,7 +52,7 @@ static bool isAligned(const Value *Base, unsigned Align, const DataLayout &DL) {
/// Test if V is always a pointer to allocated and suitably aligned memory for
/// a simple load or store.
static bool isDereferenceableAndAlignedPointer(
const Value *V, unsigned Align, APInt Size, const DataLayout &DL,
const Value *V, unsigned Align, const APInt &Size, const DataLayout &DL,
const Instruction *CtxI, const DominatorTree *DT,
const TargetLibraryInfo *TLI, SmallPtrSetImpl<const Value *> &Visited) {
// Note that it is not safe to speculate into a malloc'd region because

View File

@ -8811,7 +8811,7 @@ ScalarEvolution::howManyGreaterThans(const SCEV *LHS, const SCEV *RHS,
return ExitLimit(BECount, MaxBECount, P);
}
const SCEV *SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
const SCEV *SCEVAddRecExpr::getNumIterationsInRange(const ConstantRange &Range,
ScalarEvolution &SE) const {
if (Range.isFullSet()) // Infinite loop.
return SE.getCouldNotCompute();

View File

@ -1133,7 +1133,7 @@ TargetLibraryInfo TargetLibraryAnalysis::run(Function &F) {
lookupInfoImpl(Triple(F.getParent()->getTargetTriple())));
}
TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(Triple T) {
TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) {
std::unique_ptr<TargetLibraryInfoImpl> &Impl =
Impls[T.normalize()];
if (!Impl)

View File

@ -178,7 +178,7 @@ void DwarfExpression::AddUnsignedConstant(unsigned Value) {
AddStackValue();
}
void DwarfExpression::AddUnsignedConstant(APInt Value) {
void DwarfExpression::AddUnsignedConstant(const APInt &Value) {
unsigned Size = Value.getBitWidth();
const uint64_t *Data = Value.getRawData();

View File

@ -100,7 +100,7 @@ public:
/// Emit an unsigned constant.
void AddUnsignedConstant(unsigned Value);
/// Emit an unsigned constant.
void AddUnsignedConstant(APInt Value);
void AddUnsignedConstant(const APInt &Value);
/// \brief Emit an entire expression on top of a machine register location.
///

View File

@ -36,7 +36,7 @@ static const char kDILineInfoBadString[] = "<invalid>";
static const char kBadString[] = "??";
// Prints source code around in the FileName the Line.
void DIPrinter::printContext(std::string FileName, int64_t Line) {
void DIPrinter::printContext(const std::string &FileName, int64_t Line) {
if (PrintSourceContext <= 0)
return;

View File

@ -23,7 +23,8 @@ void JITCompileCallbackManager::anchor() {}
void IndirectStubsManager::anchor() {}
std::unique_ptr<JITCompileCallbackManager>
createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress) {
createLocalCompileCallbackManager(const Triple &T,
TargetAddress ErrorHandlerAddress) {
switch (T.getArch()) {
default: return nullptr;
@ -45,7 +46,7 @@ createLocalCompileCallbackManager(Triple T, TargetAddress ErrorHandlerAddress) {
}
std::function<std::unique_ptr<IndirectStubsManager>()>
createLocalIndirectStubsManagerBuilder(Triple T) {
createLocalIndirectStubsManagerBuilder(const Triple &T) {
switch (T.getArch()) {
default: return nullptr;

View File

@ -165,7 +165,7 @@ void LTOCodeGenerator::setModule(std::unique_ptr<LTOModule> Mod) {
HasVerifiedInput = false;
}
void LTOCodeGenerator::setTargetOptions(TargetOptions Options) {
void LTOCodeGenerator::setTargetOptions(const TargetOptions &Options) {
this->Options = Options;
}

View File

@ -108,7 +108,7 @@ std::string LTOModule::getProducerString(MemoryBuffer *Buffer) {
ErrorOr<std::unique_ptr<LTOModule>>
LTOModule::createFromFile(LLVMContext &Context, const char *path,
TargetOptions options) {
const TargetOptions &options) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getFile(path);
if (std::error_code EC = BufferOrErr.getError()) {
@ -122,14 +122,14 @@ LTOModule::createFromFile(LLVMContext &Context, const char *path,
ErrorOr<std::unique_ptr<LTOModule>>
LTOModule::createFromOpenFile(LLVMContext &Context, int fd, const char *path,
size_t size, TargetOptions options) {
size_t size, const TargetOptions &options) {
return createFromOpenFileSlice(Context, fd, path, size, 0, options);
}
ErrorOr<std::unique_ptr<LTOModule>>
LTOModule::createFromOpenFileSlice(LLVMContext &Context, int fd,
const char *path, size_t map_size,
off_t offset, TargetOptions options) {
off_t offset, const TargetOptions &options) {
ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
MemoryBuffer::getOpenFileSlice(fd, path, map_size, offset);
if (std::error_code EC = BufferOrErr.getError()) {
@ -143,7 +143,7 @@ LTOModule::createFromOpenFileSlice(LLVMContext &Context, int fd,
ErrorOr<std::unique_ptr<LTOModule>>
LTOModule::createFromBuffer(LLVMContext &Context, const void *mem,
size_t length, TargetOptions options,
size_t length, const TargetOptions &options,
StringRef path) {
StringRef Data((const char *)mem, length);
MemoryBufferRef Buffer(Data, path);
@ -153,7 +153,7 @@ LTOModule::createFromBuffer(LLVMContext &Context, const void *mem,
ErrorOr<std::unique_ptr<LTOModule>>
LTOModule::createInLocalContext(std::unique_ptr<LLVMContext> Context,
const void *mem, size_t length,
TargetOptions options, StringRef path) {
const TargetOptions &options, StringRef path) {
StringRef Data((const char *)mem, length);
MemoryBufferRef Buffer(Data, path);
// If we own a context, we know this is being used only for symbol extraction,
@ -196,7 +196,7 @@ parseBitcodeFileImpl(MemoryBufferRef Buffer, LLVMContext &Context,
}
ErrorOr<std::unique_ptr<LTOModule>>
LTOModule::makeLTOModule(MemoryBufferRef Buffer, TargetOptions options,
LTOModule::makeLTOModule(MemoryBufferRef Buffer, const TargetOptions &options,
LLVMContext &Context, bool ShouldBeLazy) {
ErrorOr<std::unique_ptr<Module>> MOrErr =
parseBitcodeFileImpl(Buffer, Context, ShouldBeLazy);

View File

@ -335,7 +335,7 @@ ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index,
const FunctionImporter::ExportSetTy &ExportList,
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols,
const GVSummaryMapTy &DefinedGlobals,
ThinLTOCodeGenerator::CachingOptions CacheOptions,
const ThinLTOCodeGenerator::CachingOptions &CacheOptions,
bool DisableCodeGen, StringRef SaveTempsDir,
unsigned count) {

View File

@ -44,7 +44,7 @@ class ModuleLinker {
/// The mover has just hit GV and we have to decide if it, and other members
/// of the same comdat, should be linked. Every member to be linked is passed
/// to Add.
void addLazyFor(GlobalValue &GV, IRMover::ValueAdder Add);
void addLazyFor(GlobalValue &GV, const IRMover::ValueAdder &Add);
bool shouldLinkReferencedLinkOnce() {
return !(Flags & Linker::DontForceLinkLinkonceODR);
@ -416,7 +416,7 @@ bool ModuleLinker::linkIfNeeded(GlobalValue &GV) {
return false;
}
void ModuleLinker::addLazyFor(GlobalValue &GV, IRMover::ValueAdder Add) {
void ModuleLinker::addLazyFor(GlobalValue &GV, const IRMover::ValueAdder &Add) {
if (!shouldLinkReferencedLinkOnce())
// For ThinLTO we don't import more than what was required.
// The client has to guarantee that the linkonce will be availabe at link

View File

@ -45,7 +45,7 @@ static bool useCompactUnwind(const Triple &T) {
return false;
}
void MCObjectFileInfo::initMachOMCObjectFileInfo(Triple T) {
void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) {
// MachO
SupportsWeakOmittedEHFrame = false;
@ -283,7 +283,7 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(Triple T) {
TLSExtraDataSection = TLSTLVSection;
}
void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) {
void MCObjectFileInfo::initELFMCObjectFileInfo(const Triple &T) {
switch (T.getArch()) {
case Triple::mips:
case Triple::mipsel:
@ -589,7 +589,7 @@ void MCObjectFileInfo::initELFMCObjectFileInfo(Triple T) {
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
}
void MCObjectFileInfo::initCOFFMCObjectFileInfo(Triple T) {
void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
EHFrameSection = Ctx->getCOFFSection(
".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,

View File

@ -1664,10 +1664,8 @@ static void KnuthDiv(unsigned *u, unsigned *v, unsigned *q, unsigned* r,
DEBUG(dbgs() << '\n');
}
void APInt::divide(const APInt LHS, unsigned lhsWords,
const APInt &RHS, unsigned rhsWords,
APInt *Quotient, APInt *Remainder)
{
void APInt::divide(const APInt &LHS, unsigned lhsWords, const APInt &RHS,
unsigned rhsWords, APInt *Quotient, APInt *Remainder) {
assert(lhsWords >= rhsWords && "Fractional result");
// First, compose the values into an array of 32-bit words instead of

View File

@ -1432,7 +1432,7 @@ PRINT_OPT_DIFF(float)
PRINT_OPT_DIFF(char)
void parser<std::string>::printOptionDiff(const Option &O, StringRef V,
OptionValue<std::string> D,
const OptionValue<std::string> &D,
size_t GlobalWidth) const {
printOptionName(O, GlobalWidth);
outs() << "= " << V;

View File

@ -1748,7 +1748,7 @@ bool AArch64DAGToDAGISel::tryBitfieldExtractOp(SDNode *N) {
/// BitsToBeInserted, suitable for use in a BFI instruction. Roughly speaking,
/// this asks whether DstMask zeroes precisely those bits that will be set by
/// the other half.
static bool isBitfieldDstMask(uint64_t DstMask, APInt BitsToBeInserted,
static bool isBitfieldDstMask(uint64_t DstMask, const APInt &BitsToBeInserted,
unsigned NumberOfIgnoredHighBits, EVT VT) {
assert((VT == MVT::i32 || VT == MVT::i64) &&
"i32 or i64 mask type expected!");

View File

@ -285,8 +285,8 @@ struct AArch64NamedImmMapper {
// Zero value of FeatureBitSet means the mapping is always available
FeatureBitset FeatureBitSet;
bool isNameEqual(std::string Other,
const FeatureBitset& FeatureBits) const {
bool isNameEqual(const std::string &Other,
const FeatureBitset &FeatureBits) const {
if (FeatureBitSet.any() &&
(FeatureBitSet & FeatureBits).none())
return false;

View File

@ -2341,7 +2341,7 @@ void NVPTXAsmPrinter::emitSrcInText(StringRef filename, unsigned line) {
this->OutStreamer->EmitRawText(temp.str());
}
LineReader *NVPTXAsmPrinter::getReader(std::string filename) {
LineReader *NVPTXAsmPrinter::getReader(const std::string &filename) {
if (!reader) {
reader = new LineReader(filename);
}

View File

@ -293,7 +293,7 @@ private:
bool isLoopHeaderOfNoUnroll(const MachineBasicBlock &MBB) const;
LineReader *reader;
LineReader *getReader(std::string);
LineReader *getReader(const std::string &);
// Used to control the need to emit .generic() in the initializer of
// module scope variables.

View File

@ -15,8 +15,8 @@ using namespace llvm;
#define DEBUG_TYPE "nvptx-mcexpr"
const NVPTXFloatMCExpr*
NVPTXFloatMCExpr::create(VariantKind Kind, APFloat Flt, MCContext &Ctx) {
const NVPTXFloatMCExpr *
NVPTXFloatMCExpr::create(VariantKind Kind, const APFloat &Flt, MCContext &Ctx) {
return new (Ctx) NVPTXFloatMCExpr(Kind, Flt);
}

View File

@ -37,15 +37,15 @@ public:
/// @name Construction
/// @{
static const NVPTXFloatMCExpr *create(VariantKind Kind, APFloat Flt,
static const NVPTXFloatMCExpr *create(VariantKind Kind, const APFloat &Flt,
MCContext &Ctx);
static const NVPTXFloatMCExpr *createConstantFPSingle(APFloat Flt,
static const NVPTXFloatMCExpr *createConstantFPSingle(const APFloat &Flt,
MCContext &Ctx) {
return create(VK_NVPTX_SINGLE_PREC_FLOAT, Flt, Ctx);
}
static const NVPTXFloatMCExpr *createConstantFPDouble(APFloat Flt,
static const NVPTXFloatMCExpr *createConstantFPDouble(const APFloat &Flt,
MCContext &Ctx) {
return create(VK_NVPTX_DOUBLE_PREC_FLOAT, Flt, Ctx);
}

View File

@ -99,7 +99,7 @@ static void cacheAnnotationFromMD(const Module *m, const GlobalValue *gv) {
}
}
bool llvm::findOneNVVMAnnotation(const GlobalValue *gv, std::string prop,
bool llvm::findOneNVVMAnnotation(const GlobalValue *gv, const std::string &prop,
unsigned &retval) {
MutexGuard Guard(Lock);
const Module *m = gv->getParent();
@ -113,7 +113,7 @@ bool llvm::findOneNVVMAnnotation(const GlobalValue *gv, std::string prop,
return true;
}
bool llvm::findAllNVVMAnnotation(const GlobalValue *gv, std::string prop,
bool llvm::findAllNVVMAnnotation(const GlobalValue *gv, const std::string &prop,
std::vector<unsigned> &retval) {
MutexGuard Guard(Lock);
const Module *m = gv->getParent();

View File

@ -30,8 +30,9 @@ namespace llvm {
void clearAnnotationCache(const llvm::Module *);
bool findOneNVVMAnnotation(const llvm::GlobalValue *, std::string, unsigned &);
bool findAllNVVMAnnotation(const llvm::GlobalValue *, std::string,
bool findOneNVVMAnnotation(const llvm::GlobalValue *, const std::string &,
unsigned &);
bool findAllNVVMAnnotation(const llvm::GlobalValue *, const std::string &,
std::vector<unsigned> &);
bool isTexture(const llvm::Value &);

View File

@ -522,12 +522,12 @@ private:
Value *SimplifyDemandedUseBits(Value *V, APInt DemandedMask, APInt &KnownZero,
APInt &KnownOne, unsigned Depth,
Instruction *CxtI);
bool SimplifyDemandedBits(Use &U, APInt DemandedMask, APInt &KnownZero,
bool SimplifyDemandedBits(Use &U, const APInt &DemandedMask, APInt &KnownZero,
APInt &KnownOne, unsigned Depth = 0);
/// Helper routine of SimplifyDemandedUseBits. It tries to simplify demanded
/// bit for "r1 = shr x, c1; r2 = shl r1, c2" instruction sequence.
Value *SimplifyShrShlDemandedBits(Instruction *Lsr, Instruction *Sftl,
APInt DemandedMask, APInt &KnownZero,
const APInt &DemandedMask, APInt &KnownZero,
APInt &KnownOne);
/// \brief Tries to simplify operands to an integer instruction based on its

View File

@ -68,7 +68,7 @@ bool InstCombiner::SimplifyDemandedInstructionBits(Instruction &Inst) {
/// SimplifyDemandedBits - This form of SimplifyDemandedBits simplifies the
/// specified instruction operand if possible, updating it in place. It returns
/// true if it made any change and false otherwise.
bool InstCombiner::SimplifyDemandedBits(Use &U, APInt DemandedMask,
bool InstCombiner::SimplifyDemandedBits(Use &U, const APInt &DemandedMask,
APInt &KnownZero, APInt &KnownOne,
unsigned Depth) {
auto *UserI = dyn_cast<Instruction>(U.getUser());
@ -830,7 +830,10 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
/// As with SimplifyDemandedUseBits, it returns NULL if the simplification was
/// not successful.
Value *InstCombiner::SimplifyShrShlDemandedBits(Instruction *Shr,
Instruction *Shl, APInt DemandedMask, APInt &KnownZero, APInt &KnownOne) {
Instruction *Shl,
const APInt &DemandedMask,
APInt &KnownZero,
APInt &KnownOne) {
const APInt &ShlOp1 = cast<ConstantInt>(Shl->getOperand(1))->getValue();
const APInt &ShrOp1 = cast<ConstantInt>(Shr->getOperand(1))->getValue();

View File

@ -493,7 +493,7 @@ struct LoopInterchange : public FunctionPass {
return true;
}
unsigned selectLoopForInterchange(LoopVector LoopList) {
unsigned selectLoopForInterchange(const LoopVector &LoopList) {
// TODO: Add a better heuristic to select the loop to be interchanged based
// on the dependence matrix. Currently we select the innermost loop.
return LoopList.size() - 1;

View File

@ -76,7 +76,7 @@ public:
// command line arguments into instance variables of BugDriver.
//
bool addSources(const std::vector<std::string> &FileNames);
void addPass(std::string p) { PassesToRun.push_back(p); }
void addPass(std::string p) { PassesToRun.push_back(std::move(p)); }
void setPassesToRun(const std::vector<std::string> &PTR) {
PassesToRun = PTR;
}
@ -183,7 +183,7 @@ public:
/// Error.
///
std::string executeProgramSafely(const Module *Program,
std::string OutputFile,
const std::string &OutputFile,
std::string *Error) const;
/// createReferenceFile - calls compileProgram and then records the output

View File

@ -384,7 +384,7 @@ std::string BugDriver::executeProgram(const Module *Program,
/// backend, if reference output is not provided.
///
std::string BugDriver::executeProgramSafely(const Module *Program,
std::string OutputFile,
const std::string &OutputFile,
std::string *Error) const {
return executeProgram(Program, OutputFile, "", "", SafeInterpreter, Error);
}

View File

@ -531,7 +531,7 @@ public:
/// original \p Entries.
void emitRangesEntries(
int64_t UnitPcOffset, uint64_t OrigLowPc,
FunctionIntervals::const_iterator FuncRange,
const FunctionIntervals::const_iterator &FuncRange,
const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,
unsigned AddressSize);
@ -715,7 +715,7 @@ void DwarfStreamer::emitStrings(const NonRelocatableStringpool &Pool) {
/// sized addresses describing the ranges.
void DwarfStreamer::emitRangesEntries(
int64_t UnitPcOffset, uint64_t OrigLowPc,
FunctionIntervals::const_iterator FuncRange,
const FunctionIntervals::const_iterator &FuncRange,
const std::vector<DWARFDebugRangeList::RangeListEntry> &Entries,
unsigned AddressSize) {
MS->SwitchSection(MC->getObjectFileInfo()->getDwarfRangesSection());
@ -1416,7 +1416,7 @@ private:
/// \defgroup Helpers Various helper methods.
///
/// @{
bool createStreamer(Triple TheTriple, StringRef OutputFilename);
bool createStreamer(const Triple &TheTriple, StringRef OutputFilename);
/// \brief Attempt to load a debug object from disk.
ErrorOr<const object::ObjectFile &> loadObject(BinaryHolder &BinaryHolder,
@ -1744,7 +1744,8 @@ void DwarfLinker::reportWarning(const Twine &Warning, const DWARFUnit *Unit,
6 /* Indent */);
}
bool DwarfLinker::createStreamer(Triple TheTriple, StringRef OutputFilename) {
bool DwarfLinker::createStreamer(const Triple &TheTriple,
StringRef OutputFilename) {
if (Options.NoOutput)
return true;

View File

@ -72,7 +72,7 @@ public:
int run(Command Cmd, int argc, const char **argv);
typedef std::function<int(int, const char **)> CommandLineParserType;
typedef llvm::function_ref<int(int, const char **)> CommandLineParserType;
int show(int argc, const char **argv,
CommandLineParserType commandLineParser);

View File

@ -114,7 +114,7 @@ static void DumpInput(StringRef Filename) {
/// If the input path is a .dSYM bundle (as created by the dsymutil tool),
/// replace it with individual entries for each of the object files inside the
/// bundle otherwise return the input path.
static std::vector<std::string> expandBundle(std::string InputPath) {
static std::vector<std::string> expandBundle(const std::string &InputPath) {
std::vector<std::string> BundlePaths;
SmallString<256> BundlePath(InputPath);
// Manually open up the bundle to avoid introducing additional dependencies.

View File

@ -597,8 +597,8 @@ static void darwinPrintStab(MachOObjectFile *MachO, SymbolListT::iterator I) {
}
static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName,
std::string ArchiveName,
std::string ArchitectureName) {
const std::string &ArchiveName,
const std::string &ArchitectureName) {
if (!NoSort) {
std::function<bool(const NMSymbol &, const NMSymbol &)> Cmp;
if (NumericSort)
@ -963,10 +963,10 @@ static unsigned getNsectInMachO(MachOObjectFile &Obj, BasicSymbolRef Sym) {
return (STE.n_type & MachO::N_TYPE) == MachO::N_SECT ? STE.n_sect : 0;
}
static void dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
std::string ArchiveName = std::string(),
std::string ArchitectureName =
std::string()) {
static void
dumpSymbolNamesFromObject(SymbolicFile &Obj, bool printName,
const std::string &ArchiveName = std::string(),
const std::string &ArchitectureName = std::string()) {
auto Symbols = Obj.symbols();
if (DynamicSyms) {
const auto *E = dyn_cast<ELFObjectFileBase>(&Obj);

View File

@ -116,7 +116,7 @@ namespace {
/// If this is the first time a node with unique identifier Name has been
/// seen, record it. Otherwise, emit a check to make sure this is the same
/// node. Returns true if this is the first encounter.
bool recordUniqueNode(std::string Name);
bool recordUniqueNode(const std::string &Name);
// Result Code Generation.
unsigned getNamedArgumentSlot(StringRef Name) {
@ -438,7 +438,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N,
}
}
bool MatcherGen::recordUniqueNode(std::string Name) {
bool MatcherGen::recordUniqueNode(const std::string &Name) {
unsigned &VarMapEntry = VariableMap[Name];
if (VarMapEntry == 0) {
// If it is a named node, we must emit a 'Record' opcode.

View File

@ -96,12 +96,11 @@ using namespace llvm::X86Disassembler;
namespace llvm {
extern void EmitFixedLenDecoder(RecordKeeper &RK, raw_ostream &OS,
std::string PredicateNamespace,
std::string GPrefix,
std::string GPostfix,
std::string ROK,
std::string RFail,
std::string L);
const std::string &PredicateNamespace,
const std::string &GPrefix,
const std::string &GPostfix,
const std::string &ROK,
const std::string &RFail, const std::string &L);
void EmitDisassembler(RecordKeeper &Records, raw_ostream &OS) {
CodeGenTarget Target(Records);

View File

@ -2324,12 +2324,10 @@ void FixedLenDecoderEmitter::run(raw_ostream &o) {
namespace llvm {
void EmitFixedLenDecoder(RecordKeeper &RK, raw_ostream &OS,
std::string PredicateNamespace,
std::string GPrefix,
std::string GPostfix,
std::string ROK,
std::string RFail,
std::string L) {
const std::string &PredicateNamespace,
const std::string &GPrefix,
const std::string &GPostfix, const std::string &ROK,
const std::string &RFail, const std::string &L) {
FixedLenDecoderEmitter(RK, PredicateNamespace, GPrefix, GPostfix,
ROK, RFail, L).run(OS);
}

View File

@ -101,7 +101,7 @@ class SubtargetEmitter {
void EmitSchedClassTables(SchedClassTables &SchedTables, raw_ostream &OS);
void EmitProcessorModels(raw_ostream &OS);
void EmitProcessorLookup(raw_ostream &OS);
void EmitSchedModelHelpers(std::string ClassName, raw_ostream &OS);
void EmitSchedModelHelpers(const std::string &ClassName, raw_ostream &OS);
void EmitSchedModel(raw_ostream &OS);
void ParseFeaturesFunction(raw_ostream &OS, unsigned NumFeatures,
unsigned NumProcs);
@ -1268,7 +1268,7 @@ void SubtargetEmitter::EmitSchedModel(raw_ostream &OS) {
OS << "#undef DBGFIELD";
}
void SubtargetEmitter::EmitSchedModelHelpers(std::string ClassName,
void SubtargetEmitter::EmitSchedModelHelpers(const std::string &ClassName,
raw_ostream &OS) {
OS << "unsigned " << ClassName
<< "\n::resolveSchedClass(unsigned SchedClass, const MachineInstr *MI,"