[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

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

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-02-12 Thread Nikolas Klauser via cfe-commits
philnik777 wrote: > > Yes, that's the interesting question. Currently we assume that if > > __builtin_constant_p(__begin <= __ptr && __ptr < __end) is false, __ptr > > can't be within the the range [__begin, __ptr). > > Thinking about this some more, I'm not sure if this is even true. > `__bu

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-02-11 Thread Timm Baeder via cfe-commits
tbaederr wrote: > Yes, that's the interesting question. Currently we assume that if > __builtin_constant_p(__begin <= __ptr && __ptr < __end) is false, __ptr can't > be within the the range [__begin, __ptr). Thinking about this some more, I'm not sure if this is even true. `__builtin_constant

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-09 Thread Nikolas Klauser via cfe-commits
philnik777 wrote: > > * We check whether two pointers are in the same range > > > > Is that possible to implement in the interpreter without going back to AST > > visitors? > > I take "in the same range" meaning as "can be compared at compile time at > all" here, so yes, that would be rather

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-09 Thread Timm Baeder via cfe-commits
tbaederr wrote: >- We check whether two pointers are in the same range > > Is that possible to implement in the interpreter without going back to AST > visitors? I take "in the same range" meaning as "can be compared at compile time at all" here, so yes, that would be rather trivial (we ha

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-09 Thread Nikolas Klauser via cfe-commits
philnik777 wrote: > > We check which one is the currently active member of a union, and > > This is `__builtin_is_within_lifetime`, isn't it? I didn't realize that exists. I guess that is the correct builtin, yes. https://github.com/llvm/llvm-project/pull/122099 ___

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-09 Thread Timm Baeder via cfe-commits
tbaederr wrote: > We check which one is the currently active member of a union, and This is `__builtin_is_within_lifetime`, isn't it? https://github.com/llvm/llvm-project/pull/122099 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://list

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-08 Thread Nikolas Klauser via cfe-commits
philnik777 wrote: Does this mean we should avoid `__builtin_constant_p` during constant evaluation when possible and instead add custom builtins in the few places we actually need the correct answer during constant evaluation? We currently use `__builtin_constant_p` in two different cases: - W

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-08 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) Changes See the comment at the beginning of `InterpBuiltinConstantP.h` for an explanation. --- Full diff: https://github.com/llvm/llvm-project/pull/122099.diff 10 Files Affected: - (modified) clang/lib/AST/ByteCo

[clang] [clang][bytecode] Implement __builtin_constant_p differently (PR #122099)

2025-01-08 Thread Timm Baeder via cfe-commits
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/122099 See the comment at the beginning of `InterpBuiltinConstantP.h` for an explanation. >From 7fe5944ed5f072c0e74202fd01aa65d87aea3787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Tue, 7 Jan