Subzero: Improve malloc/free behavior.
Use a bigger block size in the bump-pointer allocators, since we
basically know up front that we'll need lots of memory. The 1MB value
(versus the default of 4KB) was chosen somewhat arbitrarily, and
succeeds in pretty much removing bump-pointer related mallocs from the
profile.
Pre-reserve the a priori known number of edges in getTerminatorEdges()
to avoid vector resizing.
BUG= none
R=kschimpf@google.com
Review URL: https://codereview.chromium.org/760973002
diff --git a/src/IceCfg.h b/src/IceCfg.h
index 2a1e602..970b838 100644
--- a/src/IceCfg.h
+++ b/src/IceCfg.h
@@ -164,7 +164,7 @@
// order to use a "Recycler" to preserve memory. If we keep all allocation
// requests from the Cfg exposed via methods, we can always switch the
// implementation over at a later point.
- llvm::BumpPtrAllocator Allocator;
+ llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 1024 * 1024> Allocator;
GlobalContext *Ctx;
IceString FunctionName;
diff --git a/src/IceGlobalContext.h b/src/IceGlobalContext.h
index eeed6af..02e216b 100644
--- a/src/IceGlobalContext.h
+++ b/src/IceGlobalContext.h
@@ -202,7 +202,7 @@
Ostream *StrDump; // Stream for dumping / diagnostics
Ostream *StrEmit; // Stream for code emission
- llvm::BumpPtrAllocator Allocator;
+ llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 1024 * 1024> Allocator;
VerboseMask VMask;
std::unique_ptr<class ConstantPool> ConstPool;
Intrinsics IntrinsicsInfo;
diff --git a/src/IceInst.cpp b/src/IceInst.cpp
index 89c57e8..e1b5f43 100644
--- a/src/IceInst.cpp
+++ b/src/IceInst.cpp
@@ -250,6 +250,7 @@
NodeList InstBr::getTerminatorEdges() const {
NodeList OutEdges;
+ OutEdges.reserve(TargetTrue ? 2 : 1);
OutEdges.push_back(TargetFalse);
if (TargetTrue)
OutEdges.push_back(TargetTrue);
@@ -409,6 +410,7 @@
NodeList InstSwitch::getTerminatorEdges() const {
NodeList OutEdges;
+ OutEdges.reserve(NumCases + 1);
OutEdges.push_back(LabelDefault);
for (SizeT I = 0; I < NumCases; ++I) {
OutEdges.push_back(Labels[I]);