27 Commits

Author SHA1 Message Date
Timm Bäder
87461d6696 [clang][Interp] Implement __builtin_offsetof
Differential Revision: https://reviews.llvm.org/D156400
2023-09-11 12:03:47 +02:00
Timm Bäder
673ef8ceae Re-land "[clang][Interp] Make sure we push integers of the correct size"
This also re-reverts the commit implementing __builtin_strlen.

I was unable to reproduce the msan issue with an msan-enabled build (for
infrastructure reasons), but I think fixing the target-dependent int
sizes in the implementation of __builtin_fpclassify should work.
2023-08-18 10:25:54 +02:00
Vitaly Buka
e03686f4a3 Revert "[clang][Interp] Make sure we push integers of the correct size"
Revert "[clang][Interp] Implement __builtin_strlen"

Fails Msan. Details in https://reviews.llvm.org/D155568

This reverts commit d425720aed48fd2c058a126ac961576d48c9732b.
This reverts commit 91af0d0a669880918eda2d2bd2d6185b2903a402.
2023-08-17 18:12:02 -07:00
Timm Bäder
d425720aed [clang][Interp] Implement __builtin_strlen
Differential Revision: https://reviews.llvm.org/D156042
2023-08-17 13:10:46 +02:00
Timm Bäder
91af0d0a66 [clang][Interp] Make sure we push integers of the correct size
Integers might not be 32 bits wide, so check the TargetInfo for their
size.

Differential Revision: https://reviews.llvm.org/D155568
2023-08-17 10:36:06 +02:00
Timm Bäder
8a25145058 [clang][Interp] Pass CallExpr to builtin functions
For some builtins, we need to do quite a bit of type checking ourselves,
so pass the call expression along. This way we can inspect arguments,
expected return value, etc.

Differential Revision: https://reviews.llvm.org/D155545
2023-08-17 10:20:58 +02:00
Timm Bäder
89e44e33ed [clang][Interp] Implement __builtin_fmax
Differential Revision: https://reviews.llvm.org/D155401
2023-08-01 17:45:24 +02:00
Timm Bäder
1684406e63 [clang][Interp] Implement __builtin_fabs()
Differential Revision: https://reviews.llvm.org/D155400
2023-08-01 16:32:29 +02:00
Timm Bäder
5821351343 [clang][Interp] Implement __builtin_fpclassify
Differential Revision: https://reviews.llvm.org/D155394
2023-08-01 16:02:15 +02:00
Timm Bäder
6ba4b21334 [clang][Interp] Implement __builtin_isfpclass 2023-08-01 15:25:22 +02:00
Timm Bäder
d37f1e9965 [clang][Interp] Implement __builtin_isnormal
Differential Revision: https://reviews.llvm.org/D155374
2023-07-31 09:14:16 +02:00
Timm Bäder
f444f39686 [clang][Interp] Implement __builtin_isfinite
Differential Revision: https://reviews.llvm.org/D155372
2023-07-31 09:12:32 +02:00
Timm Bäder
72450a7793 [clang][Interp] Implement __builtin_isinf
Differential Revision: https://reviews.llvm.org/D155371
2023-07-31 08:49:22 +02:00
Timm Bäder
ff80fc0ea2 [clang][Interp] Implement __builtin_isnan()
The previous version was using llvm::reverse(CallExpr::arguments()),
which causes problems when clang is compiled with GCC.

Differential Revision: https://reviews.llvm.org/D155369
2023-07-29 10:48:10 +02:00
Timm Bäder
9016514c6b Revert "[clang][Interp] Implement __builtin_isnan()"
This reverts commit 8ad9dcb3869394e3a4ecb01631646237074723fe.

This breaks builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/46363/steps/6/logs/FAIL__Clang__constant-builtins-fmin_cpp

Revert while I figure out what's going wrong.
2023-07-28 20:59:38 +02:00
Timm Bäder
8ad9dcb386 [clang][Interp] Implement __builtin_isnan()
Differential Revision: https://reviews.llvm.org/D155369
2023-07-28 20:49:45 +02:00
Timm Bäder
c14c34de45 [clang][Interp] Implement __builtin_fmin
Differential Revision: https://reviews.llvm.org/D155546
2023-07-28 20:18:57 +02:00
Timm Bäder
57ca62d5d3 [clang][Interp] Implement __builtin_copysign
Differential Revision: https://reviews.llvm.org/D155368
2023-07-28 10:55:34 +02:00
Timm Bäder
b395e91f2e [clang][Interp] Implement __builtin_inf() etc.
Differential Revision: https://reviews.llvm.org/D155367
2023-07-28 10:50:13 +02:00
Timm Bäder
c2273e33bd [clang][Interp] Implement __builtin_nan family
Differential Revision: https://reviews.llvm.org/D155356
2023-07-28 10:28:55 +02:00
Timm Bäder
e9eb8362f0 [clang][Interp][NFC] Add an assertion 2023-07-26 11:50:07 +02:00
Timm Bäder
d913aa6971 [clang][Interp][NFC] Make a local function static 2023-07-26 11:50:07 +02:00
Timm Bäder
ae667f03d3 [clang][Interp][NFC] Take a const InterpFrame* in InterpBuiltin.cpp 2023-07-26 10:06:26 +02:00
Timm Bäder
8a4bbeb916 [clang][Interp] Remove args from called functions in more cases
When calling functions in the checkingPotentialConstantExpression mode,
we cannot have arguments (including This + RVO pointers) for the
toplevel callee, but the functions called from within can work just
fine, or at least we succeed in pushing their arguments on the stack, so
we must also succeed in removing them again.

Differential Revision: https://reviews.llvm.org/D150358
2023-07-26 08:47:54 +02:00
Timm Bäder
eaadbcd5e0 [clang][Interp] Implement __builtin_strcmp
Make our Function class keep a list of parameter offsets so we can
simply get a parameter by index when evaluating builtin functions.

Differential Revision: https://reviews.llvm.org/D149816
2023-07-20 15:46:04 +02:00
Timm Bäder
760136ff13 [clang][Interp] Implement __builtin_assume
Just ignore it.

As part of this, move the Ret and RetVoid implementation to Interp.h, so
they can be shared with InterpBuiltin.cpp.

Differential Revision: https://reviews.llvm.org/D141193
2023-01-27 07:54:37 +01:00
Timm Bäder
a7a4463acb [clang][Interp] Start implementing builtin functions
Differential Revision: https://reviews.llvm.org/D137487
2023-01-25 14:08:03 +01:00