From 84105a3d6e86c8c439fff16c71ac536eae735a0e Mon Sep 17 00:00:00 2001 From: Rex Xu Date: Mon, 11 Dec 2023 17:42:02 +0800 Subject: [PATCH] Remove the function optimizeDecorates This is to port the upstream change: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/commit/fd04d44. --- .../lib/SPIRV/libSPIRV/SPIRVModule.cpp | 40 ------------------- .../lib/SPIRV/libSPIRV/SPIRVModule.h | 1 - 2 files changed, 41 deletions(-) diff --git a/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp index 57cb02c5f6..6c3dc8c800 100644 --- a/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp +++ b/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.cpp @@ -146,7 +146,6 @@ class SPIRVModuleImpl : public SPIRVModule { // Module changing functions bool importBuiltinSet(const std::string &, SPIRVId *) override; bool importBuiltinSetWithId(const std::string &, SPIRVId) override; - void optimizeDecorates() override; void setAddressingModel(SPIRVAddressingModelKind AM) override { AddrModel = AM; } void postProcessExecutionModeId(); void setMemoryModel(SPIRVMemoryModelKind MM) override { MemoryModel = MM; } @@ -357,44 +356,6 @@ void SPIRVModuleImpl::setCurrentLine(const SPIRVLine *Line) { CurrentLine = Line; } -// Creates decoration group and group decorates from decorates shared by -// multiple targets. -void SPIRVModuleImpl::optimizeDecorates() { - for (auto I = DecorateSet.begin(), E = DecorateSet.end(); I != E;) { - auto D = *I; - if (D->getOpCode() == OpMemberDecorate) { - ++I; - continue; - } - auto ER = DecorateSet.equal_range(D); - if (std::distance(ER.first, ER.second) < 2) { - I = ER.second; - continue; - } - auto G = add(new SPIRVDecorationGroup(this, getId())); - std::vector Targets; - Targets.push_back(D->getTargetId()); - const_cast(D)->setTargetId(G->getId()); - G->getDecorations().insert(D); - for (I = ER.first; I != ER.second; ++I) { - auto E = *I; - if (*E == *D) - continue; - Targets.push_back(E->getTargetId()); - } - - // WordCount is only 16 bits. We can only have 65535 - FixedWC targets per - // group. - // For now, just skip using a group if the number of targets to too big - if (Targets.size() < 65530) { - DecorateSet.erase(ER.first, ER.second); - auto GD = add(new SPIRVGroupDecorate(G, Targets)); - DecGroupVec.push_back(G); - GroupDecVec.push_back(GD); - } - } -} - void SPIRVModuleImpl::postProcessExecutionModeId() { for (auto ExecModeId : ExecModeIdVec) { SPIRVExecutionModeId *E = static_cast(ExecModeId); @@ -1127,7 +1088,6 @@ std::istream &operator>>(std::istream &I, SPIRVModule &M) { Decoder.getEntry(); MI.postProcessExecutionModeId(); - MI.optimizeDecorates(); MI.resolveUnknownStructFields(); MI.createForwardPointers(); return I; diff --git a/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.h b/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.h index b018ec4d26..56afc972ae 100644 --- a/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.h +++ b/llpc/translator/lib/SPIRV/libSPIRV/SPIRVModule.h @@ -145,7 +145,6 @@ class SPIRVModule { virtual void setSourceLanguage(SourceLanguage, SPIRVWord) = 0; virtual void setSourceFile(SPIRVId) = 0; virtual SPIRVString *getSourceFile(uint32_t FileId) const = 0; - virtual void optimizeDecorates() = 0; virtual void setAutoAddCapability(bool E) { AutoAddCapability = E; } virtual void setValidateCapability(bool E) { ValidateCapability = E; } virtual void setGeneratorId(unsigned short) = 0;