Commit 9d801a01 by Jim Stichnoth

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
parent 33246427
......@@ -164,7 +164,7 @@ private:
// 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;
......
......@@ -202,7 +202,7 @@ private:
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;
......
......@@ -250,6 +250,7 @@ InstBr::InstBr(Cfg *Func, CfgNode *Target)
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 @@ void InstSwitch::addBranch(SizeT CaseIndex, uint64_t Value, CfgNode *Label) {
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]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment