Require 'simplified' loops, not just raw natural loops. This fixes
CodeExtractor/2004-03-13-LoopExtractorCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12381
91177308-0d34-0410-b5e6-
96231b3b80d8
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/FunctionUtils.h"
using namespace llvm;
namespace {
// FIXME: PassManager should allow Module passes to require FunctionPasses
struct LoopExtractor : public FunctionPass {
#include "llvm/Transforms/Utils/FunctionUtils.h"
using namespace llvm;
namespace {
// FIXME: PassManager should allow Module passes to require FunctionPasses
struct LoopExtractor : public FunctionPass {
- virtual bool run(Module &M);
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<LoopInfo>();
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<LoopInfo>();
+ AU.addRequiredID(LoopSimplifyID);
X("loop-extract", "Extract loops into new functions");
} // End anonymous namespace
X("loop-extract", "Extract loops into new functions");
} // End anonymous namespace
-bool LoopExtractor::run(Module &M) {
- bool Changed = false;
- for (Module::iterator i = M.begin(), e = M.end(); i != e; ++i)
- Changed |= runOnFunction(*i);
- return Changed;
-}
-
bool LoopExtractor::runOnFunction(Function &F) {
std::cerr << F.getName() << "\n";
bool LoopExtractor::runOnFunction(Function &F) {
std::cerr << F.getName() << "\n";