-
Notifications
You must be signed in to change notification settings - Fork 254
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
Deduplicate witness table while specializing generic functions #6363
Open
jkwak-work
wants to merge
5
commits into
shader-slang:master
Choose a base branch
from
jkwak-work:fix/duplicated_struct_for_DiffPair
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
303e670
Deduplicate witness table based on type and operand-0
jkwak-work 4aa5a14
Swap the cloned IR properly
jkwak-work 4734d57
Avoid clonning instances that will be deallocated
jkwak-work 5e68cb3
Clone the WitenessTableType as well to be safe
jkwak-work 9dbbcdf
Changed the comments about cloning the children
jkwak-work 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 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
Oops, something went wrong.
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 dictionary needs to be populated upon initialization of
SpecializationContext
, otherwise, if a specialization will result in a witness table that already exists in the global scope, we will not be able to dedup.The current code can only dedup witness tables created during a single specialization pass. Note that the specialization pass is invoked in a loop, so it can run more than once, each time specializing a couple more insts.
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.
I still feel like the cleanest way to solve this is to make IRWitnessTable a
HOISTABLE
inst so it can be deduplicated by the existing global value deduplication mechanism in our IR.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.
I will make changes based on the first comment.
For the second comment, I can give another try but when I tried, it was crashing.
I think WitnessTableEntry will have to become HOISTABLE as well in order to make WitnessTable HOISTABLE.
Because WitenessTable gets WitnessTableEntry as children.
I will try to make both of them HOISTABLE and see what happens.
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 definitely don’t want witness table entry to be hoistable, since they doesn’t matter for deduplication purpose. Deduplication uses only type and operand as key, and that is exactly what we need here.
I am not saying turning the witness table inst itself as hoistable is the only required change, we need to deal with the consequences. For example, hoistable insts requires knowing its type and operands upon creation, you can’t create an hoistable inst and then modify its type or operands afterwards.
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.
I see. I will not touch the witness table entry.