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

Introduce program linkage #295

Merged
merged 4 commits into from
Aug 12, 2024
Merged

Conversation

llvm-beanz
Copy link
Collaborator

The C++ specification talks in terms of module, external, internal, and no linkage. These linkages in C++ refer to translation units. For HLSL, we have some differences in how programs are built and linked that can't be fully expressed in that language.

Specifically, we have a notion of a program-export (entry functions, export keyword), that denotes a linkage that is more external than just cross translation unit.

This change introduces a term program linkage to refer to names that have linkage outside a linked or freestanding program.

The C++ specification talks in terms of module, external, internal, and no linkage. These linkages in C++ refer to translation units. For HLSL, we have some differences in how programs are built and linked that can't be fully expressed in that language.

Specifically, we have a notion of a program-export (entry functions, export keyword), that denotes a linkage that is more external than just cross translation unit.

This change introduces a term _program linkage_ to refer to names that have linkage outside a linked or freestanding program.
@llvm-beanz llvm-beanz requested a review from hekota August 5, 2024 18:55
Copy link
Member

@hekota hekota left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Collaborator

@coopp coopp left a comment

Choose a reason for hiding this comment

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

Looks great!

hekota added a commit to hekota/llvm-project that referenced this pull request Aug 7, 2024
…e sure only shader entry points and exported functions are visible from the module (have program linkage). Linkage of all other functions will be changed to internal.

Related spec update: microsoft/hlsl-specs#295
specs/language/basic.tex Outdated Show resolved Hide resolved
@llvm-beanz llvm-beanz merged commit 05a8bcf into microsoft:main Aug 12, 2024
3 checks passed
hekota added a commit to llvm/llvm-project that referenced this pull request Aug 16, 2024
An HLSL function has internal linkage by default unless it is:
1. shader entry point function
2. marked with the `export` keyword
(#92812)
3. patch constant function (not implemented yet)

This PR adds a link-time pass `DXILFinalizeLinkage` that updates the
linkage of functions to make sure only shader entry points and exported
functions are visible from the module (have _program linkage_). All
other functions will be updated to have internal linkage.

Related spec update: microsoft/hlsl-specs#295

Fixes ##92071
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.

4 participants