Skip to content

[6.2] Fix IRGen for @_addressable params which may be "captured". #80709

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
Apr 12, 2025

Conversation

atrick
Copy link
Contributor

@atrick atrick commented Apr 10, 2025

Simply omit the 'nocapture' attribute on the parameter.

Fixes rdar://148039510 ([nonescapable] IRGen: lower addressable
params to LLVM: captures(ret: address, provenance))

(cherry picked from commit e40a34d)

main PR: #80708

@atrick atrick requested a review from a team as a code owner April 10, 2025 07:16
@atrick atrick changed the title Fix IRGen for @_addressable params which may be "captured". [6.2] Fix IRGen for @_addressable params which may be "captured". Apr 10, 2025
@atrick atrick added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.2 labels Apr 10, 2025
@atrick
Copy link
Contributor Author

atrick commented Apr 10, 2025

@swift-ci test

@rizh09
Copy link

rizh09 commented Apr 10, 2025

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

CodiumAI-Agent commented Apr 10, 2025

PR Reviewer Guide 🔍

(Review updated until commit e048dd1)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Attribute Application

The newly introduced conditional check for applying the NoCapture attribute when a parameter is not addressable should be verified to ensure it does not affect the intended capture semantics. Confirm that this change aligns with all expected parameter behaviors.

if (!addressable && ti.isBitwiseTakable(ResilienceExpansion::Maximal))
  b.addAttribute(llvm::Attribute::NoCapture);
// The parameter must reference dereferenceable memory of the type.
Type Lowering Consistency

The new overload of isAddressable with additional parameters and the associated type lowering logic should be carefully reviewed to ensure consistency with existing behavior and to avoid potential misinterpretation of type parameters.

  return isAddressable(paramIdx, caller->getModule(),
                       caller->getGenericEnvironment(),
                       caller->getModule().Types,
                       caller->getTypeExpansionContext());
}

// 'genericEnv' may be null.
bool SILFunctionType::isAddressable(unsigned paramIdx, SILModule &module,
                                    GenericEnvironment *genericEnv,
                                    Lowering::TypeConverter &typeConverter,
                                    TypeExpansionContext expansion) {

Simply omit the 'nocapture' attribute on the parameter.

Fixes rdar://148039510 ([nonescapable] IRGen: lower addressable
params to LLVM: captures(ret: address, provenance))

(cherry picked from commit 2d9df8f)
@atrick atrick force-pushed the 62-irgen-addressable branch from 40780a4 to e048dd1 Compare April 10, 2025 16:43
@atrick
Copy link
Contributor Author

atrick commented Apr 10, 2025

@swift-ci smoke test

@atrick atrick enabled auto-merge April 10, 2025 16:44
@atrick
Copy link
Contributor Author

atrick commented Apr 10, 2025

@swift-ci test

@CodiumAI-Agent
Copy link

Persistent review updated to latest commit e048dd1

@atrick atrick requested a review from tbkka April 11, 2025 18:11
@atrick atrick merged commit 097dba3 into swiftlang:release/6.2 Apr 12, 2025
5 checks passed
@atrick atrick deleted the 62-irgen-addressable branch April 12, 2025 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants