[gardening] Always create SILBasicBlocks via SILFunction::createBasicBlock.

This eliminates all inline creation of SILBasicBlock via placement new.

There are a few reasons to do this:

1. A SILBasicBlock is always created with a parent function. This commit
formalizes this into the SILBasicBlock API by only allowing for SILFunctions to
create SILBasicBlocks. This is implemented via the type system by making all
SILBasicBlock constructors private. Since SILFunction is a friend of
SILBasicBlock, SILFunction can still create a SILBasicBlock without issue.

2. Since all SILBasicBlocks will be created in only a few functions, it becomes
very easy to determine using instruments the amount of memory being allocated
for SILBasicBlocks by simply inverting the call tree in Allocations.

With LTO+PGO, normal inlining can occur if profitable so there shouldn't be
overhead that we care about in shipping compilers.
This commit is contained in:
Michael Gottesman
2016-11-24 23:29:31 -06:00
parent 28656578be
commit e42bf07af4
20 changed files with 40 additions and 36 deletions

View File

@@ -1975,7 +1975,7 @@ public:
}
// Create the cloned start basic block.
auto *ClonedStartBB = new (Mod) SILBasicBlock(CurFun);
auto *ClonedStartBB = CurFun->createBasicBlock();
BBMap[StartBB] = ClonedStartBB;
// Clone the arguments.