mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user