Skip to content

Commit

Permalink
[LegacyPM] Use MapVector for OnTheFlyPassManagers.
Browse files Browse the repository at this point in the history
Currently the iteration order of OnTheFlyManagers is not deterministic
between executions, which means some of test/Other/opt-*-pipeline.ll
tests fail non-deterministically if an additional on-the-fly manager is
added, as in D45330.

By using MapVector, we always iterate in the insertion order. As we are
not removing elements, there shouldn't be a performance hit, except that
we store an additional vector with the keys.


Reviewers: efriedma, chandlerc, pcc, jhenderson

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D47317

llvm-svn: 333231
  • Loading branch information
fhahn committed May 24, 2018
1 parent 4a3e2dc commit a4ffa3a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/IR/LegacyPassManager.cpp
Expand Up @@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/IR/LegacyPassManager.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IRPrintingPasses.h"
Expand All @@ -29,7 +30,6 @@
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <map>
#include <unordered_set>
using namespace llvm;
using namespace llvm::legacy;
Expand Down Expand Up @@ -414,8 +414,8 @@ class MPPassManager : public Pass, public PMDataManager {
for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) {
ModulePass *MP = getContainedPass(Index);
MP->dumpPassStructure(Offset + 1);
std::map<Pass *, FunctionPassManagerImpl *>::const_iterator I =
OnTheFlyManagers.find(MP);
MapVector<Pass *, FunctionPassManagerImpl *>::const_iterator I =
OnTheFlyManagers.find(MP);
if (I != OnTheFlyManagers.end())
I->second->dumpPassStructure(Offset + 2);
dumpLastUses(MP, Offset+1);
Expand All @@ -434,7 +434,7 @@ class MPPassManager : public Pass, public PMDataManager {
private:
/// Collection of on the fly FPPassManagers. These managers manage
/// function passes that are required by module passes.
std::map<Pass *, FunctionPassManagerImpl *> OnTheFlyManagers;
MapVector<Pass *, FunctionPassManagerImpl *> OnTheFlyManagers;
};

char MPPassManager::ID = 0;
Expand Down

0 comments on commit a4ffa3a

Please sign in to comment.