[clang] Improve stack usage to increase template instantiation depth (PR #88546)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 12 11:10:53 PDT 2024


================
@@ -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(
----------------
erichkeane wrote:

As a future optimization, I wonder if we could defer this allocation until we already know that we've failed?  Perhaps in `SetOverloadFailure`?  Not sure I can grok the analysis at the moment to know how possible this is though.

https://github.com/llvm/llvm-project/pull/88546


More information about the cfe-commits mailing list