[llvm] [SPIRV] Do not remove capability from all caps (PR #68194)

Paulo Matos via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 00:51:28 PST 2023


https://github.com/pmatos updated https://github.com/llvm/llvm-project/pull/68194

>From 4ee35e0569726d966a9b5da96a4fe09ac0592f0a Mon Sep 17 00:00:00 2001
From: Paulo Matos <pmatos at igalia.com>
Date: Mon, 30 Oct 2023 12:29:09 +0100
Subject: [PATCH 1/2] [SPIRV] Fix test SPV_KHR_bit_instructions

Use AllCAps instead of AvailableCaps as initial implementation
confused these two.
Also document their purpose and difference.
---
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp | 4 ++--
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h   | 8 +++++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
index e8529496b07e4c4..779036016560e8c 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
@@ -528,8 +528,8 @@ void SPIRV::RequirementHandler::addAvailableCaps(const CapabilityList &ToAdd) {
 void SPIRV::RequirementHandler::removeCapabilityIf(
     const Capability::Capability ToRemove,
     const Capability::Capability IfPresent) {
-  if (AvailableCaps.contains(IfPresent))
-    AvailableCaps.erase(ToRemove);
+  if (AllCaps.contains(IfPresent))
+    AllCaps.erase(ToRemove);
 }
 
 namespace llvm {
diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
index 9eea9ac5bda5b08..57d0a7416342a66 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
@@ -60,11 +60,17 @@ struct Requirements {
 struct RequirementHandler {
 private:
   CapabilityList MinimalCaps;
+  
+  // AllCaps and AvailableCaps are related but different. AllCaps is a subset of 
+  // AvailableCaps. AvailableCaps is the complete set of capabilities that are available
+  // to the current target. AllCaps is the set of capabilities that are required
+  // by the current module.
   SmallSet<Capability::Capability, 8> AllCaps;
+  DenseSet<unsigned> AvailableCaps;
+
   SmallSet<Extension::Extension, 4> AllExtensions;
   unsigned MinVersion; // 0 if no min version is defined.
   unsigned MaxVersion; // 0 if no max version is defined.
-  DenseSet<unsigned> AvailableCaps;
   // Remove a list of capabilities from dedupedCaps and add them to AllCaps,
   // recursing through their implicitly declared capabilities too.
   void pruneCapabilities(const CapabilityList &ToPrune);

>From 42455807f96701498e77c096a0f8f0a1c34f1127 Mon Sep 17 00:00:00 2001
From: Paulo Matos <pmatos at linki.tools>
Date: Mon, 6 Nov 2023 09:51:07 +0100
Subject: [PATCH 2/2] Run clang-format

---
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
index 57d0a7416342a66..5124181b49e2c9c 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.h
@@ -60,11 +60,11 @@ struct Requirements {
 struct RequirementHandler {
 private:
   CapabilityList MinimalCaps;
-  
-  // AllCaps and AvailableCaps are related but different. AllCaps is a subset of 
-  // AvailableCaps. AvailableCaps is the complete set of capabilities that are available
-  // to the current target. AllCaps is the set of capabilities that are required
-  // by the current module.
+
+  // AllCaps and AvailableCaps are related but different. AllCaps is a subset of
+  // AvailableCaps. AvailableCaps is the complete set of capabilities that are
+  // available to the current target. AllCaps is the set of capabilities that
+  // are required by the current module.
   SmallSet<Capability::Capability, 8> AllCaps;
   DenseSet<unsigned> AvailableCaps;
 



More information about the llvm-commits mailing list