[llvm-branch-commits] [clang] [llvm] [HLSL] GetDimensions methods for buffer resources (PR #161929)

Helena Kotas via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Oct 15 11:24:07 PDT 2025


================
@@ -421,13 +444,32 @@ BuiltinTypeMethodBuilder::addParam(StringRef Name, QualType Ty,
 void BuiltinTypeMethodBuilder::createDecl() {
   assert(Method == nullptr && "Method or constructor is already created");
 
-  // create method or constructor type
+  // create function prototype
   ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
   SmallVector<QualType> ParamTypes;
-  for (Param &MP : Params)
-    ParamTypes.emplace_back(MP.Ty);
+  SmallVector<FunctionType::ExtParameterInfo> ParamExtInfos(Params.size());
+  uint32_t ArgIndex = 0;
+  bool IsTemplate = DeclBuilder.Template != nullptr;
+  bool UseParamExtInfo = false;
+  for (Param &MP : Params) {
+    QualType Ty = MP.Ty;
+    if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
+      UseParamExtInfo = true;
+      ParamExtInfos[ArgIndex].withABI(
+          convertParamModifierToParamABI(MP.Modifier));
+      // Only update types on inout and out parameters for non-templated
+      // methods. Templated types will have their inout/out parameters
+      // converted to references during template instantiation.
+      if (!IsTemplate)
+        Ty = getInoutParameterType(AST, Ty);
+    }
+    ParamTypes.emplace_back(Ty);
+    ++ArgIndex;
+  }
----------------
hekota wrote:

I tried different combinations of the `out` attribute, ABI param and when to add `restrict &` on the function prototype or the method decl - this is the variation that works and does not have to 'coerce' the arguments. However, I did some testing now and found a bug in with `out` parameters and templates:

https://godbolt.org/z/dKn1r4v4E

I'll file an issue. We'll need to fix this bug first before revisiting this.


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


More information about the llvm-branch-commits mailing list