diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 | 
| commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
| tree | 4def12e759965de927d963ac65840d663ef9d1ea /include/llvm/Transforms/InstCombine | |
| parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) | |
Diffstat (limited to 'include/llvm/Transforms/InstCombine')
| -rw-r--r-- | include/llvm/Transforms/InstCombine/InstCombine.h | 32 | ||||
| -rw-r--r-- | include/llvm/Transforms/InstCombine/InstCombineWorklist.h | 3 | 
2 files changed, 30 insertions, 5 deletions
| diff --git a/include/llvm/Transforms/InstCombine/InstCombine.h b/include/llvm/Transforms/InstCombine/InstCombine.h index f48ec13107bc9..d70b847c68921 100644 --- a/include/llvm/Transforms/InstCombine/InstCombine.h +++ b/include/llvm/Transforms/InstCombine/InstCombine.h @@ -24,23 +24,47 @@  namespace llvm { -class InstCombinePass { +class InstCombinePass : public PassInfoMixin<InstCombinePass> {    InstCombineWorklist Worklist; +  bool ExpensiveCombines;  public:    static StringRef name() { return "InstCombinePass"; }    // Explicitly define constructors for MSVC. -  InstCombinePass() {} -  InstCombinePass(InstCombinePass &&Arg) : Worklist(std::move(Arg.Worklist)) {} +  InstCombinePass(bool ExpensiveCombines = true) +      : ExpensiveCombines(ExpensiveCombines) {} +  InstCombinePass(InstCombinePass &&Arg) +      : Worklist(std::move(Arg.Worklist)), +        ExpensiveCombines(Arg.ExpensiveCombines) {}    InstCombinePass &operator=(InstCombinePass &&RHS) {      Worklist = std::move(RHS.Worklist); +    ExpensiveCombines = RHS.ExpensiveCombines;      return *this;    } -  PreservedAnalyses run(Function &F, AnalysisManager<Function> *AM); +  PreservedAnalyses run(Function &F, AnalysisManager<Function> &AM);  }; +/// \brief The legacy pass manager's instcombine pass. +/// +/// This is a basic whole-function wrapper around the instcombine utility. It +/// will try to combine all instructions in the function. +class InstructionCombiningPass : public FunctionPass { +  InstCombineWorklist Worklist; +  const bool ExpensiveCombines; + +public: +  static char ID; // Pass identification, replacement for typeid + +  InstructionCombiningPass(bool ExpensiveCombines = true) +      : FunctionPass(ID), ExpensiveCombines(ExpensiveCombines) { +    initializeInstructionCombiningPassPass(*PassRegistry::getPassRegistry()); +  } + +  void getAnalysisUsage(AnalysisUsage &AU) const override; +  bool runOnFunction(Function &F) override; +};  }  #endif diff --git a/include/llvm/Transforms/InstCombine/InstCombineWorklist.h b/include/llvm/Transforms/InstCombine/InstCombineWorklist.h index 5d2b2d000009e..32af035d07d4f 100644 --- a/include/llvm/Transforms/InstCombine/InstCombineWorklist.h +++ b/include/llvm/Transforms/InstCombine/InstCombineWorklist.h @@ -11,6 +11,7 @@  #define LLVM_TRANSFORMS_INSTCOMBINE_INSTCOMBINEWORKLIST_H  #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/SmallVector.h"  #include "llvm/IR/Instruction.h"  #include "llvm/Support/Compiler.h" @@ -63,7 +64,7 @@ public:    void AddInitialGroup(ArrayRef<Instruction *> List) {      assert(Worklist.empty() && "Worklist must be empty to add initial group");      Worklist.reserve(List.size()+16); -    WorklistMap.resize(List.size()); +    WorklistMap.reserve(List.size());      DEBUG(dbgs() << "IC: ADDING: " << List.size() << " instrs to worklist\n");      unsigned Idx = 0;      for (Instruction *I : reverse(List)) { | 
