[PATCH] D87319: [DomTree] Use SmallVector<DomTreeNodeBase *, 4> instead of std::vector.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 11:59:01 PDT 2020
fhahn created this revision.
fhahn added reviewers: kuhar, nhaehnle, dblaikie, asbirlea.
Herald added a subscriber: dexonsmith.
Herald added a project: LLVM.
fhahn requested review of this revision.
Currentl DomTreeNodeBase is using std::vectot to store it's children.
Using SmallVector should be more efficient in terms of compile-time.
A size of 4 seems to be the sweet-spot in terms of compile-time,
according to
http://llvm-compile-time-tracker.com/compare.php?from=9933188c90615c9c264ebb69117f09726e909a25&to=d7a801d027648877b20f0e00e822a7a64c58d976&stat=instructions
This results in the following geomean improvements
geomean insts max rss
O3 -0.31 % +0.02 %
ReleaseThinLTO -0.35 % -0.12 %
ReleaseLTO -0.28 % -0.12 %
O0 -0.06 % -0.02 %
NewPM O3 -0.36 % +0.05 %
ReleaseThinLTO (link only) -0.44 % -0.10 %
ReleaseLTO-g (link only): -0.32 % -0.03 %
I am not sure if there's any other benefits of using std::vector over
SmallVector.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87319
Files:
llvm/include/llvm/Support/GenericDomTree.h
Index: llvm/include/llvm/Support/GenericDomTree.h
===================================================================
--- llvm/include/llvm/Support/GenericDomTree.h
+++ llvm/include/llvm/Support/GenericDomTree.h
@@ -38,7 +38,6 @@
#include <memory>
#include <type_traits>
#include <utility>
-#include <vector>
namespace llvm {
@@ -61,7 +60,7 @@
NodeT *TheBB;
DomTreeNodeBase *IDom;
unsigned Level;
- std::vector<DomTreeNodeBase *> Children;
+ SmallVector<DomTreeNodeBase *, 4> Children;
mutable unsigned DFSNumIn = ~0;
mutable unsigned DFSNumOut = ~0;
@@ -69,9 +68,9 @@
DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom)
: TheBB(BB), IDom(iDom), Level(IDom ? IDom->Level + 1 : 0) {}
- using iterator = typename std::vector<DomTreeNodeBase *>::iterator;
+ using iterator = typename SmallVector<DomTreeNodeBase *, 4>::iterator;
using const_iterator =
- typename std::vector<DomTreeNodeBase *>::const_iterator;
+ typename SmallVector<DomTreeNodeBase *, 4>::const_iterator;
iterator begin() { return Children.begin(); }
iterator end() { return Children.end(); }
@@ -837,7 +836,7 @@
"NewBB should have a single successor!");
NodeRef NewBBSucc = *GraphT::child_begin(NewBB);
- std::vector<NodeRef> PredBlocks;
+ SmallVector<NodeRef, 4> PredBlocks;
for (auto Pred : children<Inverse<N>>(NewBB))
PredBlocks.push_back(Pred);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87319.290561.patch
Type: text/x-patch
Size: 1415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200908/dd98d465/attachment.bin>
More information about the llvm-commits
mailing list