Skip to content

Commit

Permalink
Make block placement deterministic
Browse files Browse the repository at this point in the history
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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287148 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
xur-llvm committed Nov 16, 2016
1 parent 2318eb9 commit 4146fdb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/CodeGen/MachineBlockPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class BlockChain {
namespace {
class MachineBlockPlacement : public MachineFunctionPass {
/// \brief A typedef for a block filter set.
typedef SmallPtrSet<MachineBasicBlock *, 16> BlockFilterSet;
typedef SmallSetVector<MachineBasicBlock *, 16> BlockFilterSet;

/// \brief work lists of blocks that are ready to be laid out
SmallVector<MachineBasicBlock *, 16> BlockWorkList;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4146fdb

Please sign in to comment.