From a4ffa3accf25c0f57f3cdef74bc1a3fdd8cfc0be Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Thu, 24 May 2018 21:33:17 +0000 Subject: [PATCH] [LegacyPM] Use MapVector for OnTheFlyPassManagers. 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 --- llvm/lib/IR/LegacyPassManager.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/IR/LegacyPassManager.cpp b/llvm/lib/IR/LegacyPassManager.cpp index 6f3da0245c131..b04787cb30ebb 100644 --- a/llvm/lib/IR/LegacyPassManager.cpp +++ b/llvm/lib/IR/LegacyPassManager.cpp @@ -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" @@ -29,7 +30,6 @@ #include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" #include -#include #include using namespace llvm; using namespace llvm::legacy; @@ -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::const_iterator I = - OnTheFlyManagers.find(MP); + MapVector::const_iterator I = + OnTheFlyManagers.find(MP); if (I != OnTheFlyManagers.end()) I->second->dumpPassStructure(Offset + 2); dumpLastUses(MP, Offset+1); @@ -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 OnTheFlyManagers; + MapVector OnTheFlyManagers; }; char MPPassManager::ID = 0;