diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h index 6048502705e9..0670af8eda0a 100644 --- a/llvm/include/llvm/LTO/LTO.h +++ b/llvm/include/llvm/LTO/LTO.h @@ -58,10 +58,10 @@ public: /// emit a copy), and compile-time optimization (allow drop of duplicates). void thinLTOResolveWeakForLinkerInIndex( ModuleSummaryIndex &Index, - std::function + function_ref isPrevailing, - std::function isExported, - std::function + function_ref isExported, + function_ref recordNewLinkage); /// Update the linkages in the given \p Index to mark exported values @@ -69,8 +69,7 @@ void thinLTOResolveWeakForLinkerInIndex( /// must apply the changes to the Module via thinLTOInternalizeModule. void thinLTOInternalizeAndPromoteInIndex( ModuleSummaryIndex &Index, - std::function isExported); - + function_ref isExported); } #endif diff --git a/llvm/include/llvm/Support/Printable.h b/llvm/include/llvm/Support/Printable.h index 5c1b8d5070d4..016499ea2a3d 100644 --- a/llvm/include/llvm/Support/Printable.h +++ b/llvm/include/llvm/Support/Printable.h @@ -39,7 +39,7 @@ class Printable { public: std::function Print; Printable(const std::function Print) - : Print(Print) {} + : Print(std::move(Print)) {} }; static inline raw_ostream &operator<<(raw_ostream &OS, const Printable &P) { diff --git a/llvm/include/llvm/Transforms/Utils/Cloning.h b/llvm/include/llvm/Transforms/Utils/Cloning.h index 2ff9b84d3ff4..c5fb37007090 100644 --- a/llvm/include/llvm/Transforms/Utils/Cloning.h +++ b/llvm/include/llvm/Transforms/Utils/Cloning.h @@ -59,7 +59,7 @@ std::unique_ptr CloneModule(const Module *M, ValueToValueMapTy &VMap); /// in place of the global definition. std::unique_ptr CloneModule(const Module *M, ValueToValueMapTy &VMap, - std::function ShouldCloneDefinition); + function_ref ShouldCloneDefinition); /// ClonedCodeInfo - This struct can be used to capture information about code /// being cloned, while it is being cloned. diff --git a/llvm/include/llvm/Transforms/Utils/SplitModule.h b/llvm/include/llvm/Transforms/Utils/SplitModule.h index fa1d2dc28f81..b7a3bcf4f86a 100644 --- a/llvm/include/llvm/Transforms/Utils/SplitModule.h +++ b/llvm/include/llvm/Transforms/Utils/SplitModule.h @@ -16,7 +16,7 @@ #ifndef LLVM_TRANSFORMS_UTILS_SPLITMODULE_H #define LLVM_TRANSFORMS_UTILS_SPLITMODULE_H -#include +#include "llvm/ADT/STLExtras.h" #include namespace llvm { @@ -36,7 +36,7 @@ class StringRef; /// each partition. void SplitModule( std::unique_ptr M, unsigned N, - std::function MPart)> ModuleCallback, + function_ref MPart)> ModuleCallback, bool PreserveLocals = false); } // End llvm namespace diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp index 433ba9468e45..4b26b6436191 100644 --- a/llvm/lib/CodeGen/AtomicExpandPass.cpp +++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp @@ -59,7 +59,7 @@ namespace { bool tryExpandAtomicRMW(AtomicRMWInst *AI); bool expandAtomicOpToLLSC( Instruction *I, Value *Addr, AtomicOrdering MemOpOrder, - std::function &, Value *)> PerformOp); + function_ref &, Value *)> PerformOp); AtomicCmpXchgInst *convertCmpXchgToIntegerType(AtomicCmpXchgInst *CI); bool expandAtomicCmpXchg(AtomicCmpXchgInst *CI); bool isIdempotentRMW(AtomicRMWInst *AI); @@ -514,7 +514,7 @@ bool AtomicExpand::tryExpandAtomicRMW(AtomicRMWInst *AI) { bool AtomicExpand::expandAtomicOpToLLSC( Instruction *I, Value *Addr, AtomicOrdering MemOpOrder, - std::function &, Value *)> PerformOp) { + function_ref &, Value *)> PerformOp) { BasicBlock *BB = I->getParent(); Function *F = BB->getParent(); LLVMContext &Ctx = F->getContext(); diff --git a/llvm/lib/CodeGen/IfConversion.cpp b/llvm/lib/CodeGen/IfConversion.cpp index 5fd18ed2fe2c..4cdad607f762 100644 --- a/llvm/lib/CodeGen/IfConversion.cpp +++ b/llvm/lib/CodeGen/IfConversion.cpp @@ -1840,5 +1840,5 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) { FunctionPass * llvm::createIfConverter(std::function Ftor) { - return new IfConverter(Ftor); + return new IfConverter(std::move(Ftor)); } diff --git a/llvm/lib/CodeGen/MachineInstrBundle.cpp b/llvm/lib/CodeGen/MachineInstrBundle.cpp index cbfbf1d12055..e4686b3c5c4e 100644 --- a/llvm/lib/CodeGen/MachineInstrBundle.cpp +++ b/llvm/lib/CodeGen/MachineInstrBundle.cpp @@ -79,7 +79,7 @@ bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) { FunctionPass * llvm::createUnpackMachineBundles(std::function Ftor) { - return new UnpackMachineBundles(Ftor); + return new UnpackMachineBundles(std::move(Ftor)); } namespace { diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 11ffb59f604d..094b0c6b31ad 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -43,10 +43,10 @@ std::unique_ptr loadModuleFromBuffer(const MemoryBufferRef &Buffer, static void thinLTOResolveWeakForLinkerGUID( GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID, DenseSet &GlobalInvolvedWithAlias, - std::function + function_ref isPrevailing, - std::function isExported, - std::function + function_ref isExported, + function_ref recordNewLinkage) { auto HasMultipleCopies = GVSummaryList.size() > 1; @@ -87,10 +87,10 @@ static void thinLTOResolveWeakForLinkerGUID( // one copy. void thinLTOResolveWeakForLinkerInIndex( ModuleSummaryIndex &Index, - std::function + function_ref isPrevailing, - std::function isExported, - std::function + function_ref isExported, + function_ref recordNewLinkage) { if (Index.modulePaths().size() == 1) // Nothing to do if we don't have multiple modules @@ -112,7 +112,7 @@ void thinLTOResolveWeakForLinkerInIndex( static void thinLTOInternalizeAndPromoteGUID( GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID, - std::function isExported) { + function_ref isExported) { for (auto &S : GVSummaryList) { if (isExported(S->modulePath(), GUID)) { if (GlobalValue::isLocalLinkage(S->linkage())) @@ -126,7 +126,7 @@ static void thinLTOInternalizeAndPromoteGUID( // as external and non-exported values as internal. void thinLTOInternalizeAndPromoteInIndex( ModuleSummaryIndex &Index, - std::function isExported) { + function_ref isExported) { for (auto &I : Index) thinLTOInternalizeAndPromoteGUID(I.second, I.first, isExported); } diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index 9c122f9af055..d2c6d78abe22 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -1342,7 +1342,7 @@ Error IRMover::move( std::unique_ptr Src, ArrayRef ValuesToLink, std::function AddLazyFor) { IRLinker TheIRLinker(Composite, SharedMDs, IdentifiedStructTypes, - std::move(Src), ValuesToLink, AddLazyFor); + std::move(Src), ValuesToLink, std::move(AddLazyFor)); Error E = TheIRLinker.run(); Composite.dropTriviallyDeadConstantArrays(); return E; diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp index 9ac1920a9202..4b6cc6524f56 100644 --- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp +++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp @@ -112,8 +112,8 @@ void GCNHazardRecognizer::RecedeCycle() { // Helper Functions //===----------------------------------------------------------------------===// -int GCNHazardRecognizer::getWaitStatesSinceDef(unsigned Reg, - std::function IsHazardDef ) { +int GCNHazardRecognizer::getWaitStatesSinceDef( + unsigned Reg, function_ref IsHazardDef) { const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo(); diff --git a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h index 7fde1d9116b0..3c0a80844b5d 100644 --- a/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h +++ b/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h @@ -14,8 +14,8 @@ #ifndef LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H #define LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H +#include "llvm/ADT/STLExtras.h" #include "llvm/CodeGen/ScheduleHazardRecognizer.h" -#include #include namespace llvm { @@ -35,8 +35,8 @@ class GCNHazardRecognizer final : public ScheduleHazardRecognizer { const MachineFunction &MF; int getWaitStatesSinceDef(unsigned Reg, - std::function IsHazardDef = - [](MachineInstr*) {return true;}); + function_ref IsHazardDef = + [](MachineInstr *) { return true; }); int checkSMEMSoftClauseHazards(MachineInstr *SMEM); int checkSMRDHazards(MachineInstr *SMRD); diff --git a/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp b/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp index a21bd05ea4e9..e1b126650d81 100644 --- a/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp +++ b/llvm/lib/Target/ARM/Thumb2SizeReduction.cpp @@ -1098,5 +1098,5 @@ bool Thumb2SizeReduce::runOnMachineFunction(MachineFunction &MF) { /// reduction pass. FunctionPass *llvm::createThumb2SizeReductionPass( std::function Ftor) { - return new Thumb2SizeReduce(Ftor); + return new Thumb2SizeReduce(std::move(Ftor)); } diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp index bd614c1f7375..45296091e289 100644 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -98,7 +98,7 @@ void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); } void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); } void MipsTargetStreamer::emitDirectiveCpLoad(unsigned RegNo) {} bool MipsTargetStreamer::emitDirectiveCpRestore( - int Offset, std::function GetATReg, SMLoc IDLoc, + int Offset, function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) { forbidModuleDirective(); return true; @@ -229,7 +229,7 @@ void MipsTargetStreamer::emitGPRestore(int Offset, SMLoc IDLoc, /// Emit a store instruction with an immediate offset. void MipsTargetStreamer::emitStoreWithImmOffset( unsigned Opcode, unsigned SrcReg, unsigned BaseReg, int64_t Offset, - std::function GetATReg, SMLoc IDLoc, + function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) { if (isInt<16>(Offset)) { emitRRI(Opcode, SrcReg, BaseReg, Offset, IDLoc, STI); @@ -586,7 +586,7 @@ void MipsTargetAsmStreamer::emitDirectiveCpLoad(unsigned RegNo) { } bool MipsTargetAsmStreamer::emitDirectiveCpRestore( - int Offset, std::function GetATReg, SMLoc IDLoc, + int Offset, function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) { MipsTargetStreamer::emitDirectiveCpRestore(Offset, GetATReg, IDLoc, STI); OS << "\t.cprestore\t" << Offset << "\n"; @@ -1049,7 +1049,7 @@ void MipsTargetELFStreamer::emitDirectiveCpLoad(unsigned RegNo) { } bool MipsTargetELFStreamer::emitDirectiveCpRestore( - int Offset, std::function GetATReg, SMLoc IDLoc, + int Offset, function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) { MipsTargetStreamer::emitDirectiveCpRestore(Offset, GetATReg, IDLoc, STI); // .cprestore offset diff --git a/llvm/lib/Target/Mips/MipsTargetStreamer.h b/llvm/lib/Target/Mips/MipsTargetStreamer.h index 01eee489c702..41ebe411b98d 100644 --- a/llvm/lib/Target/Mips/MipsTargetStreamer.h +++ b/llvm/lib/Target/Mips/MipsTargetStreamer.h @@ -13,10 +13,10 @@ #include "MCTargetDesc/MipsABIFlagsSection.h" #include "MCTargetDesc/MipsABIInfo.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/MC/MCELFStreamer.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCStreamer.h" -#include namespace llvm { @@ -84,7 +84,7 @@ public: // PIC support virtual void emitDirectiveCpLoad(unsigned RegNo); virtual bool emitDirectiveCpRestore(int Offset, - std::function GetATReg, + function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI); virtual void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, const MCSymbol &Sym, bool IsReg); @@ -133,7 +133,7 @@ public: /// by reporting an error). void emitStoreWithImmOffset(unsigned Opcode, unsigned SrcReg, unsigned BaseReg, int64_t Offset, - std::function GetATReg, SMLoc IDLoc, + function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI); void emitStoreWithSymOffset(unsigned Opcode, unsigned SrcReg, unsigned BaseReg, MCOperand &HiOperand, @@ -255,7 +255,7 @@ public: /// temporary and is only called when the assembler temporary is required. It /// must handle the case where no assembler temporary is available (typically /// by reporting an error). - bool emitDirectiveCpRestore(int Offset, std::function GetATReg, + bool emitDirectiveCpRestore(int Offset, function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) override; void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, const MCSymbol &Sym, bool IsReg) override; @@ -311,7 +311,7 @@ public: // PIC support void emitDirectiveCpLoad(unsigned RegNo) override; - bool emitDirectiveCpRestore(int Offset, std::function GetATReg, + bool emitDirectiveCpRestore(int Offset, function_ref GetATReg, SMLoc IDLoc, const MCSubtargetInfo *STI) override; void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset, const MCSymbol &Sym, bool IsReg) override; diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp index cf6a43e752ca..2d0a21d2c518 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -241,5 +241,5 @@ INITIALIZE_PASS_END(CFGSimplifyPass, "simplifycfg", "Simplify the CFG", false, FunctionPass * llvm::createCFGSimplificationPass(int Threshold, std::function Ftor) { - return new CFGSimplifyPass(Threshold, Ftor); + return new CFGSimplifyPass(Threshold, std::move(Ftor)); } diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index 6fb86da9cc0e..4eed60492a74 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/lib/Transforms/Utils/CloneModule.cpp @@ -38,7 +38,7 @@ std::unique_ptr llvm::CloneModule(const Module *M, std::unique_ptr llvm::CloneModule( const Module *M, ValueToValueMapTy &VMap, - std::function ShouldCloneDefinition) { + function_ref ShouldCloneDefinition) { // First off, we need to create the new module. std::unique_ptr New = llvm::make_unique(M->getModuleIdentifier(), M->getContext()); diff --git a/llvm/lib/Transforms/Utils/SplitModule.cpp b/llvm/lib/Transforms/Utils/SplitModule.cpp index 3db04b8b34c6..e9a368f4faa4 100644 --- a/llvm/lib/Transforms/Utils/SplitModule.cpp +++ b/llvm/lib/Transforms/Utils/SplitModule.cpp @@ -227,7 +227,7 @@ static bool isInPartition(const GlobalValue *GV, unsigned I, unsigned N) { void llvm::SplitModule( std::unique_ptr M, unsigned N, - std::function MPart)> ModuleCallback, + function_ref MPart)> ModuleCallback, bool PreserveLocals) { if (!PreserveLocals) { for (Function &F : *M)