Skip to content

Commit 1c15a8f

Browse files
authored
Merge pull request #17187 from gottesmm/swift-4.2-branch-41102239
[func-sig-opts][projection] All projection trees during the run on a …
2 parents 14b344f + f7572c2 commit 1c15a8f

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

include/swift/SIL/Projection.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ class ProjectionTree {
836836
SILModule &Mod;
837837

838838
/// The allocator we use to allocate ProjectionTreeNodes in the tree.
839-
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> Allocator;
839+
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator;
840840

841841
// A common pattern is a 3 field struct.
842842
llvm::SmallVector<ProjectionTreeNode *, 4> ProjectionTreeNodes;
@@ -846,10 +846,13 @@ class ProjectionTree {
846846

847847
public:
848848
/// Construct a projection tree from BaseTy.
849-
ProjectionTree(SILModule &Mod, SILType BaseTy);
849+
ProjectionTree(SILModule &Mod, SILType BaseTy,
850+
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator);
850851
/// Construct an uninitialized projection tree, which can then be
851852
/// initialized by initializeWithExistingTree.
852-
ProjectionTree(SILModule &Mod) : Mod(Mod) {}
853+
ProjectionTree(SILModule &Mod,
854+
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
855+
: Mod(Mod), Allocator(Allocator) {}
853856
~ProjectionTree();
854857
ProjectionTree(const ProjectionTree &) = delete;
855858
ProjectionTree(ProjectionTree &&) = default;

include/swift/SILOptimizer/Utils/FunctionSignatureOptUtils.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,17 @@ struct ArgumentDescriptor {
7777
/// to the original argument. The reason why we do this is to make sure we
7878
/// have access to the original argument's state if we modify the argument
7979
/// when optimizing.
80-
ArgumentDescriptor(SILFunctionArgument *A)
81-
: Arg(A),
82-
PInfo(A->getKnownParameterInfo()),
83-
Index(A->getIndex()),
80+
ArgumentDescriptor(
81+
SILFunctionArgument *A,
82+
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
83+
: Arg(A), PInfo(A->getKnownParameterInfo()), Index(A->getIndex()),
8484
Decl(A->getDecl()), IsEntirelyDead(false), Explode(false),
8585
OwnedToGuaranteed(false), IsIndirectResult(A->isIndirectResult()),
8686
CalleeRelease(), CalleeReleaseInThrowBlock(),
87-
ProjTree(A->getModule(), A->getType()) {
88-
if (!A->isIndirectResult()) {
89-
PInfo = Arg->getKnownParameterInfo();
90-
}
87+
ProjTree(A->getModule(), A->getType(), Allocator) {
88+
if (!A->isIndirectResult()) {
89+
PInfo = Arg->getKnownParameterInfo();
90+
}
9191
}
9292

9393
ArgumentDescriptor(const ArgumentDescriptor &) = delete;

lib/SIL/Projection.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,9 +1100,12 @@ class NewAggregateBuilderMap {
11001100
// ProjectionTree
11011101
//===----------------------------------------------------------------------===//
11021102

1103-
ProjectionTree::
1104-
ProjectionTree(SILModule &Mod, SILType BaseTy) : Mod(Mod) {
1105-
DEBUG(llvm::dbgs() << "Constructing Projection Tree For : " << BaseTy);
1103+
ProjectionTree::ProjectionTree(
1104+
SILModule &Mod, SILType BaseTy,
1105+
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
1106+
: Mod(Mod), Allocator(Allocator) {
1107+
DEBUG(llvm::dbgs() << "Constructing Projection Tree For : " << BaseTy
1108+
<< "\n");
11061109

11071110
// Create the root node of the tree with our base type.
11081111
createRoot(BaseTy);

lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,11 +1275,12 @@ class FunctionSignatureOpts : public SILFunctionTransform {
12751275
}
12761276

12771277
// Allocate the argument and result descriptors.
1278+
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> Allocator;
12781279
llvm::SmallVector<ArgumentDescriptor, 4> ArgumentDescList;
12791280
llvm::SmallVector<ResultDescriptor, 4> ResultDescList;
12801281
auto Args = F->begin()->getFunctionArguments();
1281-
for (unsigned i = 0, e = Args.size(); i != e; ++i) {
1282-
ArgumentDescList.emplace_back(Args[i]);
1282+
for (unsigned i : indices(Args)) {
1283+
ArgumentDescList.emplace_back(Args[i], Allocator);
12831284
}
12841285
for (SILResultInfo IR : F->getLoweredFunctionType()->getResults()) {
12851286
ResultDescList.emplace_back(IR);

0 commit comments

Comments
 (0)