]> granicus.if.org Git - llvm/commitdiff
Move instances of std::function.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 12 Jun 2016 16:13:55 +0000 (16:13 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 12 Jun 2016 16:13:55 +0000 (16:13 +0000)
Or replace with llvm::function_ref if it's never stored. NFC intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272513 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/llvm/LTO/LTO.h
include/llvm/Support/Printable.h
include/llvm/Transforms/Utils/Cloning.h
include/llvm/Transforms/Utils/SplitModule.h
lib/CodeGen/AtomicExpandPass.cpp
lib/CodeGen/IfConversion.cpp
lib/CodeGen/MachineInstrBundle.cpp
lib/LTO/LTO.cpp
lib/Linker/IRMover.cpp
lib/Target/AMDGPU/GCNHazardRecognizer.cpp
lib/Target/AMDGPU/GCNHazardRecognizer.h
lib/Target/ARM/Thumb2SizeReduction.cpp
lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
lib/Target/Mips/MipsTargetStreamer.h
lib/Transforms/Scalar/SimplifyCFGPass.cpp
lib/Transforms/Utils/CloneModule.cpp
lib/Transforms/Utils/SplitModule.cpp

index 6048502705e9b9600042e19e62e22b57ff465546..0670af8eda0a510c401aa8dbd7416f3328a3e0c3 100644 (file)
@@ -58,10 +58,10 @@ public:
 /// emit a copy), and compile-time optimization (allow drop of duplicates).
 void thinLTOResolveWeakForLinkerInIndex(
     ModuleSummaryIndex &Index,
-    std::function<bool(GlobalValue::GUID, const GlobalValueSummary *)>
+    function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
         isPrevailing,
-    std::function<bool(StringRef, GlobalValue::GUID)> isExported,
-    std::function<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
+    function_ref<bool(StringRef, GlobalValue::GUID)> isExported,
+    function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
         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<bool(StringRef, GlobalValue::GUID)> isExported);
-
+    function_ref<bool(StringRef, GlobalValue::GUID)> isExported);
 }
 
 #endif
index 5c1b8d5070d43318fd1a1a8eadc1da183b27f372..016499ea2a3dabf67a17139c61bc00d254ecc7b1 100644 (file)
@@ -39,7 +39,7 @@ class Printable {
 public:
   std::function<void(raw_ostream &OS)> Print;
   Printable(const std::function<void(raw_ostream &OS)> Print)
-    : Print(Print) {}
+      : Print(std::move(Print)) {}
 };
 
 static inline raw_ostream &operator<<(raw_ostream &OS, const Printable &P) {
index 2ff9b84d3ff4155248dccb8540ba33e6994590fd..c5fb37007090078d6a566de341f048ec11fe3a4a 100644 (file)
@@ -59,7 +59,7 @@ std::unique_ptr<Module> CloneModule(const Module *M, ValueToValueMapTy &VMap);
 /// in place of the global definition.
 std::unique_ptr<Module>
 CloneModule(const Module *M, ValueToValueMapTy &VMap,
-            std::function<bool(const GlobalValue *)> ShouldCloneDefinition);
+            function_ref<bool(const GlobalValue *)> ShouldCloneDefinition);
 
 /// ClonedCodeInfo - This struct can be used to capture information about code
 /// being cloned, while it is being cloned.
index fa1d2dc28f81ca73aab4be21fb1d518fcb60354e..b7a3bcf4f86a537aead2234a84507d16030e47c7 100644 (file)
@@ -16,7 +16,7 @@
 #ifndef LLVM_TRANSFORMS_UTILS_SPLITMODULE_H
 #define LLVM_TRANSFORMS_UTILS_SPLITMODULE_H
 
-#include <functional>
+#include "llvm/ADT/STLExtras.h"
 #include <memory>
 
 namespace llvm {
@@ -36,7 +36,7 @@ class StringRef;
 ///   each partition.
 void SplitModule(
     std::unique_ptr<Module> M, unsigned N,
-    std::function<void(std::unique_ptr<Module> MPart)> ModuleCallback,
+    function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback,
     bool PreserveLocals = false);
 
 } // End llvm namespace
