diff options
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)) { |
