Skip to content
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

Reland "[NVPTX] Use .common linkage for common globals" #86824

Merged
merged 2 commits into from
Mar 29, 2024

Conversation

AlexMaclean
Copy link
Member

Switch from .weak to .common linkage for common global variables where possible. The .common linkage is described in PTX ISA 11.6.4. Linking Directives: .common

Declares identifier to be globally visible but “common”.

Common symbols are similar to globally visible symbols. However multiple object files may declare the same common symbol and they may have different types and sizes and references to a symbol get resolved against a common symbol with the largest size.

Only one object file can initialize a common symbol and that must have the largest size among all other definitions of that common symbol from different object files.

.common linking directive can be used only on variables with .global storage. It cannot be used on function symbols or on symbols with opaque type.

I've updated the logic and tests to only use .common for PTX 5.0 or greater and verified that the new tests now pass with ptxas.

Copy link
Contributor

@Sterling-Augustine Sterling-Augustine left a comment

Choose a reason for hiding this comment

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

Looks good as far as the ptxas issues are concerned. Can't speak to the rest.

@AlexMaclean AlexMaclean merged commit 7daa65a into llvm:main Mar 29, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants