-
Notifications
You must be signed in to change notification settings - Fork 318
Destroy unused witness table after hoisting #7009
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
Conversation
What’s the rationale for disabling validation in witness tables? |
Sorry, this is not meant to be the final solution, but I'd like to test out if there are other failed tests in CI, because this is the only failed test I can reproduce locally. I'm not sure if this is expected, as it seems working fine depiste of this validation error? |
IR validation errors like this is usually due to some other code breaking the assumption. Our IR is designed around the assumption that an operand should be defined in a place that this visible to the inst, that means the operand itself needs to be either a global Inst, or defined in some parent of the inst, or in a basic block that dominates the current Inst. The only exception we allow is when the Inst is a decoration. If we need to add other exceptions, we need to understand why first. Usually breaking this assumption means there is a bug. This is similar to fixing other test failures: we usually don't fix test failures by deleting the test, unless we are certain that the test is obsolete. |
The real issue for validation error "IR validation failed: def must come before use in same block" should have something to do with Make IRWitnessTable HOISTABLE . Confirmed by reverting that commit. The error happens whenever we use operandUse is a StructType with name I also noticed that for the failed witness tables are created with
and the builder has a |
It seems that in this case the struct type and the witness table are both inside a IRGeneric. It is valid for witness tables, functions and types to exist inside a IRBlock of a IRGeneric. Does the struct type exist when the witness table is created? |
Is the last instruction of the block returning the witness table or returning the struct type? |
If it is a bug in creation of that witness table (inserting into the incorrect location), why does this only surface when the hoisting PR is merged? I suspect it is the hoisting logic moving the witness table into the wrong location. |
I think it's returnning the struct type. Dumped all children in the block when the valiation error happens.
|
Is this witness table referenced by anything? If not it shouldn’t even be inserted. |
I reverted the hoisting PR, and looks like the insertion order is the same. But when it comes to validating, the same witness table is using IR_Specialize as the operand, instead of the unseen struct type. I guess it's the hoisting and dedpulication logic that surface the issue. |
Debugging a little further, in the TOT with the hoisting logic, we have 2 witness tables in the same block. The first one is using IR_Specialize as operand, but the 2nd one is an unseen struct type (with UID 10111 below) as its opearnd.
In the old version, the 2 witness tables are still created, but only the first one is being validated ( not inserted to the list or removed?)
I'm trying to find out the logic why we have 2 witness tables after the hositing PR |
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.
Great job fixing this.
Looks good to me.
I'm not going to enable the debug test in this PR as there are still some other failures in the CI. I can't reproduce them locally, and I will try to find another way to debug it. |
This will be reverted because it is handed in PR shader-slang#7009
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.
Looks good to me.
Let's fix the other debug bugs later.
This PR turn on the debug tests in CI, which catches a validation error for the witness table using unseen inst.
The root cause is due to 0c5eee we create a new witness table but not destroying the original one, and during the IR validation the old one is triggering errors.
Fixes #6933