index 433ba9468e451fd18d1df81e05943f5055a7066e..4b26b643619149faa34850f74486635064f2e4e0 100644 (file)
@@ -59,7 +59,7 @@ namespace {
     bool tryExpandAtomicRMW(AtomicRMWInst *AI);
     bool expandAtomicOpToLLSC(
         Instruction *I, Value *Addr, AtomicOrdering MemOpOrder,
-        std::function<Value *(IRBuilder<> &, Value *)> PerformOp);
+        function_ref<Value *(IRBuilder<> &, 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 *(IRBuilder<> &, Value *)> PerformOp) {
+    function_ref<Value *(IRBuilder<> &, Value *)> PerformOp) {
   BasicBlock *BB = I->getParent();
   Function *F = BB->getParent();
   LLVMContext &Ctx = F->getContext();
index 5fd18ed2fe2c2b55d918567169f4ff2483e175d7..4cdad607f7622e6fb48cd08ef4a6e213efb4a329 100644 (file)
@@ -1840,5 +1840,5 @@ void IfConverter::MergeBlocks(BBInfo &ToBBI, BBInfo &FromBBI, bool AddEdges) {
 
 FunctionPass *
 llvm::createIfConverter(std::function<bool(const Function &)> Ftor) {
-  return new IfConverter(Ftor);
+  return new IfConverter(std::move(Ftor));
 }
index cbfbf1d120558af2fee9d31b008bc00d7f1a4987..e4686b3c5c4eb64bac44de57b0eb69786d3c9278 100644 (file)
@@ -79,7 +79,7 @@ bool UnpackMachineBundles::runOnMachineFunction(MachineFunction &MF) {
 
 FunctionPass *
 llvm::createUnpackMachineBundles(std::function<bool(const Function &)> Ftor) {
-  return new UnpackMachineBundles(Ftor);
+  return new UnpackMachineBundles(std::move(Ftor));
 }
 
 namespace {
index 11ffb59f604da30fa3454f5c8f260a72d374ce35..094b0c6b31ad0ed2e555618db1d829d2db99a90b 100644 (file)
@@ -43,10 +43,10 @@ std::unique_ptr<Module> loadModuleFromBuffer(const MemoryBufferRef &Buffer,
 static void thinLTOResolveWeakForLinkerGUID(
     GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID,
     DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias,
-    std::function<bool(GlobalValue::GUID, const GlobalValueSummary *)>
+    function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
         isPrevailing,
-    std::function<bool(StringRef, GlobalValue::GUID)> isExported,
-    std::function<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
+    function_ref<bool(StringRef, GlobalValue::GUID)> isExported,
+    function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
         recordNewLinkage) {
   auto HasMultipleCopies = GVSummaryList.size() > 1;
 
@@ -87,10 +87,10 @@ static void thinLTOResolveWeakForLinkerGUID(
 // one copy.
 void thinLTOResolveWeakForLinkerInIndex(
     ModuleSummaryIndex &Index,
-    std::function<bool(GlobalValue::GUID, const GlobalValueSummary *)>
+    function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
         isPrevailing,
-    std::function<bool(StringRef, GlobalValue::GUID)> isExported,
-    std::function<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
+    function_ref<bool(StringRef, GlobalValue::GUID)> isExported,
+    function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)>
         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<bool(StringRef, GlobalValue::GUID)> isExported) {
+    function_ref<bool(StringRef, GlobalValue::GUID)> 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<bool(StringRef, GlobalValue::GUID)> isExported) {
+    function_ref<bool(StringRef, GlobalValue::GUID)> isExported) {
   for (auto &I : Index)
     thinLTOInternalizeAndPromoteGUID(I.second, I.first, isExported);
 }
index 9c122f9af055a1ad1ebc4053da1449bbcbd0390c..d2c6d78abe22f6432803327a6162978feed408a1 100644 (file)
@@ -1342,7 +1342,7 @@ Error IRMover::move(
     std::unique_ptr<Module> Src, ArrayRef<GlobalValue *> ValuesToLink,
     std::function<void(GlobalValue &, ValueAdder Add)> 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;
index 9ac1920a9202209cedadfd0937b26c0454128fab..4b6cc6524f569e1ed144401d24ec288576437eb7 100644 (file)
@@ -112,8 +112,8 @@ void GCNHazardRecognizer::RecedeCycle() {
 // Helper Functions
 //===----------------------------------------------------------------------===//
 
-int GCNHazardRecognizer::getWaitStatesSinceDef(unsigned Reg,
-                              std::function<bool(MachineInstr*)> IsHazardDef ) {
+int GCNHazardRecognizer::getWaitStatesSinceDef(
+    unsigned Reg, function_ref<bool(MachineInstr *)> IsHazardDef) {
   const TargetRegisterInfo *TRI =
       MF.getSubtarget<AMDGPUSubtarget>().getRegisterInfo();
 
index 7fde1d9116b0b5a39be8429fc435518ee89ce0a1..3c0a80844b5db9f5f22227ace45d7e6c7cd5ab86 100644 (file)
@@ -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 <functional>
 #include <list>
 
 namespace llvm {
@@ -35,8 +35,8 @@ class GCNHazardRecognizer final : public ScheduleHazardRecognizer {
   const MachineFunction &MF;
 
   int getWaitStatesSinceDef(unsigned Reg,
-                            std::function<bool(MachineInstr*)> IsHazardDef =
-                            [](MachineInstr*) {return true;});
+                            function_ref<bool(MachineInstr *)> IsHazardDef =
+                                [](MachineInstr *) { return true; });
 
   int checkSMEMSoftClauseHazards(MachineInstr *SMEM);
   int checkSMRDHazards(MachineInstr *SMRD);
index a21bd05ea4e9b6ad2b0e1359eb4cf993eebae464..e1b126650d81a0566f3f821e37ff7ac0b5e1f316 100644 (file)
@@ -1098,5 +1098,5 @@ bool Thumb2SizeReduce::runOnMachineFunction(MachineFunction &MF) {
 /// reduction pass.
 FunctionPass *llvm::createThumb2SizeReductionPass(
     std::function<bool(const Function &)> Ftor) {
-  return new Thumb2SizeReduce(Ftor);
+  return new Thumb2SizeReduce(std::move(Ftor));
 }
index bd614c1f7375512654dc3f2d5eabad0b0913451c..45296091e2895f32f30e39e6bd92ffe046f9677e 100644 (file)
@@ -98,7 +98,7 @@ void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); }
 void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); }
 void MipsTargetStreamer::emitDirectiveCpLoad(unsigned RegNo) {}
 bool MipsTargetStreamer::emitDirectiveCpRestore(
-    int Offset, std::function<unsigned()> GetATReg, SMLoc IDLoc,
+    int Offset, function_ref<unsigned()> 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<unsigned()> GetATReg, SMLoc IDLoc,
+    function_ref<unsigned()> 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<unsigned()> GetATReg, SMLoc IDLoc,
+    int Offset, function_ref<unsigned()> 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<unsigned()> GetATReg, SMLoc IDLoc,
+    int Offset, function_ref<unsigned()> GetATReg, SMLoc IDLoc,
     const MCSubtargetInfo *STI) {
   MipsTargetStreamer::emitDirectiveCpRestore(Offset, GetATReg, IDLoc, STI);
   // .cprestore offset
index 01eee489c702f88ee980c32a9305a30d55878575..41ebe411b98d927f83d33c4637c5aa7020650573 100644 (file)
 #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 <functional>
 
 namespace llvm {
 
@@ -84,7 +84,7 @@ public:
   // PIC support
   virtual void emitDirectiveCpLoad(unsigned RegNo);
   virtual bool emitDirectiveCpRestore(int Offset,
-                                      std::function<unsigned()> GetATReg,
+                                      function_ref<unsigned()> 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<unsigned()> GetATReg, SMLoc IDLoc,
+                              function_ref<unsigned()> 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<unsigned()> GetATReg,
+  bool emitDirectiveCpRestore(int Offset, function_ref<unsigned()> 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<unsigned()> GetATReg,
+  bool emitDirectiveCpRestore(int Offset, function_ref<unsigned()> GetATReg,
                               SMLoc IDLoc, const MCSubtargetInfo *STI) override;
   void emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
                             const MCSymbol &Sym, bool IsReg) override;
index cf6a43e752ca4fe81ae83b51bae4f7c843273c74..2d0a21d2c518aa5b239b579d5d831cd6ebf43fc1 100644 (file)
@@ -241,5 +241,5 @@ INITIALIZE_PASS_END(CFGSimplifyPass, "simplifycfg", "Simplify the CFG", false,
 FunctionPass *
 llvm::createCFGSimplificationPass(int Threshold,
                                   std::function<bool(const Function &)> Ftor) {
-  return new CFGSimplifyPass(Threshold, Ftor);
+  return new CFGSimplifyPass(Threshold, std::move(Ftor));
 }
index 6fb86da9cc0eae4d354d3efff88fd41b4c990dee..4eed60492a74c09973e0f6bec3fff79daf9a59b3 100644 (file)
@@ -38,7 +38,7 @@ std::unique_ptr<Module> llvm::CloneModule(const Module *M,
 
 std::unique_ptr<Module> llvm::CloneModule(
     const Module *M, ValueToValueMapTy &VMap,
-    std::function<bool(const GlobalValue *)> ShouldCloneDefinition) {
+    function_ref<bool(const GlobalValue *)> ShouldCloneDefinition) {
   // First off, we need to create the new module.
   std::unique_ptr<Module> New =
       llvm::make_unique<Module>(M->getModuleIdentifier(), M->getContext());
index 3db04b8b34c6b33c0a6cdc4f62575da81e8c13ed..e9a368f4faa4ed13bc29aecb63c053dd32242068 100644 (file)
@@ -227,7 +227,7 @@ static bool isInPartition(const GlobalValue *GV, unsigned I, unsigned N) {
 
 void llvm::SplitModule(
     std::unique_ptr<Module> M, unsigned N,
-    std::function<void(std::unique_ptr<Module> MPart)> ModuleCallback,
+    function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback,
     bool PreserveLocals) {
   if (!PreserveLocals) {
     for (Function &F : *M)