[clang] [clang][bytecode] Fix unknown size arrays crash in clang bytecode (PR #160015)

2025-09-22 Thread Timm Baeder via cfe-commits
tbaederr wrote: The description of this issue should say "Fixes #153948" at the end so it gets properly closed. https://github.com/llvm/llvm-project/pull/160015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mai

[clang] [clang][bytecode] Fix unknown size arrays crash in clang bytecode (PR #160015)

2025-09-22 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr approved this pull request. https://github.com/llvm/llvm-project/pull/160015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Use in `Expr::tryEvaluateString` (PR #160118)

2025-09-22 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/160118 Fixes #157492 >From 817af36fba48a42670afc91dc49a3ad748187363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 16 Sep 2025 16:02:15 +0200 Subject: [PATCH] try evaluate string --- clang/

[clang] [clang]bytecode] Add degenerate pointers (PR #160086)

2025-09-22 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/160086 None >From 40c51d8bb280d3657ee7a18d795ed6faa30ba096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 22 Sep 2025 08:19:20 +0200 Subject: [PATCH] [clang]bytecode] Add degenerate pointers

[clang] [clang][bytecode] Fix unknown size arrays crash in clang bytecode (PR #160015)

2025-09-22 Thread Timm Baeder via cfe-commits
@@ -245,6 +245,11 @@ bool Context::evaluateStrlen(State &Parent, const Expr *E, uint64_t &Result) { if (!FieldDesc->isPrimitiveArray()) return false; +// Handle unknown size arrays - we can't determine the length at compile time +if (Ptr.isUnknownSizeArray(

[clang] [clang][bytecode] Fix unknown size arrays crash in clang bytecode (PR #160015)

2025-09-22 Thread Timm Baeder via cfe-commits
@@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -std=c++20 -fexperimental-new-constant-interpreter %s -verify +// RUN: %clang_cc1 -std=c++20 %s -verify=ref + +// expected-no-diagnostics +// ref-no-diagnostics + tbaederr wrote: ```suggestion /// Test that __builtin_strlen(

[clang] [clang]bytecode] Add degenerate pointers (PR #160086)

2025-09-22 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr converted_to_draft https://github.com/llvm/llvm-project/pull/160086 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Fix unknown size arrays crash in clang bytecode (PR #160015)

2025-09-22 Thread Timm Baeder via cfe-commits
@@ -0,0 +1,14 @@ +// Test that strlen() on external/unknown declarations doesn't crash the bytecode interpreter tbaederr wrote: This test doesn't do anything, check the others for appropriate RUN lines. https://github.com/llvm/llvm-project/pull/160015 _

[clang] [clang][bytecode] Fix unknown size arrays crash in clang bytecode (PR #160015)

2025-09-22 Thread Timm Baeder via cfe-commits
tbaederr wrote: > Tested with the reproducer from the GitHub issue. Add it as a test then? https://github.com/llvm/llvm-project/pull/160015 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[clang] [clang][bytecode][test] Enable a few tests in const-eval.c (PR #160034)

2025-09-21 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/160034 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode][test] Enable a few tests in const-eval.c (PR #160034)

2025-09-21 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/160034 They didn't use to work but do now. >From e2a9bc7543be873f65af9ed40a244a4d429301b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 22 Sep 2025 08:21:19 +0200 Subject: [PATCH] [clang][by

[clang] [Headers][X86] VectorExprEvaluator::VisitCallExpr - allow SSE/AVX2/AVX512 pack intrinsics to be used in constexpr (PR #156003)

2025-09-21 Thread Timm Baeder via cfe-commits
@@ -7,6 +7,7 @@ //===--===// #include "../ExprConstShared.h" #include "Boolean.h" +#include "ByteCode/FixedPoint.h" tbaederr wrote: This look unneeded. https://github.com/llvm/llvm-project/p

[clang] [clang][bytecode] Load value of non-lvalue ArraySubscriptExpr (PR #160024)

2025-09-21 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/160024 As happens in C. Fixes #158482 >From a00eb5e8b9b1267b8614c6fc8d0dfa419fb6f867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 22 Sep 2025 05:01:46 +0200 Subject: [PATCH] [clang][byteco

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (PR #158778)

2025-09-20 Thread Timm Baeder via cfe-commits
@@ -2937,6 +2937,50 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC, + const CallExpr *Call, +

[clang] [clang][ExprConst] Reject unary vector shuffles (PR #158589)

2025-09-20 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/158589 >From 1ee924c160f8b369b82fe4baf05a7428c8a10586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Sep 2025 11:

[clang] [clang][sema][NFC] Clean up builtin arg checking functions (PR #158615)

2025-09-20 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/158615 >From e6be0335f0cc2370ccb1a93c5994843e23db96a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Sep 2025 13:45:54 +0200 Subject: [PATCH] Cleanup --- clang/include/clang/Sema/Sema.h |

[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)

2025-09-20 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/158575 >From 09216705f6869f3b50038a7adb82d55e791d704e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Sep 2025 10:31:07 +0200 Subject: [PATCH] [clang][bytecode] Improve error detection in Bi

[clang] [clang][bytecode] Use bytecode interpreter in EvaluateAsLValue (PR #158038)

2025-09-20 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158038 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [libcxx] [Clang] Allow __builtin_fma/fmaf/fmal to be used in a constant expression (PR #158048)

2025-09-20 Thread Timm Baeder via cfe-commits
tbaederr wrote: LGTM from my side. https://github.com/llvm/llvm-project/pull/158048 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Remove bogus Initializing special case (PR #159933)

2025-09-20 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159933 This doesn't seem to be needed anymore and causes problems. Fixes #159787 >From 48e76ae65ccf422d13f408a34c3f82d73388c78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Sat, 20 Sep 2025 18:

[clang] [clang] diagnose invalid std::tuple_size sizes (PR #159677)

2025-09-19 Thread Timm Baeder via cfe-commits
@@ -1222,6 +1222,16 @@ static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, if (E.isInvalid()) return IsTupleLike::Error; + if (Size < 0 || Size >= UINT_MAX) { +llvm::SmallVector Str; +Size.toString(Str); tbaederr wrote: Thi

[clang] [clang][bytecode] Typecheck called function pointers more thorougly (PR #159757)

2025-09-19 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Typecheck called function pointers more thorougly (PR #159757)

2025-09-19 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr edited https://github.com/llvm/llvm-project/pull/159757 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Typecheck called functions pointer more thorougly (PR #159757)

2025-09-19 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/159757 >From 3d94cfde4833c54a91c25d1f5ff7dd2e4636f8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 19 Sep 2025 13:03:42 +0200 Subject: [PATCH] [clang][bytecode] Typecheck called functions po

[clang] [clang][bytecode] Typecheck called functions pointer more thorougly (PR #159757)

2025-09-19 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159757 Fix two older FIXME items from the `functions.cpp` test. >From a42d4ef1b94bc1844ea0c5d2091c433617490983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 19 Sep 2025 13:03:42 +0200 Subjec

[clang] [clang][bytecode] Move generic lambda handling to Compiler (PR #159733)

2025-09-19 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159733 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Move generic lambda handling to Compiler (PR #159733)

2025-09-19 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159733 So the static invoker's Function still points to the static invoker instead of the call operator of the lambda record. This is important for a later commit. >From 447077a9185fe31bedf78293a2037942a07625cf Mon S

[clang] [X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add SSE/AVX VPTEST/VTESTPD/VTESTPS intrinsics to be used in constexpr (PR #159684)

2025-09-19 Thread Timm Baeder via cfe-commits
tbaederr wrote: Try running in a debugger and adding breakpoints for `CCEDiag` and `FFDiag` and see where it fails. https://github.com/llvm/llvm-project/pull/159684 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin

[clang] [Clang][NFC] Remove duplicated specialization of `llvm::DenseMapInfo` (PR #159718)

2025-09-19 Thread Timm Baeder via cfe-commits
@@ -3843,4 +3843,25 @@ typename clang::LazyGenerationalUpdatePtr::ValueType return Value; } +template <> struct llvm::DenseMapInfo { + static FoldingSetNodeID getEmptyKey() { return FoldingSetNodeID{}; } + + static FoldingSetNodeID getTombstoneKey() { +FoldingSetNodeID

[clang] [clang][bytecode] Remove InterpFrame::IsBottom flag (PR #159279)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159279 The bottom frame is the one without a parent. No need to save that information separately. >From 89660bb96ee87cfd7634765a44c220b85702f201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed

[clang] [clang][bytecode] Check strlen impl for primitive arrays (PR #157494)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/157494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode][NFC] Add some popToAPSInt convenience API (PR #159252)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/159252 >From 99d285aa7475c954f897981ea28bb44aca042b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 17 Sep 2025 08:38:44 +0200 Subject: [PATCH] [clang][bytecode][NFC] Add some popToAPSInt con

[clang] [clang][Sema] Reject negative tuple sizes (PR #159579)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159579 Negative sizes don't make sense and trip up the code using `UnsignedOrNone`. Fixes #159563 >From 5fcc0e20cd64f27c284782c5e60c54f68ca657da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu

[clang] [clang][Sema] Reject negative tuple sizes (PR #159579)

2025-09-18 Thread Timm Baeder via cfe-commits
tbaederr wrote: `UnsignedOrNone` just means we assert there when passing `-1`. With a full `std::optional` the value would just underflow and the value we use later would've been wrong. The incorrect handling of negative values has nothing to do with `UnsignedOrNone`. https://github.com/llvm/

[clang] [clang][ExprConst] Try to minimize emitting unneeded diagnostics (PR #159528)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr edited https://github.com/llvm/llvm-project/pull/159528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Pass `SourceInfo` objects by value (PR #159532)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159532 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Allow mutation in `__builtin_constant_p`'s argument (PR #159599)

2025-09-18 Thread Timm Baeder via cfe-commits
tbaederr wrote: Not sure what the reason is we have the same behavior in `__builtin_object_size`. GCC seems to evaluate the side effects as well. https://github.com/llvm/llvm-project/pull/159599 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [clang][ExprConst] Allow mutation in `__builtin_constant_p`'s argument (PR #159599)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159599 Allow side effects and mutation of local variables in the argument of a `__builtin_constant_p` call. This aligns clang's behavior with GCC's current behavior: https://godbolt.org/z/8xhMxY6rx >From 893e7137

[clang] [clang][ExprConst] Try to minimize emitting unneeded diagnostics (PR #159528)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159528 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Optimize InterpStack (PR #159400)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159400 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Pass `SourceInfo` objects by value (PR #159532)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/159532 >From 151dfc42b7708fb137c098fab053421c6a2423de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 18 Sep 2025 06:42:51 +0200 Subject: [PATCH] Copy sourceinfo around --- clang/lib/AST/Byte

[clang] [clang][ExprConst] Try to minimize emitting unneeded diagnostics (PR #159528)

2025-09-18 Thread Timm Baeder via cfe-commits
tbaederr wrote: This is good: https://llvm-compile-time-tracker.com/compare.php?from=efa7385831503b38b45f8b4eca3e21ba7a261097&to=d17e469d8066482a00c0b647a0044a58c710bfc1&stat=instructions:u But it breaks the `__builtin_constant_p` handling :roll_eyes: https://github.com/llvm/llvm-project/pull/

[clang] [clang][bytecode] Pass `SourceInfo` objects by value (PR #159532)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr edited https://github.com/llvm/llvm-project/pull/159532 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Pass `SourceInfo` object by value (PR #159532)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr ready_for_review https://github.com/llvm/llvm-project/pull/159532 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Try to minimize emitting unneeded diagnostics (PR #159528)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159528 There are a few places in clang where we pass a list of diagnostic notes to the `evaluate*` functions, which so some extra work when that list is passed (e.g. attaching call stacks to the diagnostics). We then

[clang] [clang][bytecode] Pass `SourceInfo` object by value (PR #159532)

2025-09-18 Thread Timm Baeder via cfe-commits
tbaederr wrote: https://llvm-compile-time-tracker.com/compare.php?from=03ef1e9181aaec7f0601736a42e5db842b0d4e4f&to=76814a4a2aa9c4e337ac8dcccf523141ef84f3dd&stat=instructions:u https://github.com/llvm/llvm-project/pull/159532 ___ cfe-commits mailing lis

[clang] [clang][bytecode] Pass `SourceInfo` object by value (PR #159532)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159532 They are only pointer-sized and copying them is cheaper than taking the const ref. >From 8fb387f92694345bd6428826970bb2bef1486e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 18 Sep

[clang] [clang] Remove Diag parameter from Expr::EvaluateKnownConstInt (PR #159512)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159512 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][Expr][NFC] Fix some doc comments (PR #159504)

2025-09-18 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159504 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Remove Diag parameter from Expr::EvaluateKnownConstInt (PR #159512)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159512 If it's truly a known const int, it won't emit any diagnostics anyway. And if it did, we wouldn't notice because no call site passed something non-null. >From a4225f17a52c50239cf6ca82214adf546325708d Mon Sep 1

[clang] [clang][Expr][NFC] Fix some doc comments (PR #159504)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159504 Use proper doc comments here instead of regular comments. >From 0d1679e0857cd4f1da08878a1407c12cf74fcce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Thu, 18 Sep 2025 06:57:51 +0200 Subje

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-17 Thread Timm Baeder via cfe-commits
@@ -2903,6 +2903,55 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_pternlog(InterpState &S, CodePtr OpPC, + const CallExpr *Call, bool MaskZ) { + assert(Call->getNumArgs() == 5); + + const V

[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)

2025-09-17 Thread Timm Baeder via cfe-commits
@@ -572,3 +571,19 @@ namespace VectorCast { #endif } #endif + +namespace ToPrimPtrs { + struct S { int foo () { return 0; } }; + auto ptr = __builtin_bit_cast(int *, ((__INTPTR_TYPE__) 0)); + auto nptr = __builtin_bit_cast(nullptr_t, ((__INTPTR_TYPE__)0)); + + constexpr au

[clang] [clang][sema][NFC] Clean up builtin arg checking functions (PR #158615)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/158615 Always take an `unsigned` for the argument index, pull some locals in the closest scope and use `APInt::isPowerOf2()`. >From 4f82e5a3ed3a966aadbaa71b3cc945d1eb559d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ti

[clang] [clang][bytecode] Don't update temporary in InitGlobalTemp* (PR #158022)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158022 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Move getLangOpts() to interp::State subclasses (PR #159280)

2025-09-17 Thread Timm Baeder via cfe-commits
@@ -945,6 +945,7 @@ namespace { } ASTContext &getASTContext() const override { return Ctx; } +const LangOptions &getLangOpts() const { return Ctx.getLangOpts(); } tbaederr wrote: ```console $ grep "Info.getLangOpts()" ../clang/lib/AST/ExprConstant

[clang] [clang][bytecode][NFC] Surround Pointer diagram in \verbatim (PR #158550)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Assert that EvaluateAsInitializer has non-null VD (PR #159274)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159274 Both the expression (the initializer) as well as the VarDecl can't be null here. Assert that. >From ed0797da5f059b7f6e560a8f07c455937afd9721 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date:

[clang] [clang][bytecode] Optimize InterpStack (PR #159400)

2025-09-17 Thread Timm Baeder via cfe-commits
tbaederr wrote: https://llvm-compile-time-tracker.com/compare.php?from=a0162219165b94b950fe10547307378c0a306b74&to=03ef1e9181aaec7f0601736a42e5db842b0d4e4f&stat=instructions:u https://github.com/llvm/llvm-project/pull/159400 ___ cfe-commits mailing lis

[clang] [clang][bytecode] Optimize InterpStack (PR #159400)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159400 Replace `StackChunk::End` with `StackChunk::Size`, mark the allocating code paths as unlikely and move `grow()` into the header, which allows us to template this for the `Size` parameter. Since we only push ou

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (PR #158778)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr edited https://github.com/llvm/llvm-project/pull/158778 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][BufferUsage] Fix a StringRef lifetime issue (PR #159109)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159109 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Move getLangOpts() to interp::State subclasses (PR #159280)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159280 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Assert that EvaluateAsInitializer has non-null VD (PR #159274)

2025-09-17 Thread Timm Baeder via cfe-commits
tbaederr wrote: CI failure is a timed-out LLDB test. https://github.com/llvm/llvm-project/pull/159274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Assert that EvaluateAsInitializer has non-null VD (PR #159274)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/159274 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][ExprConst] Assert that EvaluateAsInitializer has non-null VD (PR #159274)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/159274 >From 36b5fee1993d350a22b63171a363654df4c76b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Wed, 17 Sep 2025 09:44:14 +0200 Subject: [PATCH] [clang][ExprConst] Assert that EvaluateAsInitia

[clang] [clang][ExprConst] Move getLangOpts() to interp::State subclasses (PR #159280)

2025-09-17 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159280 Instead of having `State::getLangOpts()`, which does a virtual call to `getASTContext()` to call `getLangOpts() on that, just move `getLangOpts()` to the subclasses so we can do that without the virtual call.

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (PR #158778)

2025-09-16 Thread Timm Baeder via cfe-commits
@@ -2937,6 +2937,56 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC, + const CallExpr *Call, +

[clang] [clang][BufferUsage] Fix a StringRef lifetime issue (PR #159109)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159109 The code before assigned the `std::string` returned from `tryEvaluateString()` to the `StringRef`, but it was possible that the underlying data of that string vanished in the meantime, passing invalid stack me

[clang] [clang][bytecode] Pass initializer along in `evaluateAsInitializer()` (PR #158056)

2025-09-16 Thread Timm Baeder via cfe-commits
@@ -5,6 +5,7 @@ // RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm -fprebuilt-module-path=%t // RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface -o %t/c.pcm -fprebuilt-module-path=%t // RUN: %clang_cc1 -std=c++20 %t/d.cpp -fp

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-16 Thread Timm Baeder via cfe-commits
@@ -2903,6 +2903,55 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_pternlog(InterpState &S, CodePtr OpPC, + const CallExpr *Call, bool MaskZ) { + assert(Call->getNumArgs() == 5); + + const V

[clang] [clang][bytecode] Fix bit casts to IntAP types (PR #158509)

2025-09-16 Thread Timm Baeder via cfe-commits
tbaederr wrote: That should be fixed by https://github.com/llvm/llvm-project/commit/24b58678bcde7d33117941b443f9bcd0fe67767a already https://github.com/llvm/llvm-project/pull/158509 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://list

[clang] [clang][bytecode] Optimize InitElem{,Pop} (PR #159084)

2025-09-16 Thread Timm Baeder via cfe-commits
tbaederr wrote: https://llvm-compile-time-tracker.com/compare.php?from=e28efd6e025c733238c90f2bb315c0515a6aeec5&to=51626557778ae33bce298b0dd66aded23be47a42&stat=instructions:u https://github.com/llvm/llvm-project/pull/159084 ___ cfe-commits mailing lis

[clang] [clang][bytecode] Optimize InitElem{,Pop} (PR #159084)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/159084 >From 9b5c07fe9611d2fa03a7915175a2177032782ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 16 Sep 2025 12:39:04 +0200 Subject: [PATCH] InitElem --- clang/lib/AST/ByteCode/Interp.h

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (PR #158778)

2025-09-16 Thread Timm Baeder via cfe-commits
@@ -2937,6 +2937,56 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC, + const CallExpr *Call, +

[clang] [clang][bytecode] Assert on virtual func call from array elem (PR #158502)

2025-09-16 Thread Timm Baeder via cfe-commits
@@ -1100,3 +1100,25 @@ namespace DiscardedTrivialCXXConstructExpr { constexpr int y = foo(12); // both-error {{must be initialized by a constant expression}} \ // both-note {{in call to}} } + +namespace VirtualFunctionCallThroughArrayElem { + st

[clang] [clang][bytecode] Optimize InitElem{,Pop} (PR #159084)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/159084 Try harder to avoid creating a new `Pointer` for the element. >From c4f2102e9fb8335c7d5f19c93753650970ce5e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 16 Sep 2025 12:39:04 +0200 S

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (PR #158778)

2025-09-16 Thread Timm Baeder via cfe-commits
@@ -2937,6 +2937,56 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_x86_insert_subvector(InterpState &S, CodePtr OpPC, + const CallExpr *Call, +

[clang] [clang][bytecode][NFC] InterpState: get ASTContext from interp::Context (PR #158852)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode][NFC] InterpState: get ASTContext from interp::Context (PR #158852)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/158852 Access the Parent state one less time. >From d5b1847f7019443ebd40543311391b149de45ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 16 Sep 2025 11:03:55 +0200 Subject: [PATCH] [clang]

[clang] [clang][bytecode] Create InterpState allocator on demand (PR #158802)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158802 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Assert on virtual func call from array elem (PR #158502)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr edited https://github.com/llvm/llvm-project/pull/158502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158575 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][bytecode] Create InterpState allocator on demand (PR #158802)

2025-09-16 Thread Timm Baeder via cfe-commits
tbaederr wrote: https://llvm-compile-time-tracker.com/compare.php?from=ee324d3a1f6a4f48d5af5bc990f59606027f5c03&to=6e349497bd4c58c381378be9e1dc8dccfd7cab7d&stat=instructions:u https://github.com/llvm/llvm-project/pull/158802 ___ cfe-commits mailing lis

[clang] [clang][bytecode] Create InterpState allocator on demand (PR #158802)

2025-09-16 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/158802 We often don't need it (especially in C), so make this optional and create it only when we first allocate something. >From 6e55ce4b529cdb1e42fd5703cc946118ed84844d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm

[clang] [clang][ExprConst] Reject unary vector shuffles (PR #158589)

2025-09-15 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://list

[clang] [clang][bytecode][NFC] Remove BlockScope (PR #158656)

2025-09-15 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][sema][NFC] Clean up builtin arg checking functions (PR #158615)

2025-09-15 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr closed https://github.com/llvm/llvm-project/pull/158615 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -3543,7 +3592,20 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, case X86::BI__builtin_ia32_selectpd_256: case X86::BI__builtin_ia32_selectpd_512: return interp__builtin_select(S, OpPC, Call); - + case X86::BI__builtin_ia32_pternlogd128

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -3543,7 +3592,20 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, case X86::BI__builtin_ia32_selectpd_256: case X86::BI__builtin_ia32_selectpd_512: return interp__builtin_select(S, OpPC, Call); - + case X86::BI__builtin_ia32_pternlogd128

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -2903,6 +2903,55 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_pternlog(InterpState &S, CodePtr OpPC, + const CallExpr *Call, bool MaskZ) { + assert(Call->getNumArgs() == 5); + + const V

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -2903,6 +2903,55 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_pternlog(InterpState &S, CodePtr OpPC, + const CallExpr *Call, bool MaskZ) { + assert(Call->getNumArgs() == 5); + + const V

[clang] [Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add AVX512 VPTERNLOGD/VPTERNLOGQ intrinsics to be used in constexpr (PR #158703)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -2903,6 +2903,55 @@ static bool interp__builtin_elementwise_triop( return true; } +static bool interp__builtin_pternlog(InterpState &S, CodePtr OpPC, + const CallExpr *Call, bool MaskZ) { + assert(Call->getNumArgs() == 5); + + const V

[clang] [clang][bytecode] Improve error detection in BitCastPrim op (PR #158575)

2025-09-15 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/158575 >From 693e1d6d5bd52203ec5c76866657799402b054ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Sep 2025 10:31:07 +0200 Subject: [PATCH] [clang][bytecode] Improve error detection in Bi

[clang] [clang][ExprConst] Reject unary vector shuffles (PR #158589)

2025-09-15 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= , Timm =?utf-8?q?Bäder?= Message-ID: In-Reply-To: https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/158589 >From 1ee924c160f8b369b82fe4baf05a7428c8a10586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= D

[clang] [Clang] Add vector gather / scatter builtins to clang (PR #157895)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -2361,6 +2363,101 @@ static ExprResult BuiltinMaskedStore(Sema &S, CallExpr *TheCall) { return TheCall; } +static ExprResult BuiltinMaskedGather(Sema &S, CallExpr *TheCall) { + if (S.checkArgCountRange(TheCall, 3, 4)) +return ExprError(); + + Expr *MaskArg = TheCal

[clang] [Clang] Add vector gather / scatter builtins to clang (PR #157895)

2025-09-15 Thread Timm Baeder via cfe-commits
@@ -2361,6 +2363,101 @@ static ExprResult BuiltinMaskedStore(Sema &S, CallExpr *TheCall) { return TheCall; } +static ExprResult BuiltinMaskedGather(Sema &S, CallExpr *TheCall) { + if (S.checkArgCountRange(TheCall, 3, 4)) +return ExprError(); + + Expr *MaskArg = TheCal

[clang] [clang][bytecode][NFC] Remove BlockScope (PR #158656)

2025-09-15 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/158656 Unused these days. >From 5d069297139dcc7bfef03dedb1e7e46c34bf1727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Sep 2025 17:00:28 +0200 Subject: [PATCH] [clang][bytecode][NFC] Remo

[clang] [clang][ExprConst] Reject unary vector shuffles (PR #158589)

2025-09-15 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= , Timm =?utf-8?q?B=C3=A4der?= Message-ID: In-Reply-To: tbaederr wrote: Added. https://github.com/llvm/llvm-project/pull/158589 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://

[clang] [clang][sema][NFC] Clean up builtin arg checking functions (PR #158615)

2025-09-15 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr updated https://github.com/llvm/llvm-project/pull/158615 >From 2657f76ca434b2dbf97750de609e9eba55bc18c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Mon, 15 Sep 2025 13:45:54 +0200 Subject: [PATCH] Cleanup --- clang/include/clang/Sema/Sema.h |

  1   2   3   4   5   6   7   8   9   10   >