Skip to content

[stable/21.x][ObjCARC] Run ObjCARCContract before PreISelIntrinsicLowering#12687

Open
SiliconA-Z wants to merge 1 commit intoswiftlang:stable/21.xfrom
SiliconA-Z:objca
Open

[stable/21.x][ObjCARC] Run ObjCARCContract before PreISelIntrinsicLowering#12687
SiliconA-Z wants to merge 1 commit intoswiftlang:stable/21.xfrom
SiliconA-Z:objca

Conversation

@SiliconA-Z
Copy link
Copy Markdown

Link: llvm@55322f2

74e4694 moved ObjCARCContract from running before the codegen pipeline into addISelPrepare(), which runs after PreISelIntrinsicLowering.

This broke ObjCARCContract's retainRV-to-claimRV optimization because ObjCARCContract identifies ARC calls via intrinsics, not their lowered counterparts.

This patch restores the pre-74e4694 ordering by moving ObjCARCContract to addISelPasses.

The IntrinsicInst.cpp change looks extraneous but is required here: ObjCARCContract may now rewrite the bundle operand from retainRV to claimRV. When PreISelIntrinsicLowering then encounters this new intrinsic use, lowerObjCCall asserts mayLowerToFunctionCall.

Assisted-by: claude

rdar://137997453

@SiliconA-Z SiliconA-Z requested a review from a team as a code owner March 31, 2026 20:28
@SiliconA-Z
Copy link
Copy Markdown
Author

@adrian-prantl

@SiliconA-Z
Copy link
Copy Markdown
Author

@fhahn

@fhahn fhahn requested review from ahatanaka and citymarina April 2, 2026 12:42
…ering (llvm#184149)

Link: llvm@55322f2

74e4694 moved ObjCARCContract from running before the codegen pipeline
into addISelPrepare(), which runs after PreISelIntrinsicLowering.

This broke ObjCARCContract's retainRV-to-claimRV optimization because
ObjCARCContract identifies ARC calls via intrinsics, not their lowered
counterparts.

This patch restores the pre-74e4694 ordering by moving ObjCARCContract
to addISelPasses.

The IntrinsicInst.cpp change looks extraneous but is required here:
ObjCARCContract may now rewrite the bundle operand from retainRV to
claimRV. When PreISelIntrinsicLowering then encounters this new
intrinsic use, lowerObjCCall asserts mayLowerToFunctionCall.

Assisted-by: claude

rdar://137997453
@SiliconA-Z
Copy link
Copy Markdown
Author

@cachemeifyoucan Can we please do the

@swift-ci please test I don't have perms

@adrian-prantl
Copy link
Copy Markdown

@SiliconA-Z please do not ping many random people in a short period of time.

@adrian-prantl
Copy link
Copy Markdown

@swift-ci test

@SiliconA-Z
Copy link
Copy Markdown
Author

Thank you and I'm sorry!

@SiliconA-Z
Copy link
Copy Markdown
Author

Passed!

@adrian-prantl
Copy link
Copy Markdown

@citymarina @ahatanaka Can you confirm we want this in the stable branch?

@citymarina
Copy link
Copy Markdown

@SiliconA-Z could you let us know a bit about the motivation for this, is there a particular reason that the patch needs to go on this branch? Thanks!

@SiliconA-Z
Copy link
Copy Markdown
Author

@SiliconA-Z could you let us know a bit about the motivation for this, is there a particular reason that the patch needs to go on this branch? Thanks!

Yes: a core feature related to ARC optimization is being shipped broken, and waiting a whole year for that to be addressed come macOS 27 is not a good plan.

Most bugs aren't like this and I'm fine waiting for, but also realize that there's low risk here, even if it feels like a big change for a 21.x release.

@SiliconA-Z
Copy link
Copy Markdown
Author

It seems the Windows test hasn't ran (even though this doesn't affect Windows)

@adrian-prantl
Copy link
Copy Markdown

@swift-ci test windows

@SiliconA-Z
Copy link
Copy Markdown
Author

Yay it passed!

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