From fefd3b86bf3914cf170af1f22836fbac8ca7261b Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Mon, 28 Oct 2024 09:52:14 +0100 Subject: [PATCH] [Backport to 19] Fix SPIRVCopyMemory::validate() (#2770) (#2805) 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 https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/2769 (cherry picked from commit 9d2926d27b478f08513a0265e39afb26659d2b63) --- lib/SPIRV/libSPIRV/SPIRVInstruction.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/SPIRV/libSPIRV/SPIRVInstruction.h b/lib/SPIRV/libSPIRV/SPIRVInstruction.h index d75c0baef2..1f356e794e 100644 --- a/lib/SPIRV/libSPIRV/SPIRVInstruction.h +++ b/lib/SPIRV/libSPIRV/SPIRVInstruction.h @@ -2136,10 +2136,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(); }