Skip to content

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

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
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 @@ -836,7 +836,7 @@ class ProjectionTree {
SILModule &Mod;

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

// A common pattern is a 3 field struct.
llvm::SmallVector<ProjectionTreeNode *, 4> ProjectionTreeNodes;
Expand All @@ -846,10 +846,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
16 changes: 8 additions & 8 deletions include/swift/SILOptimizer/Utils/FunctionSignatureOptUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ 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)
: Arg(A),
PInfo(A->getKnownParameterInfo()),
Index(A->getIndex()),
ArgumentDescriptor(
SILFunctionArgument *A,
llvm::SpecificBumpPtrAllocator<ProjectionTreeNode> &Allocator)
: Arg(A), PInfo(A->getKnownParameterInfo()), Index(A->getIndex()),
Decl(A->getDecl()), IsEntirelyDead(false), Explode(false),
OwnedToGuaranteed(false), IsIndirectResult(A->isIndirectResult()),
CalleeRelease(), CalleeReleaseInThrowBlock(),
ProjTree(A->getModule(), A->getType()) {
if (!A->isIndirectResult()) {
PInfo = Arg->getKnownParameterInfo();
}
ProjTree(A->getModule(), A->getType(), Allocator) {
if (!A->isIndirectResult()) {
PInfo = Arg->getKnownParameterInfo();
}
}

ArgumentDescriptor(const ArgumentDescriptor &) = delete;
Expand Down
9 changes: 6 additions & 3 deletions lib/SIL/Projection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,9 +1100,12 @@ class NewAggregateBuilderMap {
// ProjectionTree
//===----------------------------------------------------------------------===//

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

// Create the root node of the tree with our base type.
createRoot(BaseTy);
Expand Down
5 changes: 3 additions & 2 deletions lib/SILOptimizer/Transforms/FunctionSignatureOpts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1275,11 +1275,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 = 0, e = Args.size(); i != e; ++i) {
ArgumentDescList.emplace_back(Args[i]);
for (unsigned i : indices(Args)) {
ArgumentDescList.emplace_back(Args[i], Allocator);
}
for (SILResultInfo IR : F->getLoweredFunctionType()->getResults()) {
ResultDescList.emplace_back(IR);
Expand Down