Skip to content

[BasicAA] Improve escape source analysis for return-only captures #131869

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Mar 18, 2025

This fixes an issue where improving inference from a general capture to a return-only capture can make alias analysis results worse.

The problem is that if there are return-only captures, the call can no longer treated as a plain escape source, as the call result may alias one of the return-only-capture arguments, even if they don't escape.

Fix this by having isEscapeSource() return the relevant arguments and explicitly check that these aren't aliased.

Fixes #131168.

Copy link

github-actions bot commented Mar 18, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

This fixes an issue where improving inference from a general capture
to a return-only capture can make alias analysis results worse.

The problem is that if there are return-only captures, the call
can no longer treated as a plain escape source, as the call result
may alias one of the return-only-capture arguments, even if they
don't escape.

Fix this by having isEscapeSource() return the relevant arguments and
explicitly check that these aren't aliased.

Fixes llvm#131168.
@nikic nikic force-pushed the capture-ret-improvement branch from 10f944d to 67708a6 Compare March 18, 2025 17:45
@nikic
Copy link
Contributor Author

nikic commented Mar 18, 2025

@nikic
Copy link
Contributor Author

nikic commented Mar 19, 2025

There are some improvements on llvm-opt-benchmark, but not a lot. Would be nice to fix this somehow, but it's not particularly important and not worth increasing compile-time for.

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.

[AA] Return-only captures can regress results
1 participant