[llvm] r287148 - Make block placement deterministic

Rong Xu via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 16 12:50:06 PST 2016


Author: xur
Date: Wed Nov 16 14:50:06 2016
New Revision: 287148

URL: http://llvm.org/viewvc/llvm-project?rev=287148&view=rev
Log:
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

Modified:
    llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp?rev=287148&r1=287147&r2=287148&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Wed Nov 16 14:50:06 2016
@@ -264,7 +264,7 @@ public:
 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;
@@ -1512,7 +1512,7 @@ void MachineBlockPlacement::buildLoopCha
     }
     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::maybeTailDup
 
         // Handle the filter set
         if (BlockFilter) {
-          BlockFilter->erase(RemBB);
+          BlockFilter->remove(RemBB);
         }
 
         // Remove the block from loop info.




More information about the llvm-commits mailing list