#define POLLY_SCOP_DETECTION_H
#include "llvm/Pass.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/AliasSetTracker.h"
#include "polly/ScopDetectionDiagnostic.h"
/// @brief Pass to detect the maximal static control parts (Scops) of a
/// function.
class ScopDetection : public FunctionPass {
+public:
+ typedef SetVector<const Region *> RegionSet;
+
+private:
//===--------------------------------------------------------------------===//
ScopDetection(const ScopDetection &) LLVM_DELETED_FUNCTION;
const ScopDetection &operator=(const ScopDetection &) LLVM_DELETED_FUNCTION;
};
// Remember the valid regions
- typedef std::set<const Region *> RegionSet;
RegionSet ValidRegions;
// Remember a list of errors for every region.
// but do not recurse further if the first child has been found.
//
// Return the number of regions erased from Regs.
-static unsigned eraseAllChildren(std::set<const Region *> &Regs,
+static unsigned eraseAllChildren(ScopDetection::RegionSet &Regs,
const Region &R) {
unsigned Count = 0;
for (auto &SubRegion : R) {
- if (Regs.find(SubRegion.get()) != Regs.end()) {
+ if (Regs.count(SubRegion.get())) {
++Count;
- Regs.erase(SubRegion.get());
+ Regs.remove(SubRegion.get());
} else {
Count += eraseAllChildren(Regs, *SubRegion);
}
// Skip invalid regions. Regions may become invalid, if they are element of
// an already expanded region.
- if (ValidRegions.find(CurrentRegion) == ValidRegions.end())
+ if (!ValidRegions.count(CurrentRegion))
continue;
Region *ExpandedR = expandRegion(*CurrentRegion);
R.addSubRegion(ExpandedR, true);
ValidRegions.insert(ExpandedR);
- ValidRegions.erase(CurrentRegion);
+ ValidRegions.remove(CurrentRegion);
// Erase all (direct and indirect) children of ExpandedR from the valid
// regions and update the number of valid regions.