-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Improve stack usage to increase recursive initialization depth #88546
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
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b3c53b1
More efficient stack usage; NFC
AaronBallman a89ea6c
Further improvements to stack usage
AaronBallman 09085fa
Add a release note
AaronBallman 7b874a9
Fix formatting
AaronBallman bb2c55c
Update clang/docs/ReleaseNotes.rst
AaronBallman be4605d
Update clang/lib/Sema/SemaOverload.cpp
AaronBallman 39203ed
More updates to the release notes
AaronBallman 813948c
Merge branch 'aballman-stack-size' of https://github.com/AaronBallman…
AaronBallman 9c09ed2
Merge remote-tracking branch 'origin/main' into aballman-stack-size
AaronBallman 3bff337
Fix after merge
AaronBallman 4c17495
Call the destructor for the allocated object
AaronBallman c4d47c1
Use the STL rather than do work manually; NFC
AaronBallman 3cdaf99
Merge remote-tracking branch 'origin/main' into aballman-stack-size
AaronBallman 82d91ef
Merge remote-tracking branch 'origin/main' into aballman-stack-size
AaronBallman d7eb137
Don't arena allocate
AaronBallman 45e9737
Fix formatting; NFC
AaronBallman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6113,8 +6113,10 @@ static bool TryOCLZeroOpaqueTypeInitialization(Sema &S, | |
InitializationSequence::InitializationSequence( | ||
Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, | ||
MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid) | ||
: FailedOverloadResult(OR_Success), | ||
FailedCandidateSet(Kind.getLocation(), OverloadCandidateSet::CSK_Normal) { | ||
: FailedOverloadResult(OR_Success), FailedCandidateSet(nullptr) { | ||
FailedCandidateSet = S.getASTContext().Allocate<OverloadCandidateSet>(); | ||
FailedCandidateSet = new (FailedCandidateSet) OverloadCandidateSet( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a future optimization, I wonder if we could defer this allocation until we already know that we've failed? Perhaps in |
||
S.getASTContext(), Kind.getLocation(), OverloadCandidateSet::CSK_Normal); | ||
InitializeFrom(S, Entity, Kind, Args, TopLevelOfInitList, | ||
TreatUnavailableAsInvalid); | ||
} | ||
|
@@ -6808,7 +6810,8 @@ static ExprResult CopyObject(Sema &S, | |
// Perform overload resolution using the class's constructors. Per | ||
// C++11 [dcl.init]p16, second bullet for class types, this initialization | ||
// is direct-initialization. | ||
OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal); | ||
OverloadCandidateSet CandidateSet(S.getASTContext(), Loc, | ||
OverloadCandidateSet::CSK_Normal); | ||
DeclContext::lookup_result Ctors = S.LookupConstructors(Class); | ||
|
||
OverloadCandidateSet::iterator Best; | ||
|
@@ -6949,7 +6952,8 @@ static void CheckCXX98CompatAccessibleCopy(Sema &S, | |
return; | ||
|
||
// Find constructors which would have been considered. | ||
OverloadCandidateSet CandidateSet(Loc, OverloadCandidateSet::CSK_Normal); | ||
OverloadCandidateSet CandidateSet(S.getASTContext(), Loc, | ||
OverloadCandidateSet::CSK_Normal); | ||
DeclContext::lookup_result Ctors = | ||
S.LookupConstructors(cast<CXXRecordDecl>(Record->getDecl())); | ||
|
||
|
@@ -9735,7 +9739,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
switch (FailedOverloadResult) { | ||
case OR_Ambiguous: | ||
|
||
FailedCandidateSet.NoteCandidates( | ||
FailedCandidateSet->NoteCandidates( | ||
PartialDiagnosticAt( | ||
Kind.getLocation(), | ||
Failure == FK_UserConversionOverloadFailed | ||
|
@@ -9749,7 +9753,8 @@ bool InitializationSequence::Diagnose(Sema &S, | |
break; | ||
|
||
case OR_No_Viable_Function: { | ||
auto Cands = FailedCandidateSet.CompleteCandidates(S, OCD_AllCandidates, Args); | ||
auto Cands = | ||
FailedCandidateSet->CompleteCandidates(S, OCD_AllCandidates, Args); | ||
if (!S.RequireCompleteType(Kind.getLocation(), | ||
DestType.getNonReferenceType(), | ||
diag::err_typecheck_nonviable_condition_incomplete, | ||
|
@@ -9759,7 +9764,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
<< OnlyArg->getType() << Args[0]->getSourceRange() | ||
<< DestType.getNonReferenceType(); | ||
|
||
FailedCandidateSet.NoteCandidates(S, Args, Cands); | ||
FailedCandidateSet->NoteCandidates(S, Args, Cands); | ||
break; | ||
} | ||
case OR_Deleted: { | ||
|
@@ -9768,7 +9773,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
<< Args[0]->getSourceRange(); | ||
OverloadCandidateSet::iterator Best; | ||
OverloadingResult Ovl | ||
= FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best); | ||
= FailedCandidateSet->BestViableFunction(S, Kind.getLocation(), Best); | ||
if (Ovl == OR_Deleted) { | ||
S.NoteDeletedFunction(Best->Function); | ||
} else { | ||
|
@@ -9946,7 +9951,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
// bad. | ||
switch (FailedOverloadResult) { | ||
case OR_Ambiguous: | ||
FailedCandidateSet.NoteCandidates( | ||
FailedCandidateSet->NoteCandidates( | ||
PartialDiagnosticAt(Kind.getLocation(), | ||
S.PDiag(diag::err_ovl_ambiguous_init) | ||
<< DestType << ArgsRange), | ||
|
@@ -10000,7 +10005,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
break; | ||
} | ||
|
||
FailedCandidateSet.NoteCandidates( | ||
FailedCandidateSet->NoteCandidates( | ||
PartialDiagnosticAt( | ||
Kind.getLocation(), | ||
S.PDiag(diag::err_ovl_no_viable_function_in_init) | ||
|
@@ -10011,7 +10016,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
case OR_Deleted: { | ||
OverloadCandidateSet::iterator Best; | ||
OverloadingResult Ovl | ||
= FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best); | ||
= FailedCandidateSet->BestViableFunction(S, Kind.getLocation(), Best); | ||
if (Ovl != OR_Deleted) { | ||
S.Diag(Kind.getLocation(), diag::err_ovl_deleted_init) | ||
<< DestType << ArgsRange; | ||
|
@@ -10088,7 +10093,7 @@ bool InitializationSequence::Diagnose(Sema &S, | |
<< Args[0]->getSourceRange(); | ||
OverloadCandidateSet::iterator Best; | ||
OverloadingResult Ovl | ||
= FailedCandidateSet.BestViableFunction(S, Kind.getLocation(), Best); | ||
= FailedCandidateSet->BestViableFunction(S, Kind.getLocation(), Best); | ||
(void)Ovl; | ||
assert(Ovl == OR_Success && "Inconsistent overload resolution"); | ||
CXXConstructorDecl *CtorDecl = cast<CXXConstructorDecl>(Best->Function); | ||
|
@@ -10818,7 +10823,7 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( | |
// | ||
// Since we know we're initializing a class type of a type unrelated to that | ||
// of the initializer, this reduces to something fairly reasonable. | ||
OverloadCandidateSet Candidates(Kind.getLocation(), | ||
OverloadCandidateSet Candidates(Context, Kind.getLocation(), | ||
OverloadCandidateSet::CSK_Normal); | ||
OverloadCandidateSet::iterator Best; | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.