[clang] [HLSL] Preserve matrix layout as AST storage metadata (PR #225519)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 07:22:55 PDT 2026


================
@@ -44,6 +44,18 @@ column_major float4x4 Col2Row(row_major float4x4 M) {
 
 void bar(row_major float4x4 M, column_major float4x4 M2) {}
 
+// Layout metadata does not create distinct overloads.
+void same_overload(row_major float2x2 M);
+void same_overload(column_major float2x2 M);
----------------
llvm-beanz wrote:

What is this testing?

Duplicate declarations are fine and don't produce diagnostics, but they also wouldn't produce a diagnostic if they were treated as unique overloads.

For example this is totally fine in C++:
```c++
int fn(int);
int fn(int); // fine to re-declare the existing declaration.
int fn(float);  // fine to overload it.
```

By contrast this is not because it is a re-definition:
```c++
void fn(int) {}
void fn(int) {}
```

In HLSL today this is legal:
```
void fn(row_major float2x2);
void fn(column_major float2x2); // re-declaration of the same thing is fine!
```

This is illegal:
```
void fn(row_major float2x2) {}
void fn(column_major float2x2) {} // re-definition of the same thing is not!
```

That's probably a more complete test. We should also consider making re-declaration with different orientation an error since that's almost certainly a bug in code, but that's something we should probably drive through TC57.

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


More information about the cfe-commits mailing list