#include "llvm/iTerminators.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
+#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/FunctionUtils.h"
virtual bool runOnFunction(Function &F);
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+ AU.addRequired<DominatorSet>();
AU.addRequired<LoopInfo>();
AU.addRequiredID(LoopSimplifyID);
}
if (LI.begin() == LI.end())
return false;
+ DominatorSet &DS = getAnalysis<DominatorSet>();
+
// If there is more than one top-level loop in this function, extract all of
// the loops.
bool Changed = false;
for (LoopInfo::iterator i = LI.begin(), e = LI.end(); i != e; ++i) {
if (NumLoops == 0) return Changed;
--NumLoops;
- Changed |= (ExtractLoop(*i) != 0);
+ Changed |= ExtractLoop(DS, *i) != 0;
}
} else {
// Otherwise there is exactly one top-level loop. If this function is more
if (ShouldExtractLoop) {
if (NumLoops == 0) return Changed;
--NumLoops;
- Changed |= (ExtractLoop(TLL) != 0);
+ Changed |= ExtractLoop(DS, TLL) != 0;
} else {
// Okay, this function is a minimal container around the specified loop.
// If we extract the loop, we will continue to just keep extracting it
for (Loop::iterator i = TLL->begin(), e = TLL->end(); i != e; ++i) {
if (NumLoops == 0) return Changed;
--NumLoops;
- Changed |= (ExtractLoop(*i) != 0);
+ Changed |= ExtractLoop(DS, *i) != 0;
}
}
}