From 127d6636db850a8cfcebd0378ed2cdea8a5540b6 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Tue, 22 Oct 2024 09:06:39 +0200 Subject: [PATCH] [Backport to 18] Fix SPIRVCopyMemory::validate() (#2770) 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 2fb1baef19..a591ac0390 100644 --- a/lib/SPIRV/libSPIRV/SPIRVInstruction.h +++ b/lib/SPIRV/libSPIRV/SPIRVInstruction.h @@ -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(); }