Skip to content

Introduce program linkage#295

Merged
llvm-beanz merged 4 commits into
microsoft:mainfrom
llvm-beanz:cbieneman/linkage
Aug 12, 2024
Merged

Introduce program linkage#295
llvm-beanz merged 4 commits into
microsoft:mainfrom
llvm-beanz:cbieneman/linkage

Conversation

@llvm-beanz

Copy link
Copy Markdown
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

@hekota hekota left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@coopp coopp left a comment

Copy link
Copy Markdown
Collaborator

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
Comment thread specs/language/basic.tex Outdated
@llvm-beanz llvm-beanz merged commit 05a8bcf into microsoft:main Aug 12, 2024
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
llvm-beanz added a commit to llvm-beanz/hlsl-specs that referenced this pull request Feb 9, 2025
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.
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