[all-commits] [llvm/llvm-project] 8f887e: [HLSL] Add CustomTypeChecking and improve sema for...

Deric C. via All-commits all-commits at lists.llvm.org
Mon Sep 14 15:06:50 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8f887e33d2b18328885716bcbdc568680335f43e
      https://github.com/llvm/llvm-project/commit/8f887e33d2b18328885716bcbdc568680335f43e
  Author: Deric C. <cheung.deric at gmail.com>
  Date:   2026-09-14 (Mon, 14 Sep 2026)

  Changed paths:
    M clang/include/clang/Basic/Builtins.td
    M clang/lib/CodeGen/CGHLSLBuiltins.cpp
    M clang/lib/Sema/SemaHLSL.cpp
    M clang/test/CodeGenHLSL/resources/Textures-Gather.hlsl
    M clang/test/CodeGenHLSL/resources/Textures-Sample.hlsl
    M clang/test/CodeGenHLSL/resources/Textures-SampleBias.hlsl
    M clang/test/CodeGenHLSL/resources/Textures-SampleCmp.hlsl
    M clang/test/CodeGenHLSL/resources/Textures-SampleCmpLevelZero.hlsl
    M clang/test/CodeGenHLSL/resources/Textures-SampleGrad.hlsl
    M clang/test/CodeGenHLSL/resources/Textures-SampleLevel.hlsl
    A clang/test/SemaHLSL/BuiltIns/resource_gather-errors.hlsl
    A clang/test/SemaHLSL/BuiltIns/resource_load-errors.hlsl
    A clang/test/SemaHLSL/BuiltIns/resource_sample-errors.hlsl

  Log Message:
  -----------
  [HLSL] Add CustomTypeChecking and improve sema for texture builtins (#221060)

This PR makes the texture builtins (for load, sample, gather) use
CustomTypeChecking, and adds additional semantic checks for them to make
them more strict and conform with the way sema checks are done for other
builtins.

The main benefit of CustomTypeChecking is preventing
DefaultArgumentPromotion from occurring due to the builtins being
declared `void(...)`; primarily, the promotion of float/half to double
is undesirable.
Floating-point scalar operands in codegen (`CGHLSLBuiltins.cpp`) for
these builtins always had a check and cast of the form `if
(Op->getType() != FloatTy) Op = CreateFPCast(Op, FloatTy);` to
compensate for that, which looked like a code smell to me.
The DefaultArgumentPromotion also affected diagnostics, which would
report the promoted type (double) instead of the type the user provided
(float) (e.g., https://hlsl.godbolt.org/z/Yec3dKh14). These diagnostics
were not exercised before, and this PR adds tests to exercise them.

Sema checks for the texture builtin args have also been made more strict
and rewritten to be like sema for other builtins, using
`CheckArgTypeMatches` rather than only checking vector element count.

Finally, in preparation for 1D texture types, the sema for texture
builtins now allow scalar args where it is relevant.

Assisted by: Claude Opus 5

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list