Skip to content

Commit

Permalink
[Backport to 18] Fix SPIRVCopyMemory::validate() (KhronosGroup#2770)
Browse files Browse the repository at this point in the history
The asserts should be checking the `Target` member variable; `Id` is
not used for this class.

Only fix the wrong asserts for now; proper handling and testing of
`OpCopyMemory` will be done in a followup commit.

Contributes to KhronosGroup#2769

(cherry picked from commit 9d2926d)
  • Loading branch information
svenvh committed Oct 25, 2024
1 parent e8e7d76 commit 127d663
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/SPIRV/libSPIRV/SPIRVInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2107,10 +2107,15 @@ class SPIRVCopyMemory : public SPIRVInstruction, public SPIRVMemoryAccess {
}

void validate() const override {
assert((getValueType(Id) == getValueType(Source)) && "Inconsistent type");
assert(getValueType(Id)->isTypePointer() && "Invalid type");
assert(!(getValueType(Id)->getPointerElementType()->isTypeVoid()) &&
"Invalid type");
assert(getValueType(Target)->isTypePointer() && "Invalid Target type");
assert(getValueType(Source)->isTypePointer() && "Invalid Source type");
assert(!(getValueType(Target)->getPointerElementType()->isTypeVoid()) &&
"Invalid Target element type");
assert(!(getValueType(Source)->getPointerElementType()->isTypeVoid()) &&
"Invalid Source element type");
assert(getValueType(Target)->getPointerElementType() ==
getValueType(Source)->getPointerElementType() &&
"Mismatching Target and Source element types");
SPIRVInstruction::validate();
}

Expand Down

0 comments on commit 127d663

Please sign in to comment.