Skip to content

Commit

Permalink
Fix SPIRVCopyMemory::validate() (#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 #2769
  • Loading branch information
svenvh authored Oct 22, 2024
1 parent ae8fa38 commit 9d2926d
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 @@ -2253,10 +2253,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 9d2926d

Please sign in to comment.