-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DirectX] Remove trivially dead functions at linkage finalize #106146
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
Merged
+425
−32
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4022447
[DirectX] Remove trivially dead functions at linkage finalize
2335e8c
correct run lines
8320509
Remove test requiring DirectX backend
416b5c0
Eliminate trivially dead functions regardless of inline status
40253bb
Merge remote-tracking branch 'origin/main' into hlsl_remove_internal
21cfc89
Add library DX codegen test
b9c029e
Merge remote-tracking branch 'refs/remotes/origin/main' into hlsl_rem…
5d3953d
Create fully separate library test
4ac12a2
Merge remote-tracking branch 'refs/remotes/origin/main' into hlsl_rem…
ea866f3
Merge remote-tracking branch 'refs/remotes/origin/main' into hlsl_rem…
ba24945
Correct mistaken merge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| ; RUN: opt -S -dxil-finalize-linkage -mtriple=dxil-unknown-shadermodel6.5-compute %s | FileCheck %s | ||
| ; RUN: llc %s --filetype=asm -o - | FileCheck %s | ||
hekota marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| target triple = "dxilv1.5-pc-shadermodel6.5-compute" | ||
|
|
||
| ; Confirm that DXILFinalizeLinkage will remove functions that have compatible | ||
| ; linkage and are not called from anywhere. This should be any function that | ||
| ; is not explicitly marked noinline or export and is not an entry point. | ||
|
|
||
| ; Not called nor marked with any linking or inlining attributes. | ||
| ; CHECK-NOT: define {{.*}}doNothingNothing | ||
hekota marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| define void @"?doNothingNothing@@YAXXZ"() #0 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Marked internal, this should be removed. | ||
| ; CHECK-NOT: define {{.*}}doNothingInternally | ||
| define internal void @"?doNothingInternally@@YAXXZ"() #0 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Marked external, which should become internal and be removed. | ||
| ; CHECK-NOT: define {{.*}}doNothingExternally | ||
| define external void @"?doNothingExternally@@YAXXZ"() #0 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Not called nor marked with any linking or inlining attributes. | ||
| ; CHECK: define internal void @"?doSomethingSomething@@YAXXZ"() #0 | ||
| define void @"?doSomethingSomething@@YAXXZ"() #0 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Marked internal, this should be removed. | ||
| ; CHECK: define internal void @"?doSomethingInternally@@YAXXZ"() #0 | ||
hekota marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| define internal void @"?doSomethingInternally@@YAXXZ"() #0 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Marked external, which should become internal and be removed. | ||
| ; CHECK: define internal void @"?doSomethingExternally@@YAXXZ"() #0 | ||
hekota marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| define external void @"?doSomethingExternally@@YAXXZ"() #0 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Lacks alwaysinline attribute. Should remain. | ||
| ; CHECK: define internal void @"?doNothingDefault@@YAXXZ"() #1 | ||
| define void @"?doNothingDefault@@YAXXZ"() #1 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| ; Has noinline attribute. Should remain. | ||
| ; CHECK: define {{.*}}doNothingNoinline | ||
| define void @"?doNothingNoinline@@YAXXZ"() #2 { | ||
| entry: | ||
hekota marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ret void | ||
| } | ||
|
|
||
| ; Entry point function should stay. | ||
| ; CHECK: define void @main() #3 | ||
| define void @main() #3 { | ||
| entry: | ||
| call void @"?doSomethingSomething@@YAXXZ"() #4 | ||
| call void @"?doSomethingInternally@@YAXXZ"() #4 | ||
| call void @"?doSomethingExternally@@YAXXZ"() #4 | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { alwaysinline convergent norecurse nounwind } | ||
| attributes #1 = { convergent norecurse nounwind } | ||
| attributes #2 = { convergent noinline norecurse nounwind } | ||
| attributes #3 = { convergent noinline norecurse "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" } | ||
| attributes #4 = { convergent } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment may be better updated to something like:
Collect all non-entry point and non-exported functions to possibly set to internal linkage later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated