Skip to content

[func-sig-opts][projection] All projection trees during the run on a … #17130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/swift/SIL/Projection.h
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ class ProjectionTree {
///
/// FIXME: This should be a reference to an outside allocator. We shouldn't
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. You forgot to remove the FIXME.

/// have each ProjectionTree have its own allocator.
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> Allocator;
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator;

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

public:
/// Construct a projection tree from BaseTy.
ProjectionTree(SILModule &Mod, SILType BaseTy);
ProjectionTree(SILModule &Mod, SILType BaseTy,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator);
/// Construct an uninitialized projection tree, which can then be
/// initialized by initializeWithExistingTree.
ProjectionTree(SILModule &Mod) : Mod(Mod) {}
ProjectionTree(SILModule &Mod,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
: Mod(Mod), Allocator(Allocator) {}
~ProjectionTree();
ProjectionTree(const ProjectionTree &) = delete;
ProjectionTree(ProjectionTree &&) = default;
Expand Down
6 changes: 4 additions & 2 deletions lib/SIL/Projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,10 @@ class NewAggregateBuilderMap {
// ProjectionTree
//===----------------------------------------------------------------------===//

ProjectionTree::
ProjectionTree(SILModule &Mod, SILType BaseTy) : Mod(Mod) {
ProjectionTree::ProjectionTree(
SILModule &Mod, SILType BaseTy,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
: Mod(Mod), Allocator(Allocator) {
DEBUG(llvm::dbgs() << "Constructing Projection Tree For : " << BaseTy
<< "\n");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -779,11 +779,12 @@ class FunctionSignatureOpts : public SILFunctionTransform {
}

// Allocate the argument and result descriptors.
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> Allocator;
llvm::SmallVector<ArgumentDescriptor, 4> ArgumentDescList;
llvm::SmallVector<ResultDescriptor, 4> ResultDescList;
auto Args = F->begin()->getFunctionArguments();
for (unsigned i : indices(Args)) {
ArgumentDescList.emplace_back(Args[i]);
ArgumentDescList.emplace_back(Args[i], Allocator);
}
for (SILResultInfo IR : F->getLoweredFunctionType()->getResults()) {
ResultDescList.emplace_back(IR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,15 @@ struct ArgumentDescriptor {
/// to the original argument. The reason why we do this is to make sure we
/// have access to the original argument's state if we modify the argument
/// when optimizing.
ArgumentDescriptor(SILFunctionArgument *A)
ArgumentDescriptor(
SILFunctionArgument *A,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
: Arg(A), PInfo(A->getKnownParameterInfo()), Index(A->getIndex()),
Decl(A->getDecl()), IsEntirelyDead(false), WasErased(false),
Explode(false), OwnedToGuaranteed(false),
IsIndirectResult(A->isIndirectResult()), CalleeRelease(),
CalleeReleaseInThrowBlock(), ProjTree(A->getModule(), A->getType()) {
CalleeReleaseInThrowBlock(),
ProjTree(A->getModule(), A->getType(), Allocator) {
if (!A->isIndirectResult()) {
PInfo = Arg->getKnownParameterInfo();
}
Expand Down