[clang] [Clang] Fix cluster_dims thread block limit checks (PR #230186)

Petar Jovanovic via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 8 13:46:25 PDT 2026


================
@@ -6180,10 +6180,13 @@ static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
                         AL.getNumArgs() > 2 ? AL.getArgAsExpr(2) : nullptr);
 }
 
-static std::pair<Expr *, int>
+static std::pair<Expr *, uint64_t>
----------------
petar-jovanovic wrote:

If we use a 5-bit bound, values above 31 will fail here and we will report

`cannot be represented in a 5-bit unsigned integer type`

yet, this way we report IMHO the more useful

`cluster does not support more than 16 thread blocks; N provided`

Otherwise, e.g. `cluster_dims(32, 2, 4) ` will never reach the cluster-size check and we will lose the diagnostic this patch is intended to restore.

This way, we get (nice) error report:

`"cluster does not support more than 16 thread blocks; 256 provided".`

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


More information about the cfe-commits mailing list