From: David Peixotto Date: Wed, 22 Oct 2014 20:39:07 +0000 (+0000) Subject: Change the RegionSet type to a SetVector X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8da2b93d9fe57c4ca6f1560c0d9b61f61a14206b;p=platform%2Fupstream%2Fllvm.git Change the RegionSet type to a SetVector This patch changes the RegionSet type used in ScopDetection from a std::set to a llvm::SetVector. The reason for the change is to ensure deterministic output when printing the result of the analysis. We had a windows buildbot failure for the modified test because the output was coming in a different order. Only one test case needed to be modified for this change. We could use CHECK-DAG directives instead of CHECK in the analysis test cases because the actual order of scops does not matter, but I think that change should be done in a separate patch that modifies all the appliciable tests. I simply modified the test to reflect the expected deterministic output. Differential Revision: http://reviews.llvm.org/D5897 llvm-svn: 220423 --- diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h index c04b2c2..9753e38 100644 --- a/polly/include/polly/ScopDetection.h +++ b/polly/include/polly/ScopDetection.h @@ -48,6 +48,7 @@ #define POLLY_SCOP_DETECTION_H #include "llvm/Pass.h" +#include "llvm/ADT/SetVector.h" #include "llvm/Analysis/AliasSetTracker.h" #include "polly/ScopDetectionDiagnostic.h" @@ -118,6 +119,10 @@ extern llvm::StringRef PollySkipFnAttr; /// @brief Pass to detect the maximal static control parts (Scops) of a /// function. class ScopDetection : public FunctionPass { +public: + typedef SetVector RegionSet; + +private: //===--------------------------------------------------------------------===// ScopDetection(const ScopDetection &) LLVM_DELETED_FUNCTION; const ScopDetection &operator=(const ScopDetection &) LLVM_DELETED_FUNCTION; @@ -155,7 +160,6 @@ class ScopDetection : public FunctionPass { }; // Remember the valid regions - typedef std::set RegionSet; RegionSet ValidRegions; // Remember a list of errors for every region. diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index de74f82..234aa63 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -691,13 +691,13 @@ static bool regionWithoutLoops(Region &R, LoopInfo *LI) { // 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 &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); } @@ -740,7 +740,7 @@ void ScopDetection::findScops(Region &R) { // 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); @@ -750,7 +750,7 @@ void ScopDetection::findScops(Region &R) { 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. diff --git a/polly/test/ScopInfo/multi-scop.ll b/polly/test/ScopInfo/multi-scop.ll index 5f9e670..69926b2 100644 --- a/polly/test/ScopInfo/multi-scop.ll +++ b/polly/test/ScopInfo/multi-scop.ll @@ -33,6 +33,6 @@ for.end170: ; preds = %for.body81 ret void } -; CHECK: Valid Region for Scop: for.body81 => for.end170 ; CHECK: Valid Region for Scop: entry.split => for.end +; CHECK: Valid Region for Scop: for.body81 => for.end170