Skip to content

Reapply "[clang] Introduce [[clang::lifetime_capture_by(X)]] #9595

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 1 commit into from
Nov 14, 2024

Conversation

Xazax-hun
Copy link

Fix compile time regression and memory leak

In the previous change, we saw:

For compile time regression, we make the Param->Idx StringMap for all functions. This StringMap is expensive and should not be computed when none of the params are annotated with [[clang::lifetime_capture_by(X)]].

For the memory leak, the small vectors used in Attribute are not destroyed because the attributes are allocated through ASTContext's allocator. We therefore need a raw array in this case.

Cherry-picked from 3e20bae

…5823)

Fix compile time regression and memory leak

In the previous change, we saw:
- Memory leak: https://lab.llvm.org/buildbot/#/builders/169/builds/5193
- 0.5% Compile time regression
[link](https://llvm-compile-time-tracker.com/compare.php?from=4a68e4cbd2423dcacada8162ab7c4bb8d7f7e2cf&to=8c4331c1abeb33eabf3cdbefa7f2b6e0540e7f4f&stat=instructions:u)

For compile time regression, we make the Param->Idx `StringMap` for
**all** functions. This `StringMap` is expensive and should not be
computed when none of the params are annotated with
`[[clang::lifetime_capture_by(X)]]`.

For the memory leak, the small vectors used in Attribute are not
destroyed because the attributes are allocated through ASTContext's
allocator. We therefore need a raw array in this case.

Cherry-picked from 3e20bae
@Xazax-hun Xazax-hun requested a review from egorzhdan November 13, 2024 11:10
@Xazax-hun
Copy link
Author

@swift-ci please test

@Xazax-hun
Copy link
Author

@swift-ci please test LLVM

Copy link

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

I haven't reviewed all the bits of the implementation since it's already approved upstream, but cherry-picking this LGTM.

@Xazax-hun Xazax-hun merged commit ad89af1 into stable/20240723 Nov 14, 2024
5 checks passed
@Xazax-hun Xazax-hun deleted the gaborh/cherry-pick-lifetime-capture-by branch November 14, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants