[llvm] r300088 - CodeGen: BlockPlacement: Add comment about DenseMap Safety.

Kyle Butt via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 11:30:32 PDT 2017


Author: iteratee
Date: Wed Apr 12 13:30:32 2017
New Revision: 300088

URL: http://llvm.org/viewvc/llvm-project?rev=300088&view=rev
Log:
CodeGen: BlockPlacement: Add comment about DenseMap Safety.

The use of a DenseMap in precomputeTriangleChains does not cause
non-determinism, even though it is iterated over, as the only thing the
iteration does is to insert entries into a new DenseMap, which is not iterated.
Comment only change.

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=300088&r1=300087&r2=300088&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBlockPlacement.cpp Wed Apr 12 13:30:32 2017
@@ -1165,6 +1165,9 @@ void MachineBlockPlacement::precomputeTr
     }
   }
 
+  // Iterating over a DenseMap is safe here, because the only thing in the body
+  // of the loop is inserting into another DenseMap (ComputedEdges).
+  // ComputedEdges is never iterated, so this doesn't lead to non-determinism.
   for (auto &ChainPair : TriangleChainMap) {
     TriangleChain &Chain = ChainPair.second;
     // Benchmarking has shown that due to branch correlation duplicating 2 or




More information about the llvm-commits mailing list