[clang] [Clang] Restrict AMDGCN image built-ins (PR #180949)

Alexey Sachkov via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 6 04:34:44 PST 2026


================
@@ -293,9 +323,14 @@ bool SemaAMDGPU::CheckAMDGCNBuiltinFunctionCall(unsigned BuiltinID,
     unsigned ArgCount = TheCall->getNumArgs() - 1;
     llvm::APSInt Result;
 
-    return (SemaRef.BuiltinConstantArg(TheCall, 1, Result)) ||
-           (SemaRef.BuiltinConstantArg(TheCall, ArgCount, Result)) ||
-           (SemaRef.BuiltinConstantArg(TheCall, (ArgCount - 1), Result));
+    // Complain about dmask values which are too huge to fully fit into 4 bits
+    // (which is the actual size of the dmask in corresponding HW instructions).
+    constexpr unsigned DMaskArgNo = 1;
+    return SemaRef.BuiltinConstantArgRange(TheCall, DMaskArgNo, /* Low = */ 0,
+                                           /* High = */ 15,
+                                           /* RangeIsError = */ true) ||
----------------
AlexeySachkov wrote:

Applied in d794ed4805136b253bde2d8aea600549adc943e5

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


More information about the cfe-commits mailing list