Timm Baeder
34097c07e1
[clang][bytecode] Consider unknown-size arrays in memcpy/memcmp ( #121462 )
...
When emitting diagnostics for the number of elements.
2025-01-02 10:59:08 +01:00
Timm Baeder
45e874e390
[clang][bytecode] Check for memcpy/memmove dummy pointers earlier ( #121453 )
2025-01-02 09:15:14 +01:00
Timm Baeder
f0d60170cc
[clang][bytecode] Check memove/memcpy for available elements ( #121383 )
...
Both destination and source pointer need to have at least as many
elements as requested.
2024-12-31 12:14:27 +01:00
Timm Baeder
1f2d934525
[clang][bytecode] Support pointers in __builtin_mem{move,cpy} ( #120560 )
...
Unfortunately, that means we can't use the __builtin_bit_cast
implementation for this.
2024-12-19 16:38:58 +01:00
Timm Baeder
dd6f6a096a
[clang][bytecode] Handle builtin_wmemcmp ( #120070 )
2024-12-16 13:41:14 +01:00
Timm Baeder
30cbd09f4b
[clang][bytecode] Fix memcmp/bcmp failures on big-endian hosts ( #119851 )
...
See the discussion in
https://github.com/llvm/llvm-project/pull/119678#issuecomment-2539680746
and
https://github.com/llvm/llvm-project/pull/119544#issuecomment-2539678561
2024-12-13 12:19:27 +01:00
Timm Baeder
98470c0b2e
[clang][bytecode] Handle __builtin_bcmp ( #119678 )
...
... the same as `__builtin_memcmp`. Also fix a bug we still had when we
couldn't find a difference in the two inputs after `Size` bytes.
2024-12-12 10:57:39 +01:00
Timm Bäder
cfad8f14f8
[clang][bytecode] Fix a build failure on aarch64
...
This broke e.g.
https://lab.llvm.org/buildbot/#/builders/190/builds/11216
2024-12-12 09:08:30 +01:00
Timm Baeder
8713914d76
[clang][bytecode] Handle __builtin_memcmp ( #119544 )
2024-12-12 08:59:35 +01:00
Timm Baeder
d416cae180
[clang][bytecode][NFC] Use Pointer::pointToSameBlock ( #119552 )
...
block() requires the pointer to be a block pointer.
2024-12-11 16:14:19 +01:00
Timm Baeder
4dde52d76b
[clang][bytecode] Check for overlapping memcpy regions ( #119535 )
2024-12-11 12:06:56 +01:00
Timm Baeder
6168739f00
[clang][bytecode] Reject memcpy sizes with element size remainder ( #119209 )
2024-12-09 16:57:49 +01:00
Timm Baeder
d17e51f306
[clang][bytecode] Handle __builtin_strncmp ( #119208 )
2024-12-09 16:17:39 +01:00
Jie Fu
4f08fa1a77
[clang] Fix -Wunused-variable in InterpBuiltin.cpp (NFC)
...
/llvm-project/clang/lib/AST/ByteCode/InterpBuiltin.cpp:262:23:
error: unused variable 'AC' [-Werror,-Wunused-variable]
const ASTContext &AC = S.getASTContext();
^
1 error generated.
2024-12-09 21:23:08 +08:00
Timm Baeder
00b50c917b
[clang][bytecode] Handle __builtin_wcslen ( #119187 )
...
Handle different char widths in builtin_strlen.
2024-12-09 12:34:25 +01:00
Timm Baeder
abc27039be
[clang][bytecode] Pass __builtin_memcpy size along ( #118649 )
...
To DoBitCastPtr, so we know how many bytes we want to read.
2024-12-05 06:55:18 +01:00
Timm Bäder
61c2ac03d8
Revert "[clang][bytecode] Handle __builtin_wcslen ( #118446 )"
...
This reverts commit 89a0ee89973c3d213c4bc11c26b41eab67e06da0.
This breaks builders:
https://lab.llvm.org/buildbot/#/builders/13/builds/3885
2024-12-03 13:35:57 +01:00
Timm Baeder
3f39c5df08
[clang][bytecode] Reject memcpy dummy pointers after null check ( #118460 )
...
To match the diagnostic output of the current interpreter.
2024-12-03 11:51:49 +01:00
Timm Baeder
0f4dc4276f
[clang][bytecode] Initialize elements in __builtin_elementwise_popcount ( #118457 )
2024-12-03 11:14:06 +01:00
Timm Baeder
89a0ee8997
[clang][bytecode] Handle __builtin_wcslen ( #118446 )
...
... just like strlen.
2024-12-03 10:20:30 +01:00
Timm Baeder
46446bb2d3
[clang][bytecode][NFC] Diagnose non-constexpr builtin strcmp calls ( #118442 )
2024-12-03 09:49:26 +01:00
Timm Baeder
789551362e
[clang][bytecode] Handle memmove like memcpy ( #118431 )
...
This is the same thing for us, except for diagnostic differences.
2024-12-03 07:56:06 +01:00
Timm Baeder
dac9736d05
[clang][bytecode][NFC] Diagnose no-constexpr memcpy/strlen versions ( #118429 )
2024-12-03 06:59:56 +01:00
Timm Baeder
fc9052ee25
[clang][bytecode] Check __builtin_memcpy for null pointers ( #118313 )
2024-12-03 03:36:57 +01:00
Timm Baeder
637a1ae855
[clang][bytecode] Implement __builtin_elementwise_popcount ( #118307 )
2024-12-02 16:48:22 +01:00
Timm Baeder
b587b910d5
[clang][bytecode] Implement __builtin_reduce_xor ( #118299 )
2024-12-02 16:04:49 +01:00
Timm Baeder
1288f6d405
[clang][bytecode] Implement __builtin_reduce_or ( #118292 )
2024-12-02 15:28:26 +01:00
Timm Baeder
ccc471fe3e
[clang][bytecode] Implement __builtin_reduce_and ( #118289 )
2024-12-02 14:29:38 +01:00
Timm Baeder
c1dcf75a7c
[clang][bytecode] Implement __builtin_reduce_mul ( #118287 )
2024-12-02 14:03:53 +01:00
Timm Baeder
0611fdd320
[clang][bytecode] Add simple __builtin_memcpy implementation ( #118278 )
...
Not handling all the special- and error cases yet. Just making sure the
bitcast code can be used for this as well.
2024-12-02 13:11:22 +01:00
Timm Baeder
31bde711c4
[clang][bytecode] Support __builtin_reduce_add ( #117672 )
2024-12-01 17:39:11 +01:00
Timm Baeder
82ed9c0319
[clang][bytecode][NFC] Remove APValue Result argument where unnecessary ( #118199 )
...
This is unneeded in almost all circumstances. We only return an APValue
back to clang when the evaluation is finished, and that is always done
by an EvalEmitter - which has its own implementation of the Ret
instructions.
2024-12-01 17:36:19 +01:00
Congcong Cai
cbdd14ee9d
[clang][NFC]add static for internal linkage function ( #117482 )
...
Detected by misc-use-internal-linkage
2024-11-25 06:48:33 +08:00
Timm Baeder
8951b51402
[clang][bytecode] Add more checks to _ai32_* builtins ( #114412 )
...
They are called in a few different forms that we don't support.
2024-11-01 14:19:59 +01:00
Timm Baeder
ef2a104c94
[clang][bytecode] Start implementing __builtin_bit_cast ( #112126 )
...
This is a subset of #68288 , with hopefully narrower scope. It does not
support bitcasting to non-integral types yet.
Bitfields are supported, but only if they result in a full byte-sized
final buffer. It does not support casting from null-pointers yet or
casting from indeterminate bits.
The tests are from #68288 and partially from #74775 .
The `BitcastBuffer` struct is currently always working in single bits,
but I plan to (try to) optimize this for the common full-byte case.
2024-10-31 18:09:40 +01:00
Timm Baeder
b46a0482f9
[clang][bytecode] Implement __builtin_arithmetic_fence ( #113937 )
2024-10-29 00:56:03 +01:00
Timm Baeder
615a5eb02c
[clang][bytecode] Check ai32_bextr builtins for integer args ( #113128 )
2024-10-21 08:15:51 +02:00
Timm Baeder
5405ba50de
[clang][bytecode] Check ia32_{pext,pdep} builtins for integer args ( #113091 )
2024-10-20 19:37:41 +02:00
c8ef
332ac18e31
[clang] constexpr built-in abs function. ( #112539 )
...
According to [P0533R9](https://wg21.link/P0533R9 ), the C++ standard
library functions corresponding to the C macros in `[c.math.abs]` are
now `constexpr`.
To implement this feature in libc++, we must make the built-in abs
function `constexpr`. This patch adds the implementation of a
`constexpr` abs function for the current constant evaluator and the new
bytecode interpreter.
It is important to note that in 2's complement systems, the absolute
value of the most negative value is out of range. In gcc, it will result
in an out-of-range error and will not be evaluated as constants. We
follow the same approach here.
2024-10-18 19:03:50 +08:00
Timm Baeder
790d986946
[clang][bytecode] Implement __builtin_f{maximum,minimum}_num ( #112335 )
2024-10-15 12:49:32 +02:00
Timm Baeder
80c15c48d1
[clang][bytecode] Implement __builtin_assume_aligned ( #111968 )
2024-10-11 11:46:33 +02:00
Timm Baeder
1fd79f105d
[clang][bytecode] Check number of addcarry/subborrow args ( #111952 )
...
Apparently this can fail as well.
2024-10-11 08:08:28 +02:00
Timm Baeder
f1eac77617
[clang][bytecode] Check new builtins for integer types ( #111801 )
...
These might also be called with vectors, but we don't support that.
2024-10-10 10:23:59 +02:00
Timm Baeder
6f8e855150
[clang][bytecode] Implement __builtin_ai32_addcarryx* ( #111671 )
2024-10-09 15:42:19 +02:00
Timm Baeder
235067b222
[clang][bytecode] Make sure ia32_bzhi input is an integer ( #111505 )
2024-10-08 13:30:40 +02:00
Timm Baeder
e1e788f423
[clang][bytecode] Protect ia32_{lzcnt,tzcnt} against non-integers ( #110699 )
...
These are also called for vectors.
2024-10-02 05:44:54 +02:00
Timm Baeder
f3baa73c8b
[clang][bytecode] Implement ia32_{pdep,pext} builtins ( #110675 )
2024-10-01 17:17:37 +02:00
Timm Baeder
7147e88f55
[clang][bytecode] Implement lzcnt/tzcnt/bzhi builtins ( #110639 )
2024-10-01 12:04:32 +02:00
Timm Baeder
8518178857
[clang][bytecode] Implement ia32_bextr builitns ( #110513 )
2024-09-30 20:07:28 +02:00
Timm Baeder
a024a0ceed
[clang][bytecode] Override InConstantContext flag for immediate calls ( #109967 )
...
And fix the diagnostics for __builtin_is_constant_evaluated(). We can be
in a non-constant context, but calling an immediate function always
makes the context constant for the duration of that call.
2024-09-25 16:46:46 +02:00