[PATCH] D39593: [ADCE] Use MapVector for BlockInfo to make iteration order deterministic
Mikael Holmén via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 07:15:41 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317323: [ADCE] Use MapVector for BlockInfo to make iteration order deterministic (authored by uabelho).
Changed prior to commit:
https://reviews.llvm.org/D39593?vs=121468&id=121472#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39593
Files:
llvm/trunk/include/llvm/ADT/MapVector.h
llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
Index: llvm/trunk/include/llvm/ADT/MapVector.h
===================================================================
--- llvm/trunk/include/llvm/ADT/MapVector.h
+++ llvm/trunk/include/llvm/ADT/MapVector.h
@@ -56,6 +56,13 @@
size_type size() const { return Vector.size(); }
+ /// Grow the MapVector so that it can contain at least \p NumEntries items
+ /// before resizing again.
+ void reserve(size_type NumEntries) {
+ Map.reserve(NumEntries);
+ Vector.reserve(NumEntries);
+ }
+
iterator begin() { return Vector.begin(); }
const_iterator begin() const { return Vector.begin(); }
iterator end() { return Vector.end(); }
Index: llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
+++ llvm/trunk/lib/Transforms/Scalar/ADCE.cpp
@@ -18,6 +18,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
@@ -118,7 +119,8 @@
PostDominatorTree &PDT;
/// Mapping of blocks to associated information, an element in BlockInfoVec.
- DenseMap<BasicBlock *, BlockInfoType> BlockInfo;
+ /// Use MapVector to get deterministic iteration order.
+ MapVector<BasicBlock *, BlockInfoType> BlockInfo;
bool isLive(BasicBlock *BB) { return BlockInfo[BB].Live; }
/// Mapping of instructions to associated information.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39593.121472.patch
Type: text/x-patch
Size: 1540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171103/e6552270/attachment.bin>
More information about the llvm-commits
mailing list