Skip to content

Conversation

@AnthonyLatsis
Copy link
Collaborator

Since llvm/llvm-project#106271, clang::TargetInfo does not co-own target options, so there is no longer anything to keep them alive after we discard the throwaway Clang invocation they originate from. Make the importer take ownership of a copy of code generation target options to avoid a use after free.

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test

@AnthonyLatsis
Copy link
Collaborator Author

preset=buildbot_incremental,tools=RA,stdlib=RA

@swift-ci please test with preset macOS

Copy link
Contributor

Choose a reason for hiding this comment

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

Is my understanding right that TargetOpts remains nullptr when we use the existing invocation? I wonder if this can get a bit confusing that we don't have one unique way to refer to TargetOpts regardless of which path we took.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, correct. That’s pretty much why I didn’t add a getter for TargetOpts. It’s just there to keep the options alive for as long as CodeGenTargetInfo when they differ from the importer invocation’s. You’re still supposed to access them through the invocation or getCodeGenTargetInfo, depending on which you want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a doc comment to TargetOpts.

generation

Since llvm/llvm-project#106271,
`clang::TargetInfo` does not co-own target options, so there is no
longer anything to keep them alive after we discard the throwaway Clang
invocation they originate from. Make the importer take ownership of a
copy of code generation target options to avoid a use after free.
@AnthonyLatsis
Copy link
Collaborator Author

Copy link
Contributor

@artemcm artemcm left a comment

Choose a reason for hiding this comment

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

Thank you.

@AnthonyLatsis
Copy link
Collaborator Author

Targeted test failures gone; merging.

@AnthonyLatsis AnthonyLatsis merged commit 7c77838 into swiftlang:rebranch Jul 9, 2025
@AnthonyLatsis AnthonyLatsis deleted the rebranch branch July 9, 2025 19:49
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