-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DirectX] Add GlobalDCE pass after finalize linkage pass in DirectX backend #151071
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
Changes from all commits
65204f1
7cae259
502dc5a
f75de6c
275e811
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ; RUN: llc %s -mtriple=dxil-pc-shadermodel6.3-library --filetype=asm -o - | FileCheck %s | ||
| ; RUN: opt -S -passes='dxil-data-scalarization,dxil-flatten-arrays' -mtriple=dxil-unknown-shadermodel6.5-compute %s | FileCheck %s | ||
|
||
|
|
||
| ; Make sure we don't touch arrays without vectors and that can recurse and flatten multiple-dimension arrays of vectors | ||
|
|
||
|
|
||
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.
For anyone else looking this is the crux of the change right here. GlobalDCE is conservative so it won't remove globals marked external. This is because Linker would handle these globals and usually something like the internalizer pass would run and do a similar conversion to what we are doing here.
In HLSL's case after finalize linkage we should be able to assume that it is safe to mark all external globals with no uses as internal. If we then run GlobalDCE after this these globals will get cleaned up.
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.
If we're just concerned with deleting unused external variables... we could do that as part of DXILFinalizeLinkage instead of running GlobalDCE in the backend.
Are there other cases that GlobalDCE catches that we need to catch late?
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.
Justin suggested we not do special casing of global_ctors and that GlobalDCE was a more complete solution. Hence why we closed the previous attempt at fixing this issue.
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.
We need to special case global constructors for library shaders. That's not optional.
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.
If we use GlobalDCE we don't need to special case, things just work by converting to internal.