aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Compiler.cpp
AgeCommit message (Collapse)AuthorFilesLines
3 days[clang][bytecode] Diagnose volatile writes (#160350)Timm Baeder1-6/+12
7 days[clang][bytecode] Remove bogus Initializing special case (#159933)Timm Baeder1-7/+2
This doesn't seem to be needed anymore and causes problems. Fixes #159787
8 days[clang][bytecode] Load value of non-lvalue ArraySubscriptExpr (#160024)Timm Baeder1-1/+6
As happens in C. Fixes #158482
11 days[clang][bytecode] Move generic lambda handling to Compiler (#159733)Timm Baeder1-1/+18
So the static invoker's Function still points to the static invoker instead of the call operator of the lambda record. This is important for a later commit.
2025-09-16[clang][bytecode] Improve error detection in BitCastPrim op (#158575)Timm Baeder1-1/+2
Reject bitcasts to pointer types unless it's to `nullptr_t` and always reject bitcasts to member pointer types. Fixes #156174
2025-09-16[clang][ExprConst] Reject unary vector shuffles (#158589)Timm Baeder1-0/+4
This is not implemented at compile time and asserts in assertion builds, so reject it here. Fixed the coding style in `BuiltinShuffleVector` at the same time. Fixes #158471
2025-09-16[clang][bytecode][NFC] Remove BlockScope (#158656)Timm Baeder1-5/+5
Unused these days.
2025-09-15[clang][bytecode] Pass initializer along in `evaluateAsInitializer()` (#158056)Timm Baeder1-11/+10
We just called `getInit()`, which isn't always correct and used the wrong initializer in the module test case.
2025-09-11[clang][bytecode] Implement C23 named loops (#156856)Timm Baeder1-56/+113
2025-09-11[clang][bytecode][NFC] Remove an else after a return (#157999)Timm Baeder1-11/+9
2025-09-08[clang][bytcode][NFC] Use UnsignedOrNone for global ids (#157328)Timm Baeder1-7/+8
2025-09-07[clang][bytecode][NFC] Remove some unnecessary if statements (#157329)Timm Baeder1-12/+4
We already checked that `IsStatic` is true above.
2025-09-05[clang][bytecode][NFC] Remove instance pointer from emitDestruction (#157040)Timm Baeder1-52/+32
We only call this when we just pushed a new pointer to the stack, so try to save the folling PopPtr op by removing the pointer inside emitDestruction directly, e.g. by letting the Call op just remove it.
2025-09-04[clang][bytecode] Create implicit variables for wider base types (#156658)Timm Baeder1-14/+27
If we create an implicit local variable for a derived-to-base cast, we still should allocate enough space for the entire derived type. Fixes #156219
2025-09-04[clang][bytecode] Remove superfluous check for complex types (#156666)Timm Baeder1-2/+1
`!E->getType()->isAnyComplexType()` is implied by `!canClassify()`.
2025-08-30[clang][bytecode] Fix ignoring comparisons in C (#156180)Timm Baeder1-1/+1
Our comparison ops always return bool, and we do the pop before the conversion to in in C. Fixes #156178
2025-08-27[clang][bytecode] Reject vectors with non-primitive element types (#155597)Timm Baeder1-4/+8
This happens for e.g. arm's float8 types.
2025-08-27[clang][bytecode] Reject dependent RequiresExprs (#155230)Timm Baeder1-0/+2
Fixes #152899
2025-08-27[clang][bytecode] Handle vector assignments (#155573)Timm Baeder1-1/+16
2025-08-27[clang] AST: fix getAs canonicalization of leaf types (#155028)Matheus Izvekov1-2/+2
2025-08-26[clang] NFC: introduce Type::getAsEnumDecl, and cast variants for all ↵Matheus Izvekov1-2/+1
TagDecls (#155463) And make use of those. These changes are split from prior PR #155028, in order to decrease the size of that PR and facilitate review.
2025-08-26[clang][bytecode] Error if calls have fewer arguments than parameters (#155151)Timm Baeder1-0/+6
Shouldn't happen, but does. Fixes #155147
2025-08-25[Clang] Fix Variable Length Array `_Countof` Crash (#154627)Vincent1-1/+3
Check for missing VLA size expressions (e.g. in int a[*][10]) before evaluation to avoid crashes in _Countof and constant expression checks. Fixes #152826
2025-08-25[clang][bytecode] Fix OptionScope initializer (#155149)Timm Baeder1-1/+1
Initialize the `OldToLValue` member with the actual old value of `ToLValue`. Pointed out by Shafik in https://github.com/llvm/llvm-project/pull/153601#discussion_r2294319428
2025-08-19[clang][bytecode][NFC] Replace std::optional<unsigned> with UnsignedO… ↵Timm Baeder1-33/+32
(#154286) …rNone
2025-08-19[clang][bytecode] Fix initializing float elements from #embed (#154285)Timm Baeder1-6/+20
Fixes #152885
2025-08-19[clang][bytecode] Create temporary before discarding CXXConstructExpr (#154280)Timm Baeder1-7/+7
Fixes #154110
2025-08-18[clang][bytecode] Always track item types in InterpStack (#151088)Timm Baeder1-10/+15
This has been a long-standing problem, but we didn't use to call the destructors of items on the stack unless we explicitly `pop()` or `discard()` them. When interpretation was interrupted midway-through (because something failed), we left `Pointer`s on the stack. Since all `Block`s track what `Pointer`s point to them (via a doubly-linked list in the `Pointer`), that meant we potentially leave deallocated pointers in that list. We used to work around this by removing the `Pointer` from the list before deallocating the block. However, we now want to track pointers to global blocks as well, which poses a problem since the blocks are never deallocated and thus those pointers are always left dangling. I've tried a few different approaches to fixing this but in the end I just gave up on the idea of never knowing what items are in the stack. We already have an `ItemTypes` vector that we use for debugging assertions. This patch simply enables this vector unconditionally and uses it in the abort case to properly `discard()` all elements from the stack. That's a little sad IMO but I don't know of another way of solving this problem. As expected, this is a slight hit to compile times: https://llvm-compile-time-tracker.com/compare.php?from=574d0a92060bf4808776b7a0239ffe91a092b15d&to=0317105f559093cfb909bfb01857a6b837991940&stat=instructions:u
2025-08-18[clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation ↵Timm Baeder1-11/+42
(#153601)
2025-08-17[clang][bytecode] Fix pseudo dtor calls on non-pointers (#153970)Timm Baeder1-1/+2
The isGLValue() check made us ignore expressions we shouldn't ignore.
2025-08-16[clang][bytecode] Prefer ParmVarDecls as function parameters (#153952)Timm Baeder1-14/+16
We might create a local temporary variable for a ParmVarDecl, in which case a DeclRefExpr for that ParmVarDecl should _still_ result in us choosing the parameter, not that local.
2025-08-10[clang][bytecode] Emit embed element casts directly (#152928)Timm Baeder1-8/+3
The element initializer is known to be an IntegerLiteral, the previous signature of the lambda just didn't specify that. So we can also do the cast directly instead of doing it via a Cast op.
2025-08-10[clang][bytecode] Use Param decl as variable source if we can (#152909)Timm Baeder1-20/+20
This results in diagnostics that are closer to what the current interpreter produces.
2025-08-09[clang][bytecode] Add AccessFlags to Block (#152590)Timm Baeder1-4/+0
This way, we can check a single uint8_t for != 0 to know whether this block is accessible or not. If not, we still need to figure out why not and diagnose appropriately of course.
2025-08-09[clang][bytecode] Add canClassify() helper (#152755)Timm Baeder1-7/+7
Sometimes we don't need the return value of a classsify() call, we only need to know if we can map the given Expr/Type to a primitive type. Add canClassify() for that.
2025-08-09[clang] Improve nested name specifier AST representation (#147835)Matheus Izvekov1-4/+5
This is a major change on how we represent nested name qualifications in the AST. * The nested name specifier itself and how it's stored is changed. The prefixes for types are handled within the type hierarchy, which makes canonicalization for them super cheap, no memory allocation required. Also translating a type into nested name specifier form becomes a no-op. An identifier is stored as a DependentNameType. The nested name specifier gains a lightweight handle class, to be used instead of passing around pointers, which is similar to what is implemented for TemplateName. There is still one free bit available, and this handle can be used within a PointerUnion and PointerIntPair, which should keep bit-packing aficionados happy. * The ElaboratedType node is removed, all type nodes in which it could previously apply to can now store the elaborated keyword and name qualifier, tail allocating when present. * TagTypes can now point to the exact declaration found when producing these, as opposed to the previous situation of there only existing one TagType per entity. This increases the amount of type sugar retained, and can have several applications, for example in tracking module ownership, and other tools which care about source file origins, such as IWYU. These TagTypes are lazily allocated, in order to limit the increase in AST size. This patch offers a great performance benefit. It greatly improves compilation time for [stdexec](https://github.com/NVIDIA/stdexec). For one datapoint, for `test_on2.cpp` in that project, which is the slowest compiling test, this patch improves `-c` compilation time by about 7.2%, with the `-fsyntax-only` improvement being at ~12%. This has great results on compile-time-tracker as well: ![image](https://github.com/user-attachments/assets/700dce98-2cab-4aa8-97d1-b038c0bee831) This patch also further enables other optimziations in the future, and will reduce the performance impact of template specialization resugaring when that lands. It has some other miscelaneous drive-by fixes. About the review: Yes the patch is huge, sorry about that. Part of the reason is that I started by the nested name specifier part, before the ElaboratedType part, but that had a huge performance downside, as ElaboratedType is a big performance hog. I didn't have the steam to go back and change the patch after the fact. There is also a lot of internal API changes, and it made sense to remove ElaboratedType in one go, versus removing it from one type at a time, as that would present much more churn to the users. Also, the nested name specifier having a different API avoids missing changes related to how prefixes work now, which could make existing code compile but not work. How to review: The important changes are all in `clang/include/clang/AST` and `clang/lib/AST`, with also important changes in `clang/lib/Sema/TreeTransform.h`. The rest and bulk of the changes are mostly consequences of the changes in API. PS: TagType::getDecl is renamed to `getOriginalDecl` in this patch, just for easier to rebasing. I plan to rename it back after this lands. Fixes #136624 Fixes https://github.com/llvm/llvm-project/issues/43179 Fixes https://github.com/llvm/llvm-project/issues/68670 Fixes https://github.com/llvm/llvm-project/issues/92757
2025-08-08[clang][bytecode][NFC] Remove a useless local variable (#152711)Timm Baeder1-5/+2
We can just check NonNullArgs.empty().
2025-08-06[clang][bytecode] Overrride locs for certain CXXConstructExprs (#152185)Timm Baeder1-8/+19
Do it only if we will end up skipping the initializer anyway because it's a trivial copy or move constructor.
2025-08-05[clang][bytecode] Disable location tracking for implicit field inits (#150190)Timm Baeder1-0/+38
2025-08-05[clang][bytecode][NFC] Only collect non-null args if we have to (#152074)Timm Baeder1-2/+7
Only do this if the function really has a NonNullArg.
2025-08-04[AST] Use llvm::iterator_range::empty (NFC) (#151904)Kazu Hirata1-1/+1
2025-08-04[clang][bytecode] Try to load primitive values directly (#151833)Timm Baeder1-4/+23
Instead of doing a GetPtrLocal + Load or GetPtrGlobal + Load pair, try to load the value directly.
2025-08-02[clang][bytecode] Fix D3DCOLORtoUBYTE4 hlsl test (#151819)Timm Baeder1-4/+11
HLSL is using CK_FloatingToIntegral casts to cast to vectors, which we don't support (neither does the current interpreter). Also fix a crash when trying to promote the HLSL bool, which can't be promoted it seems.
2025-07-31[clang][bytecode] Fix a crash in codegen (#151515)Timm Baeder1-0/+3
getRecord() can return nullptr if any one of the fields does, in this case because the array is too large for us to allocate.
2025-07-31[clang][bytecode][NFC] Remove LabelScope (#151498)Timm Baeder1-15/+6
It did almost nothing
2025-07-30[clang] Forbid reinterpret_cast of function pointers in constexpr. (#150557)Eli Friedman1-3/+7
This has been explicitly forbidden since C++11, but somehow the edge case of converting a function pointer to void* using a cast like `(void*)f` wasn't handled. Fixes #150340 .
2025-07-28[clang][bytecode][NFC] Fix a few clang-tidy complaints (#150940)Timm Baeder1-20/+23
2025-07-23[clang][bytecode] Activate primitive fields before initializing them (#149963)Timm Baeder1-39/+50
The initializer itself might need the field to be active.
2025-07-23[clang][bytecode] Only implicitly start lifetime of ↵Timm Baeder1-1/+8
trivially-default-constructible union members (#149835) See https://github.com/llvm/llvm-project/commit/faee39baa87e43f4b746dd77e479268391163658
2025-07-21[clang][bytecode] Use OptPrimType instead of std::optional<PrimType> (#149812)Timm Baeder1-60/+59
We use this construct a lot. Use something similar to clang's UnsignedOrNone. This results in some slighy compile time improvements: https://llvm-compile-time-tracker.com/compare.php?from=17a4b0399d161a3b89d8f0ce82add1638f23f5d4&to=a251d81ecd0ed45dd190462663155fdb303ef04d&stat=instructions:u