summaryrefslogtreecommitdiff
path: root/clang/lib/AST/ByteCode/Program.cpp
AgeCommit message (Collapse)Author
2025-11-07[clang][bytecode] Dummy variables can have pointers to them (#166908)Timm Baeder
at the point when they become proper globals.
2025-11-05[clang][bytecode] Check types when loading values (#165385)Timm Baeder
We need to allow BitCasts between pointer types to different prim types, but that means we need to catch the problem at a later stage, i.e. when loading the values. Fixes https://github.com/llvm/llvm-project/issues/158527 Fixes https://github.com/llvm/llvm-project/issues/163778
2025-11-05[clang][bytecode] Remove dummy variables once they are proper globals (#166174)Timm Baeder
Dummy variables have an entry in `Program::Globals`, but they are not added to `GlobalIndices`. When registering redeclarations, we used to only patch up the global indices, but that left the dummy variables alone. Update the dummy variables of all redeclarations as well. Fixes https://github.com/llvm/llvm-project/issues/165952
2025-10-20[clang][bytecode] Fix a crash when redeclaring extern globals (#164204)Timm Baeder
One iteration of this loop might've already fixed up the pointers of coming globals, so check for that explicitly. Fixes https://github.com/llvm/llvm-project/issues/164151
2025-10-17[clang][bytecode] Add Block::movePointersTo (#163795)Timm Baeder
which moves all the block's pointers to a new block.
2025-09-08[clang][bytcode][NFC] Use UnsignedOrNone for global ids (#157328)Timm Baeder
2025-08-26[clang] NFC: introduce Type::getAsEnumDecl, and cast variants for all ↵Matheus Izvekov
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][NFC] Use Pointer::initializeAllElements() in Program (#155391)Timm Baeder
We just initialized the entire string, so use this function instead.
2025-08-25[clang] NFC: change more places to use Type::getAsTagDecl and friends (#155313)Matheus Izvekov
This changes a bunch of places which use getAs<TagType>, including derived types, just to obtain the tag definition. This is preparation for #155028, offloading all the changes that PR used to introduce which don't depend on any new helpers.
2025-08-20[clang][bytecode][NFC] Use an anonymous union in Pointer (#154405)Timm Baeder
So we can save ourselves writing PointeeStorage all the time.
2025-08-19[clang][bytecode] Move pointers from extern globals to new decls (#154273)Timm Baeder
2025-08-18[clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation ↵Timm Baeder
(#153601)
2025-08-09[clang][bytecode] Add AccessFlags to Block (#152590)Timm Baeder
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] Improve nested name specifier AST representation (#147835)Matheus Izvekov
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-03[clang][bytecode] Remove unused includes (#151848)Timm Baeder
UnsignedOrNone.h from PrimType.h and ASTLambda.h from Function.h.
2025-07-28[clang][bytecode][NFC] Fix a few clang-tidy complaints (#150940)Timm Baeder
2025-07-21[clang][bytecode] Use OptPrimType instead of std::optional<PrimType> (#149812)Timm Baeder
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
2025-07-20[clang][bytecode] Reintroduce Pointer::elem() (#149693)Timm Baeder
As a way of writing atIndex(I).deref<T>(), which creates an intermediate Pointer, which in turn adds (and removes) that pointer from the pointer list of the Block. This way we can avoid that.
2025-05-21[clang][bytecode] Initialize global strings via memcpy (#140789)Timm Baeder
If we know the char width is 1, we can just copy the data over instead of going through the Pointer API.
2025-04-25[clang][bytecode] Propagate IsVolatile bit to subobjects (#137293)Timm Baeder
For ```c++ struct S { constexpr S(int=0) : i(1) {} int i; }; constexpr volatile S vs; ``` reading from `vs.i` is not allowed, even though `i` is not volatile qualified. Propagate the IsVolatile bit down the hierarchy, so we know reading from `vs.i` is a volatile read.
2025-04-25[clang][bytecode] Don't diagnose const extern reads in CPCE mode (#137285)Timm Baeder
They might become constexpr later.
2025-04-16[clang][bytecode] Explicitly mark constexpr-unknown variables as such (#135806)Timm Baeder
Instead of trying to figure out what's constexpr-unknown later on.
2025-03-22[clang][bytecode] Fix __builtin_memmove type diagnostics (#132544)Timm Baeder
Set the source type when allocating primitives so we can later retrieve it.
2025-03-20[ByteCode] Avoid repeated hash lookups (NFC) (#132141)Kazu Hirata
2025-03-04[clang][bytecode] Don't error out on incomplete declarations (#129685)Timm Baeder
Later operations on these are invalid, but the declaration is fine, if extern.
2025-03-02[clang][bytecode] Explicit composite array descriptor types (#129376)Timm Baeder
When creating descriptor for array element types, we only save the original source, e.g. int[2][2][2]. So later calls to getType() of the element descriptors will also return int[2][2][2], instead of e.g. int[2][2] for the second dimension. Fix this by explicitly tracking the array types. The last attached test case used to have an lvalue offset of 32 instead of 24. We should do this for more desriptor types though and not just composite array, but I'm leaving that to a later patch.
2025-02-16[clang][bytecode] Fix dynamic array allocation return values (#127387)Timm Baeder
We need to return a pointer to the first element, not the array itself.
2025-02-08[ByteCode] Avoid repeated hash lookups (NFC) (#126379)Kazu Hirata
2025-02-03[clang][bytecode] Refactor Program::createGlobalString (#125467)Timm Baeder
Remove unnecesary narrow() calls, rename a variable and initialize the array as a whole instead of each element individually.
2025-01-29[clang][bytecode] Handle non-primitive vector element types (#124926)Timm Baeder
By rejecting them. We would crash before.
2025-01-18[ByteCode] Migrate away from PointerUnion::dyn_cast (NFC) (#123445)Kazu Hirata
Note that PointerUnion::dyn_cast has 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> Literal migration would result in dyn_cast_if_present (see the definition of PointerUnion::dyn_cast), but this patch uses dyn_cast because we expect D to be nonnull.
2024-11-24[AST] Migrate away from PointerUnion::{is,get} (NFC) (#117469)Kazu Hirata
Note that PointerUnion::{is,get} 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> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
2024-11-17[AST] Remove unused includes (NFC) (#116549)Kazu Hirata
Identified with misc-include-cleaner.
2024-10-31[clang][bytecode][NFC] Use const auto* for Type cast result (#114405)Timm Baeder
2024-10-22[clang][bytecode] Create dummy pointers for non-reference DeclRefExprs (#113202)Timm Baeder
... with non-constant initializers.
2024-10-11[clang][bytecode] Use PredefinedExpr as base for its variable (#111956)Timm Baeder
This fixes the error message generated.
2024-10-06[ByteCode] Avoid repeated hash lookups (NFC) (#111273)Kazu Hirata
2024-10-05[clang][bytecode] Save a per-Block IsWeak bit (#111248)Timm Baeder
Checking the decl for every load is rather expensive.
2024-09-17[clang][bytecode] Fix defining extern variables (#108940)Timm Baeder
At the point of defintion of the variable, a function might already refert to the variable by its index. Replace the index with the new one.
2024-09-12[clang][bytecode] Add support for creating dummies for expressions (#108394)Timm Baeder
And use that to fix VisitObjCBoxedExprs.
2024-08-19[clang][bytecode] Use first FieldDecl instead of asserting (#104760)Timm Baeder
This assertion fails sometimes. We use the first decl for lookup later, so let's use the first decl here as well.
2024-08-16[clang] Rename all AST/Interp stuff to AST/ByteCode (#104552)Timm Baeder
"Interp" clashes with the clang interpreter and people often confuse this.