From 336c78fdbe61270baca0f9fe72e3dc87375fa84e Mon Sep 17 00:00:00 2001 From: Kyle Butt Date: Wed, 12 Apr 2017 18:30:32 +0000 Subject: [PATCH] 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. llvm-svn: 300088 --- llvm/lib/CodeGen/MachineBlockPlacement.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp index e23f90b..4cfc128 100644 --- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp +++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp @@ -1165,6 +1165,9 @@ void MachineBlockPlacement::precomputeTriangleChains() { } } + // 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 -- 2.7.4