[llvm] [NFC] Refactoring MCDXBC to support out of order storage of root parameters (PR #137284)

Sarah Spall via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 09:28:04 PDT 2025


================
@@ -30,24 +30,20 @@ static void rewriteOffsetToCurrentByte(raw_svector_ostream &Stream,
 
 size_t RootSignatureDesc::getSize() const {
   size_t Size = sizeof(dxbc::RootSignatureHeader) +
-                Parameters.size() * sizeof(dxbc::RootParameterHeader);
+                ParametersContainer.size() * sizeof(dxbc::RootParameterHeader);
 
-  for (const mcdxbc::RootParameter &P : Parameters) {
-    switch (P.Header.ParameterType) {
-    case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit):
-      Size += sizeof(dxbc::RootConstants);
-      break;
-    case llvm::to_underlying(dxbc::RootParameterType::CBV):
-    case llvm::to_underlying(dxbc::RootParameterType::SRV):
-    case llvm::to_underlying(dxbc::RootParameterType::UAV):
-      if (Version == 1)
-        Size += sizeof(dxbc::RTS0::v1::RootDescriptor);
-      else
-        Size += sizeof(dxbc::RTS0::v2::RootDescriptor);
-
-      break;
-    }
+  for (const auto &I : ParametersContainer) {
+    std::optional<ParametersView> P = ParametersContainer.getParameter(&I);
+    if (!P)
----------------
spall wrote:

Is this case possible? From my understanding of this code, you are looping over the ParametersInfo, and everything that was added to ParametersInfo, should have a corresponding member in either Constants or Descriptors.  
If this case is possible I believe it means that there is a mechanism for removing values from Constants or Descriptors, which would potentially invalidate all of the Locations you are storing in the RootParameterInfo(s). 
If this is not possible, which i hope it's not, I think you should add an llvm_unreachable here. 

https://github.com/llvm/llvm-project/pull/137284


More information about the llvm-commits mailing list