34 Commits

Author SHA1 Message Date
Timm Bäder
18461dc454 [clang][Interp] Add IntegralAP for arbitrary-precision integers (#65844) 2023-10-01 07:11:07 +02:00
Timm Bäder
4bae636abf Revert "[clang][Interp] Add IntegralAP for arbitrary-precision integers (#65844)"
This reverts commit 16b9e6fbac4c0bd94c66e7670a41b5c266cf7bff.

This breaks buildbots.
2023-09-30 20:12:14 +02:00
Timm Baeder
16b9e6fbac
[clang][Interp] Add IntegralAP for arbitrary-precision integers (#65844)
This adds `IntegralAP` backing the two new primtypes `IntAP` (unsigned
arbitrary-precision int) and `IntAPS` (same but signed).

We use this for `int128` support (which isn't available on all host
systems we support AFAIK) and I think we can also use this for `_BitInt`
later.
2023-09-30 20:08:22 +02:00
Timm Bäder
6d79f985b5 [clang][Interp] Implement zero-init of record types
Differential Revision: https://reviews.llvm.org/D154189
2023-09-05 11:20:35 +02:00
Timm Bäder
39236e9c60 [clang][Interp] Fix lifetime diagnostics for dead records
This used to crash the interpreter, either because we ran into the
assertion in CheckMutable() or because we accessed a Descriptor* pointer
preceding the field of a record. Those are preceded by an
InlineDescriptor though.

Differential Revision: https://reviews.llvm.org/D152132
2023-08-20 11:38:29 +02:00
Timm Bäder
1740cf3453 [clang][Interp][NFC] Use std::byte to refer to Block data 2023-08-17 13:04:05 +02:00
Timm Bäder
af67614f79 [clang][Interp] Call dtor of Floating values
The APFloat might heap-allocate some memory, so we need to call its
destructor.

Differential Revision: https://reviews.llvm.org/D154928
2023-07-20 15:27:16 +02:00
Timm Bäder
976d8b40cc [clang][Interp] Virtual function calls
Add a CallVirt opcode and implement virtual function calls this way.

Differential Revision: https://reviews.llvm.org/D142630
2023-06-15 13:33:43 +02:00
Timm Bäder
e69448b1ea [clang][Interp][NFC] Make Src parameter for move functions const 2023-06-05 13:20:18 +02:00
Timm Bäder
3ad167329a [clang][Interp] Implement function pointers
Differential Revision: https://reviews.llvm.org/D141472
2023-03-30 15:37:49 +02:00
Timm Bäder
0041f08196 [clang][Interp][NFC] Take a const Descriptor* in dtor,move,ctorFns
We are not mutating the descriptors here.
2023-03-09 16:08:59 +01:00
Timm Bäder
cb7f582211 Re-apply "[clang][Interp] Support floating-point values"
Don't move the Repr struct into Integral this time.

Differential Revision: https://reviews.llvm.org/D134859
2023-01-25 15:13:09 +01:00
Timm Bäder
b3b1d86137 Revert "[clang][Interp] Support floating-point values"
This reverts commit 62f43c3eae2460d4ca3da7897fd2d7c56920638c.

This breaks a couple of builders, e.g.

https://lab.llvm.org/buildbot/#/builders/139/builds/34925
2023-01-25 14:48:39 +01:00
Timm Bäder
62f43c3eae [clang][Interp] Support floating-point values
Add a new Floating type and a few new opcodes to support floating point
values.

Differential Revision: https://reviews.llvm.org/D134859
2023-01-25 14:41:26 +01:00
Timm Bäder
d54ae905d1 [clang][Interp][NFC] Rename InlineDescptor::IsMutable to IsFieldMutable 2023-01-23 10:32:51 +01:00
Timm Bäder
8e7c1b9a3d [clang][Interp][NFCI] Make InitMap::isInitialized() const 2023-01-22 08:33:40 +01:00
Timm Bäder
b07399f0fa [clang][Interp][NFC] Forward-declare Boolean in PrimTypes.h
We don't need the full header file here.
2023-01-22 08:33:39 +01:00
Timm Bäder
6b0cd497b0 [clang][Interp] Check Field initialization after constructor call
Differential Revision: https://reviews.llvm.org/D136694
2023-01-19 09:42:22 +01:00
Timm Bäder
865094746e [clang][Interp] Track initialization state of local variables
Use an InlineDescriptor per local variable to track whether locals
have been initialized or not. This way we can support uninitialized
local variables in constexpr functions.

Differential Revision: https://reviews.llvm.org/D135750
2023-01-18 16:55:02 +01:00
Aaron Ballman
37f80101a9 Silence a "not all control paths return" MSVC warning; NFC 2022-11-03 10:27:16 -04:00
Timm Bäder
ee9bbfa5e6 [clang][Interp] Make sure we free() allocated InitMaps
They get allocated when calling initialize() on a primitive array. And
they get free'd when the array is fully initialized. However, when that
never happens, they get leaked. Fix that by calling the destructor of
global variables.

Differential Revision: https://reviews.llvm.org/D136826
2022-10-28 17:00:15 +02:00
Fangrui Song
2f23dc9127 [AST/Interp] Fix left shift overflow bug in D64146
Noticed by Dmitri Gribenko
2022-09-08 13:49:07 -07:00
Fangrui Song
49c289879c [AST/Interp] Fix latent unitialized use of memory bug in D64146
Exposed by D132727: clang/test/AST/Interp/arrays.cpp fails with --config=msan
2022-09-08 13:39:30 -07:00
Nandor Licker
950b70dcc7 [Clang Interpreter] Initial patch for the constexpr interpreter
Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64146

llvm-svn: 371834
2019-09-13 09:46:16 +00:00
Roman Lebedev
2c9f83cfab Revert "[Clang Interpreter] Initial patch for the constexpr interpreter"
Breaks BUILD_SHARED_LIBS build, introduces cycles in library dependency
graphs. (clangInterp depends on clangAST which depends on clangInterp)

This reverts r370839, which is an yet another recommit of D64146.

llvm-svn: 370874
2019-09-04 10:57:06 +00:00
Nandor Licker
32f82c9cba [Clang Interpreter] Initial patch for the constexpr interpreter
Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64146

llvm-svn: 370839
2019-09-04 05:49:41 +00:00
Nandor Licker
c3bdad8c1e Revert [Clang Interpreter] Initial patch for the constexpr interpreter
This reverts r370636 (git commit 8327fed9475a14c3376b4860c75370c730e08f33)

llvm-svn: 370642
2019-09-02 11:34:47 +00:00
Nandor Licker
8327fed947 [Clang Interpreter] Initial patch for the constexpr interpreter
Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64146

llvm-svn: 370636
2019-09-02 10:38:08 +00:00
Nandor Licker
a6bef738bf Revert [Clang Interpreter] Initial patch for the constexpr interpreter
This reverts r370584 (git commit afcb3de117265a69d21e5673356e925a454d7d02)

llvm-svn: 370588
2019-08-31 15:15:39 +00:00
Nandor Licker
afcb3de117 [Clang Interpreter] Initial patch for the constexpr interpreter
Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64146

llvm-svn: 370584
2019-08-31 15:00:38 +00:00
Nandor Licker
0300c3536a Revert [Clang Interpreter] Initial patch for the constexpr interpreter
This reverts r370531 (git commit d4c1002e0bbbbab50f6891cdd2f5bd3a8f3a3584)

llvm-svn: 370535
2019-08-30 21:32:00 +00:00
Nandor Licker
d4c1002e0b [Clang Interpreter] Initial patch for the constexpr interpreter
Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64146

llvm-svn: 370531
2019-08-30 21:17:03 +00:00
Nandor Licker
5c8b94a672 Revert [Clang Interpreter] Initial patch for the constexpr interpreter
This reverts r370476 (git commit a5590950549719d0d9ea69ed164b0c8c0f4e02e6)

llvm-svn: 370481
2019-08-30 15:41:45 +00:00
Nandor Licker
a559095054 [Clang Interpreter] Initial patch for the constexpr interpreter
Summary:
This patch introduces the skeleton of the constexpr interpreter,
capable of evaluating a simple constexpr functions consisting of
if statements. The interpreter is described in more detail in the
RFC. Further patches will add more features.

Reviewers: Bigcheese, jfb, rsmith

Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64146

llvm-svn: 370476
2019-08-30 15:02:09 +00:00