Timm Baeder
202ad47fe1
[clang][bytecode] SourceInfo::Source might be null ( #115905 )
...
This broke in 23fbaff9a3fd2b26418e0c2f10b701049399251f, but the old
.dyn_cast<> handled null.
2024-11-13 08:35:50 +01:00
Kazu Hirata
23fbaff9a3
[ByteCode] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) ( #115809 )
...
Note that PointerUnion::{is,get,dyn_cast} have been soft deprecated in
PointerUnion.h:
// FIXME: Replace the uses of is(), get() and dyn_cast() with
// isa<T>, cast<T> and the llvm::dyn_cast<T>
2024-11-11 22:49:58 -08:00
Richard Smith
de18fa1ace
Don't redundantly specify the default template argument to BumpPtrAllocatorImpl
( #114857 )
2024-11-06 18:45:27 -08:00
Timm Baeder
1b3da362c5
[clang][bytecode] Fix bitcasting packed bool vectors ( #114937 )
...
This is a special case we need to handle. We don't do bitcasting _into_
such vectors yet though.
2024-11-05 11:43:09 +01:00
Timm Baeder
5f84b332ec
[clang][bytecode] Fix discarding __builtin_bit_cast calls ( #114926 )
...
Optionally prepare storage for the result and do the bitcast anyway, to
get the right diagnostic output.
2024-11-05 11:05:23 +01:00
Timm Baeder
2f13fbfcd1
[clang][bytecode] Support bitcasting into float fields ( #114825 )
2024-11-05 05:52:03 +01:00
Timm Baeder
1f55d77189
[clang][bytecode][NFC] Remove unused parameter from pushData() ( #114801 )
2024-11-04 17:14:05 +01:00
Timm Baeder
3268d51a5c
[clang][bytecode][NFC] Fix a possible build warning ( #114800 )
...
InterpBuiltinBitCast.cpp:95:3: warning: non-void function does not
return a value in all control paths [-Wreturn-type]
95 | }
| ^
1 warning generated.
2024-11-04 16:58:44 +01:00
Timm Baeder
2588b8be56
[clang][bytecode] Implement bitcasts to composite types ( #114776 )
...
Only fixed-size, non-bitfield integral fields for now.
2024-11-04 15:10:10 +01:00
Timm Baeder
fb30208d1e
[clang][bytecode][NFC] Make Floating::bitcastToMemory const ( #114777 )
...
The other functions like this are also const.
2024-11-04 14:00:24 +01:00
Timm Baeder
5b32c5954b
[clang][bytecode] Implement bitcasts to floating-point values ( #114485 ) ( #114712 )
...
This time I tested on big-endian hosts.
2024-11-03 19:42:26 +01:00
Timm Baeder
88823d08ab
[clang][bytecode][NFC] Switch BitcastBuffer to SmallVector ( #114677 )
...
This is a little easier to work with since we are guaranteed that the
item type of the vector is byte sized and not something else.
2024-11-03 11:16:59 +01:00
Timm Bäder
c2a892f49a
Revert "[clang][bytecode] Implement bitcasts to floating-point values ( #114485 )"
...
This reverts commit c752efbdcc1ebd81f879633d6b798248064e2ae2.
This broke bots:
- https://lab.llvm.org/buildbot/#/builders/13/builds/3268
- https://lab.llvm.org/buildbot/#/builders/42/builds/1718
2024-11-02 01:54:38 +01:00
Timm Baeder
c752efbdcc
[clang][bytecode] Implement bitcasts to floating-point values ( #114485 )
2024-11-01 14:58:19 +01: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
1e19f0f9d9
[clang][bytecode] Implement IntegralAP bitcasting ( #114471 )
...
Only for full-byte bitwidths for now.
2024-11-01 09:15:05 +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
05910b44c9
[clang][bytecode][NFC] Use const auto* for Type cast result ( #114405 )
2024-10-31 16:37:53 +01:00
Timm Baeder
2c82079924
[clang][bytecode] Fix Pointer::toAPValue() for multidimensional arrays ( #114400 )
...
When we see an array root, that pointer might yet again be an array
element, so check for that.
2024-10-31 15:15:59 +01:00
Timm Baeder
ccb7cc319f
[clang][bytecode] Diagnose negative array sizes differently ( #114380 )
...
We have a special diagnostic ID for this.
2024-10-31 10:59:53 +01:00
Timm Baeder
f0b9a0ba06
[clang][bytecode] Diagnose delete with non-virtual dtor ( #114373 )
...
... in the base class.
2024-10-31 10:13:40 +01:00
Timm Baeder
87b6ec3be6
[clang][bytecode] Diagnose placement-new construction to inactive field ( #114047 )
...
We can reuse CheckActive() for this.
2024-10-29 15:08:41 +01:00
Timm Baeder
ec871cfcdf
[clang][bytecode][NFC] Remove Pointer::elem() ( #114046 )
...
Unused.
2024-10-29 15:00:36 +01:00
Timm Baeder
b46a0482f9
[clang][bytecode] Implement __builtin_arithmetic_fence ( #113937 )
2024-10-29 00:56:03 +01:00
Timm Baeder
7b88e7530d
[clang][bytecode][NFC] Make CheckVolatile static ( #113785 )
2024-10-27 05:06:47 +01:00
Timm Baeder
d5b42db00f
[clang][bytecode][NFC] Only do CheckConstant checks for global pointers ( #113786 )
...
We can check isStatic() early here and save ourselves some work.
2024-10-27 04:56:53 +01:00
Timm Baeder
46ad7ff4b7
[clang][bytecode] Diagnose non-const initialiers in diagnoseUnknownDecl ( #113276 )
...
This is more similar to the diagnostic output of the current interpreter
2024-10-23 05:50:30 +02:00
Timm Baeder
9ae41c24b3
[clang][bytecode] Create dummy pointers for non-reference DeclRefExprs ( #113202 )
...
... with non-constant initializers.
2024-10-22 10:38:13 +02:00
Timm Baeder
159f253017
[clang][bytecode] Diagnose invalid declrefs differently if we've... ( #113140 )
...
... tried their initializer already. In that case, diagnose the
non-const initializer instead of the reference to a non-constexpr
variable later. This is used in a lot of openmp tests.
2024-10-21 12:07:09 +02:00
Timm Baeder
923b8eea64
[clang][bytecode] Allow ArrayElemPtr ops on null pointers ( #113132 )
...
This regresses one of the _Complex test cases a bit, but since the
diagnostic output wasn't very good here in the first place, let's ignore
it.
2024-10-21 09:52:07 +02:00
Timm Baeder
615a5eb02c
[clang][bytecode] Check ai32_bextr builtins for integer args ( #113128 )
2024-10-21 08:15:51 +02:00
Timm Baeder
df8b785838
[clang][bytecode] Narrow pointer in UO_Deref unary operators ( #113089 )
...
Otherwise we treat this like an array element even though we should
treat it as a single object.
2024-10-21 07:51:49 +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
3eaf4a9d1a
[clang][bytecode] Check for memory leaks after destroying global scope ( #112868 )
...
The global scope we create when evaluating expressions might free some
of the dynamic memory allocations, so we can't check for memory leaks
before destroying it.
2024-10-18 13:03:13 +02:00
Timm Baeder
9d0616ce52
[clang][bytecode] Ignore explicit calls to trivial dtors ( #112841 )
...
This is what the current interpreter does as well.
2024-10-18 09:45:02 +02:00
Timm Baeder
5d08625347
[clang][bytecode] Activate pointers in Init{,Pop} ( #112832 )
2024-10-18 07:38:22 +02:00
Timm Baeder
03888a9046
[clang][bytecode] Handle non-arrays in initElem{,Pop} ( #112719 )
...
... provided the given index is 0. Skip the atIndex() in that case.
2024-10-17 19:07:47 +02:00
Timm Bäder
1251687448
[clang][bytecode][NFC] Remove a leftover dump call
2024-10-17 12:40:14 +02:00
Timm Baeder
5b4071c755
[clang][bytecode] Explicitly truncate in IntegralAP::from() ( #112683 )
...
Add Integral::toAPInt(), which truncates to the given BitWidth, similar
to the toAPSInt() we already have.
2024-10-17 12:26:44 +02:00
Nikita Popov
255a99c29f
[APInt] Fix APInt constructions where value does not fit bitwidth (NFCI) ( #80309 )
...
This fixes all the places that hit the new assertion added in
https://github.com/llvm/llvm-project/pull/106524 in tests. That is,
cases where the value passed to the APInt constructor is not an N-bit
signed/unsigned integer, where N is the bit width and signedness is
determined by the isSigned flag.
The fixes either set the correct value for isSigned, set the
implicitTrunc flag, or perform more calculations inside APInt.
Note that the assertion is currently still disabled by default, so this
patch is mostly NFC.
2024-10-17 08:48:08 +02:00
yronglin
8079a2c578
[clang][bytecode] Diagnose reference to non-constexpr variable of const type in C23 constexpr ( #112211 )
...
```cpp
const int V33 = 4;
const int V34 = 0;
const int V35 = 2;
constexpr int V36 = V33 / V34;
// expected-error@-1 {{constexpr variable 'V36' must be initialized by a constant expression}}
constexpr int V37 = V33 / V35;
// expected-error@-1 {{constexpr variable 'V37' must be initialized by a constant expression}}
```
---------
Signed-off-by: yronglin <yronglin777@gmail.com>
2024-10-16 00:11:12 +08:00
Timm Baeder
790d986946
[clang][bytecode] Implement __builtin_f{maximum,minimum}_num ( #112335 )
2024-10-15 12:49:32 +02:00
Timm Baeder
51d0e40c2e
[clang][bytecode] Fix __builtin_convertvector with float-cast ( #112238 )
...
Comparing their PrimTypes isn't enough in this case. We can have a
floating cast here as well.
2024-10-15 07:49:55 +02:00
Timm Baeder
4c78c8cc21
[clang][bytecode] Fix discarding block expressions ( #112185 )
2024-10-14 15:11:39 +02:00
Timm Baeder
80c15c48d1
[clang][bytecode] Implement __builtin_assume_aligned ( #111968 )
2024-10-11 11:46:33 +02:00
Timm Baeder
ff04bb8f40
[clang][bytecode] Use PredefinedExpr as base for its variable ( #111956 )
...
This fixes the error message generated.
2024-10-11 09:31:49 +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
36b0707767
[clang][bytecode] Return an lvalue path for dummy pointers ( #111862 )
...
Not doing this is wrong in general and we need to reject expressions
where it would matter differently.
2024-10-11 05:58:25 +02:00
Timm Baeder
55d51dd9dc
[clang][bytecode] Fix temporary lvalue base expression ( #111808 )
...
We need to use the MaterializeTemporaryExpr here so the checks in
ExprConstant.cpp do the right thing.
2024-10-10 14:10:38 +02:00