[clang] [Clang][OpenMP] Fix crash on `_BitInt` loop bounds and counters in loop analysis (PR #226464)
Akash Manna via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 25 07:50:06 PDT 2026
================
@@ -5969,6 +5640,16 @@ class CaptureVars : public TreeTransform<CaptureVars> {
};
} // namespace
+/// Like ASTContext::getIntTypeForBitwidth, but falls back to a _BitInt type
+/// when no standard integer type has the requested width.
+static QualType getIntTypeForBitwidthOrBitInt(ASTContext &C, unsigned Bits,
+ bool Signed) {
+ QualType Ty = C.getIntTypeForBitwidth(Bits, Signed);
+ if (Ty.isNull())
+ Ty = C.getBitIntType(/*IsUnsigned=*/!Signed, Bits);
----------------
akash-manna-sky wrote:
That would narrow the bound, not the count. Only `Upper` is cast here, and `(unsigned long)b - a` still has type `_BitInt(931)`, so a truncated `Upper` gives a wrong count even when the count fits in 64 bits (GCC's libgomp `bitint-1.c` `baz`: 2^930 bounds, 77 iterations, comes out as a large negative number). The count itself is already narrowed to 64 bits with `warn_omp_loop_64_bit_var` in `buildNumIterations`, same as `__int128`.
https://github.com/llvm/llvm-project/pull/226464
More information about the cfe-commits
mailing list