Index: lib/Transforms/Scalar/ADCE.cpp =================================================================== --- lib/Transforms/Scalar/ADCE.cpp +++ lib/Transforms/Scalar/ADCE.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/MapVector.h" #include "llvm/ADT/PostOrderIterator.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -118,7 +119,8 @@ PostDominatorTree &PDT; /// Mapping of blocks to associated information, an element in BlockInfoVec. - DenseMap BlockInfo; + /// Use MapVector to get deterministic iteration order. + MapVector BlockInfo; bool isLive(BasicBlock *BB) { return BlockInfo[BB].Live; } /// Mapping of instructions to associated information. @@ -209,11 +211,6 @@ } void AggressiveDeadCodeElimination::initialize() { - auto NumBlocks = F.size(); - - // We will have an entry in the map for each block so we grow the - // structure to twice that size to keep the load factor low in the hash table. - BlockInfo.reserve(NumBlocks); size_t NumInsts = 0; // Iterate over blocks and initialize BlockInfoVec entries, count