Issue 127512
Summary [HLSL] Misleading builtin diagnostics
Labels HLSL
Assignees
Reporter llvm-beanz
    Many of the HLSL builtins are reporting diagnostics using `err_typecheck_convert_incompatible`, which produces diagnostics of the form:
`error: passing <type1> to parameter of incompatible type <type2>`. This diagnostic strongly implies the usage of the builtin requires a specific type, which is not the case. For example see the `__builtin_hlsl_cross` intrinsic which is valid for 16 and 32-bit floating point types and vectors of such type.


```hlsl
export int4 fn(int4 x, int4 y) {
    return __builtin_hlsl_cross(x, y);
}

export int16_t4 fn(int16_t4 x, int16_t4 y) {
    return __builtin_hlsl_cross(x, y);
}
```
[Compiler Explorer](https://godbolt.org/z/79hMPMdTT)

Diagnostics:
```
<source>:2:33: error: passing 'int4' (aka 'vector<int, 4>') to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(float)))) float' (vector of 4 'float' values)
    2 |     return __builtin_hlsl_cross(x, y);
      | ^
<source>:6:33: error: passing 'int16_t4' (aka 'vector<int16_t, 4>') to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(float)))) float' (vector of 4 'float' values)
    6 |     return __builtin_hlsl_cross(x, y);
      | ^
```

These diagnostics strongly indicate to a user that you must call the builtin with a float4.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to