From 66827427e1ef0e14399f24b6711e704ed96a3362 Mon Sep 17 00:00:00 2001 From: Rong Xu Date: Wed, 16 Nov 2016 20:50:06 +0000 Subject: [PATCH] Make block placement deterministic We fail to produce bit-to-bit matching stage2 and stage3 compiler in PGO bootstrap build. The reason is because LoopBlockSet is of SmallPtrSet type whose iterating order depends on the pointer value. This patch fixes this issue by changing to use SmallSetVector. Differential Revision: http://reviews.llvm.org/D26634 llvm-svn: 287148 --- llvm/lib/CodeGen/MachineBlockPlacement.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index 2f43d2c..32c0bcf 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -264,7 +264,7 @@ public: namespace { class MachineBlockPlacement : public MachineFunctionPass { /// \brief A typedef for a block filter set. - typedef SmallPtrSet BlockFilterSet; + typedef SmallSetVector BlockFilterSet; /// \brief work lists of blocks that are ready to be laid out SmallVector BlockWorkList; @@ -1512,7 +1512,7 @@ void MachineBlockPlacement::buildLoopChains(MachineLoop &L) { } for (MachineBasicBlock *ChainBB : LoopChain) { dbgs() << " ... " << getBlockName(ChainBB) << "\n"; - if (!LoopBlockSet.erase(ChainBB)) { + if (!LoopBlockSet.remove(ChainBB)) { // We don't mark the loop as bad here because there are real situations // where this can occur. For example, with an unanalyzable fallthrough // from a loop block to a non-loop block or vice versa. @@ -1928,7 +1928,7 @@ bool MachineBlockPlacement::maybeTailDuplicateBlock( // Handle the filter set if (BlockFilter) { - BlockFilter->erase(RemBB); + BlockFilter->remove(RemBB); } // Remove the block from loop info. -- 2.7.4