aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
AgeCommit message (Collapse)AuthorFilesLines
5 hours[clang][Expr] Teach IgnoreUnlessSpelledInSource about implicit calls to ↵Michael Buch1-1/+42
std::get free function (#122265) When we generate the debug-info for a `VarDecl` we try to determine whether it was introduced as part of a structure binding (aka a "holding var"). If it was then we don't mark it as `artificial`. The heuristic to determine a holding var uses `IgnoreUnlessSpelledInSource` to unwrap the `VarDecl` initializer until we hit a `DeclRefExpr` that refers to a `Decomposition`. For "tuple-like decompositions", Clang will generate a call to a `template<size_t I> Foo get(Bar)` function that retrieves the `Ith` element from the tuple-like structure. If that function is a member function, we get an AST that looks as follows: ``` VarDecl implicit used z1 'std::tuple_element<0, B>::type &&' cinit `-ExprWithCleanups <col:10> 'int' xvalue `-MaterializeTemporaryExpr <col:10> 'int' xvalue extended by Var 0x11d110cf8 'z1' 'std::tuple_element<0, B>::type &&' `-CXXMemberCallExpr <col:10> 'int' `-MemberExpr <col:10> '<bound member function type>' .get 0x11d104390 `-ImplicitCastExpr <col:10> 'B' xvalue <NoOp> `-DeclRefExpr <col:10> 'B' lvalue Decomposition 0x11d1100a8 '' 'B' ``` `IgnoreUnlessSpelledInSource` happily unwraps this down to the `DeclRefExpr`. However, when the `get` helper is a free function (which it is for `std::pair` in libc++ for example), then the AST is: ``` VarDecl col:16 implicit used k 'std::tuple_element<0, const std::tuple<int, int>>::type &' cinit `-CallExpr <col:16> 'const typename tuple_element<0UL, tuple<int, int>>::type':'const int' lvalue adl |-ImplicitCastExpr <col:16> 'const typename tuple_element<0UL, tuple<int, int>>::type &(*)(const tuple<int, int> &) noexcept' <FunctionToPointerDecay> | `-DeclRefExpr <col:16> 'const typename tuple_element<0UL, tuple<int, int>>::type &(const tuple<int, int> &) noexcept' lvalue Function 0x1210262d8 'get' 'const typename tuple_element<0UL, tuple<int, int>>::type &(const tuple<int, int> &) noexcept' (FunctionTemplate 0x11d068088 'get') `-DeclRefExpr <col:16> 'const std::tuple<int, int>' lvalue Decomposition 0x121021518 '' 'const std::tuple<int, int> &' ``` `IgnoreUnlessSpelledInSource` doesn't unwrap this `CallExpr`, so we incorrectly mark the binding as `artificial` in debug-info. This patch adjusts `IgnoreUnlessSpelledInSource` so it unwraps implicit `CallExpr`s. It's almost identical to how we treat implicit constructor calls (unfortunately the code can't quite be re-used because a `CXXConstructExpr` is-not a `CallExpr`, and we check `isElidable`, which doesn't exist for regular function calls. So I added a new `IgnoreImplicitCallSingleStep`). Fixes https://github.com/llvm/llvm-project/issues/122028
12 hours[CIR] Implement Type promotion for VectorType (#158715)Amr Hesham1-5/+4
This change adds support for type promotion for VectorType Issue https://github.com/llvm/llvm-project/issues/136487
13 hours[CIR] Add atomic exchange operation (#158089)Sirui Mu2-4/+41
This patch adds atomic exchange operation which covers the following C/C++ intrinsic functions: - `__c11_atomic_exchange` - `__atomic_exchange` - `__atomic_exchange_n`
13 hours[CIR][NFC] Fix Missing Decl::OMPGroupPrivate warning (#159631)Amr Hesham1-1/+1
Fix the Missing enum element `Decl::OMPGroupPrivate` warning
15 hours[Driver] [C++20] [Modules] Fix --precompile with -fmodule-outputChuanqi Xu1-6/+15
Close https://github.com/llvm/llvm-project/issues/159780
17 hours[clang-format][NFC] Add is_sorted() assertion for binary_search()Owen Pan2-0/+2
21 hours[clang][PAC] Don't try to diagnose use of pointer auth on dependent types ↵Oliver Hunt1-0/+3
#159505 (#159859) We can't give a correct answer for dependent types, so for now just report no ptrauth involves if the type being queried is dependent. In future we may want to distinguigh the `None` vs `Dependent` cases but that does not seem warranted for now. Fixes #159505
22 hours[modules] Fix assert on Clang module import from the global module fragment. ↵Naveen Seth Hanig1-1/+6
(#159771) Fixes #159768. When building a named module interface with `-fmodules` enabled, importing a Clang module from inside the global module fragment causes Clang to crash only on assertion builds. This fixes the assert and extends the test coverage.
25 hours[CIR] Fix structors for multidimensional arrrays (#159820)Morris Hafner3-10/+31
This patchs implements array constructors and destructors for multidimensional arrays. This works by bitcasting the pointer to the first element to a one-dimensional array type of the same extent before lowering to a loop.
26 hours[clang][analyzer] Load config through the proper VFS (#159164)Jan Svoboda1-2/+6
This PR ensures that the Clang static analyzer loads the config file through the properly-configured VFS rather than through the bare real file system. This enables correctly going through VFS overlays, unifying the behavior with the rest of the compiler.
27 hours[clang] diagnose invalid std::tuple_size sizes (#159677)Matheus Izvekov1-6/+19
This makes sure the tuple sizes remain within implementation limits, and this doesn't cause the compiler to crash later, as the tuple size is assumed to fit within an UnsignedOrNone. Fixes #159563
28 hours[CIR] Implement Logical AND for VectorType (#158696)Amr Hesham1-2/+14
This change adds support for local AND op for VectorType Issue https://github.com/llvm/llvm-project/issues/136487
28 hours[clang][Driver] Clean up UEFI linker argument handling (#159639)Roland McGrath1-11/+26
This makes the UEFI driver's handling of linking more canonical in a few ways: * Use /option:value syntax with lld-link as in the MSVC driver. * Handle -nostdlib, -nodefaultlibs, -r and call common subroutines when they aren't set. This covers sanitizer and profile runtimes and their associated switches; compiler-rt builds do not yet provide these libraries, but the driver behavior is opt-in and supports all the opt-in/out plumbing like other targets do. This lets command lines immediately use the opt-out switches even when they are superfluous for opt-in features, as build system plumbing often needs to do. It also updates some TODO comments for how the driver behavior will look when more runtime support is ready.
28 hours[clang] fix expression classification for dependent binary operators (#159819)Matheus Izvekov1-0/+7
This fixes a regression reported here: https://github.com/llvm/llvm-project/pull/159463#issuecomment-3312157416 Since this regression was never released, there are no release notes.
29 hours[HLSL] Add deprecation warnings to compatability overloads (#159208)Sarah Spall1-17/+101
Add deprecation warnings to compatability overloads and add tests to show the warnings. Closes #133452
29 hours[CIR] Upstream TypeInfo attribute (#159426)Amr Hesham2-4/+32
This change adds support for TypeInfoAttr which is needed later for RTTI in exceptions Issue https://github.com/llvm/llvm-project/issues/154992
30 hours[LifetimeSafety] Avoid adding already present items in sets/maps (#159582)Utkarsh Saxena1-4/+8
Optimize lifetime safety analysis performance - Added early return optimization in `join` function for ImmutableSet when sets are identical - Improved ImmutableMap join logic to avoid unnecessary operations when values are equal I was under the impression that ImmutableSets/Maps would not modify the underlying if already existing elements are added to the container (and was hoping for structural equality in this aspect). It looks like the current implementation of `ImmutableSet` would perform addition nevertheless thereby creating (presumably `O(log(N))` tree nodes. This change considerably brings down compile times for some edge cases which happened to be present in the LLVM codebase. Now it is actually possible to compile LLVM in under 20 min with the lifetime analysis. The compile time hit is still significant but not as bad as before this change where it was not possible to compile LLVM without severely limiting analysis' scope (giving up on CFG with > 3000 blocks). Fixes https://github.com/llvm/llvm-project/issues/157420 <details> <summary>Report (Before)</summary> </details> <details> <summary>Report (After)</summary> # Lifetime Analysis Performance Report > Generated on: 2025-09-18 14:28:00 --- ## Test Case: Pointer Cycle in Loop **Timing Results:** | N (Input Size) | Total Time | Analysis Time (%) | Fact Generator (%) | Loan Propagation (%) | Expired Loans (%) | |:---------------|-----------:|------------------:|-------------------:|---------------------:|------------------:| | 25 | 53.76 ms | 85.58% | 0.00% | 85.46% | 0.00% | | 50 | 605.35 ms | 98.39% | 0.00% | 98.37% | 0.00% | | 75 | 2.89 s | 99.62% | 0.00% | 99.61% | 0.00% | | 100 | 8.62 s | 99.80% | 0.00% | 99.80% | 0.00% | **Complexity Analysis:** | Analysis Phase | Complexity O(n<sup>k</sup>) | |:------------------|:--------------------------| | Total Analysis | O(n<sup>3.82</sup> &pm; 0.01) | | FactGenerator | (Negligible) | | LoanPropagation | O(n<sup>3.82</sup> &pm; 0.01) | | ExpiredLoans | (Negligible) | --- ## Test Case: CFG Merges **Timing Results:** | N (Input Size) | Total Time | Analysis Time (%) | Fact Generator (%) | Loan Propagation (%) | Expired Loans (%) | |:---------------|-----------:|------------------:|-------------------:|---------------------:|------------------:| | 400 | 66.02 ms | 58.61% | 1.04% | 56.53% | 1.02% | | 1000 | 319.24 ms | 81.31% | 0.63% | 80.04% | 0.64% | | 2000 | 1.43 s | 92.00% | 0.40% | 91.32% | 0.28% | | 5000 | 9.35 s | 97.01% | 0.25% | 96.63% | 0.12% | **Complexity Analysis:** | Analysis Phase | Complexity O(n<sup>k</sup>) | |:------------------|:--------------------------| | Total Analysis | O(n<sup>2.12</sup> &pm; 0.02) | | FactGenerator | O(n<sup>1.54</sup> &pm; 0.02) | | LoanPropagation | O(n<sup>2.12</sup> &pm; 0.03) | | ExpiredLoans | O(n<sup>1.13</sup> &pm; 0.03) | --- ## Test Case: Deeply Nested Loops **Timing Results:** | N (Input Size) | Total Time | Analysis Time (%) | Fact Generator (%) | Loan Propagation (%) | Expired Loans (%) | |:---------------|-----------:|------------------:|-------------------:|---------------------:|------------------:| | 50 | 137.30 ms | 90.72% | 0.00% | 90.42% | 0.00% | | 100 | 1.09 s | 98.13% | 0.00% | 98.02% | 0.09% | | 150 | 4.06 s | 99.24% | 0.00% | 99.18% | 0.05% | | 200 | 10.44 s | 99.66% | 0.00% | 99.63% | 0.03% | **Complexity Analysis:** | Analysis Phase | Complexity O(n<sup>k</sup>) | |:------------------|:--------------------------| | Total Analysis | O(n<sup>3.29</sup> &pm; 0.01) | | FactGenerator | (Negligible) | | LoanPropagation | O(n<sup>3.29</sup> &pm; 0.01) | | ExpiredLoans | O(n<sup>1.42</sup> &pm; 0.19) | --- </details>
33 hours[Clang][AST] Fix printing for `atomic_test_and_set` and `atomic_clear` (#159712)Devajith1-5/+1
https://github.com/llvm/llvm-project/pull/121943 rewrote `__atomic_test_and_set` and `__atomic_clear` to be lowered through AtomicExpr StmtPrinter::VisitAtomicExpr still treated them like other atomic builtins with a Val1 operand. This led to incorrect pretty-printing when dumping the AST. Skip Val1 for these two builtins like atomic loads.
34 hours[clang][bytecode] Typecheck called function pointers more thorougly (#159757)Timm Baeder2-5/+10
Fix two older FIXME items from the `functions.cpp` test.
34 hours[Clang] Rename elementwise builtins to `clzg` and `ctzg` (#157128)Joseph Huber6-29/+29
Summary: The added bit counting builtins for vectors used `cttz` and `ctlz`, which is consistent with the LLVM naming convention. However, these are clang builtins and implement exactly the `__builtin_ctzg` and `__builtin_clzg` behavior. It is confusing to people familiar with other other builtins that these are the only bit counting intrinsics named differently. This includes the additional operation for the undefined zero case, which was added as a `clzg` extension.
35 hours[WebKit checkers] fix a typo in a message in one of the checkers (#159593)Claudio Saavedra1-1/+1
36 hours[clang][bytecode] Move generic lambda handling to Compiler (#159733)Timm Baeder2-18/+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.
37 hoursRISC-V: builtins support for MIPS RV64 P8700 execution control .UmeshKalappa2-0/+35
the following changes are made a)Typo Fix (with previous PRhttps://github.com/llvm/llvm-project/pull/155747) b)builtins support for MIPS P8700 execution control instructions . c)Testcase
37 hours[Clang][NFC] Remove duplicated specialization of ↵Corentin Jabot2-48/+0
`llvm::DenseMapInfo<llvm::FoldingSetNodeID>` (#159718) In preparation of #141776
41 hours[Clang][CIR] fix enumeration value 'OMPGroupPrivate' not handled in switch ↵Maksim Levental1-1/+2
(#159694)
42 hours[WebKit checkers] Add the support for OSObjectPtr (#159484)Ryosuke Niwa9-35/+41
Add the support for OSObjectPtr, which behaves like RetainPtr.
43 hours[C++20][Modules] Fix merging of anonymous members of class templates. (#155948)Michael Park2-1/+17
46 hours[webkit.UncountedLambdaCapturesChecker] Treat arguments of ↵Ryosuke Niwa1-27/+37
std::ranges::all_of as [[clang::noescape]] (#158419) The checker already had std::ranges hard-coded to treat its arguments as [[clang::oescape]] but the fact std::ranges::all_of is implemented as a struct instead of a function confused the checker and resuled in a superflous warning being emitted for std::ranges::all_of. This PR adds the support for recognizing DeclRefExpr which appears as a callee in VisitCallExpr and generalizes the check in shouldTreatAllArgAsNoEscape to walk up the decl contexts to find the target namespaces such as std::ranges:: or a namespace and a function like WTF::switchOn.
48 hours[clang][Dependency Scanning] Canonicalize Defines of a Compiler Invocation ↵Qiongsi Wu1-2/+6
As Early As Possible (#159620) Before this patch, we only perform `-D` canonicalization on the deep copy of the `CompilerInvocation` instance, since the canonicalization should have no impact on scanning. However, in the presence of CAS, the content of the `builtin` macros are included in the context hash. This patch makes sure that we canonicalize the scanning `CompilerInvocation`'s `-D`s. Part of work for rdar://136303612. --------- Co-authored-by: Jan Svoboda <jan@svoboda.ai>
2 days[PowerPC] fix float ABI selection on ppcle (#154773)DanilaZhebryakov1-1/+2
soft float ABI selection was not taking effect on little-endian powerPC with embedded vectors (e.g. e500v2) leading to errors. (embedded vectors use "extended" GPRs to store floating-point values, and this caused issues with variadic arguments assuming dedicated floating-point registers with hard-float ABI)
2 days[llvm][clang] Pass VFS to `llvm::cl` command line handling (#159174)Jan Svoboda2-6/+10
This PR passes the VFS down to `llvm::cl` functions so that they don't assume the real file system.
2 days[HLSL] Make sure global resources and resource arrays cannot be assigned to ↵Helena Kotas2-0/+34
(#157772) Global resources are read-only. The compiler needs to report an error when somebody attempts to assign a value to a global resource, a global resource array element or the whole array. Test update in `static-local-ctor.hlsl` includes the use of the llvm-cxxfilt tool which takes care of demangling of function names for a more readable test baseline. Closes #154390
2 days[clang] check constant template parameters in dependent contexts (#159463)Matheus Izvekov1-3/+2
This patch makes sure constant template parameters are checked even in dependent contexts. This can for example diagnose narrowings earlier, but this is permitted as these templates would have no valid instantiations.
2 days[CIR] Implement Logical OR for VectorType (#158668)Amr Hesham1-3/+15
This change adds support for local OR op for VectorType Issue #136487
2 days[clang] Pass VFS into `ASTUnit::LoadFromASTFile()` (#159166)Jan Svoboda4-9/+12
This PR makes the `VFS` parameter to `ASTUnit::LoadFromASTFile()` required and explicit, rather than silently defaulting to the real file system. This makes it easy to correctly propagate the fully-configured VFS and load any input files like the rest of the compiler does.
2 days[clang] Only set non-empty bypass to scan VFS (#159605)Jan Svoboda1-5/+6
Normalizing an empty modules cache path results in an incorrect non-empty path (the working directory). This PR conditionalizes more code to avoid this. Tested downstream by swift/llvm-project and the `DependencyScanningCAPITests.DependencyScanningFSCacheOutOfDate` unit test.
2 days[CIR] Support type promotion for Scalar unary plus & minus ops (#158486)Amr Hesham1-13/+32
Support type promotion for Scalar unary plus & minus ops
2 days[CIR] Support type promotion for Scalar unary real & imag ops (#158473)Amr Hesham1-27/+41
This change adds support for type promotion in Scalar unary real & imag ops Issue: https://github.com/llvm/llvm-project/issues/141365
2 days[CIR] Implement OpaqueValueExpr for Complex in C (#158423)Amr Hesham2-5/+3
This change adds support for the OpaqueValueExpr for Complex in C Issue: https://github.com/llvm/llvm-project/issues/141365
2 days[Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow ↵Aditya Chaudhari2-0/+105
AVX/AVX512 subvector insertion intrinsics to be used in constexpr #157709 (#158778) AVX/AVX512 vector insert intrinsics now support constexpr evaluation in both the AST evaluator and bytecode interpreter paths. FIXES: #157709
2 days[flang][Driver] Enables lto-partitions and fat-lto-object. (#158125)Anchu Rajendran S2-12/+28
2 days[CIR][NFC] Use TableGen to generate LLVM lowering patterns (#159390)Sirui Mu2-875/+7
Most lowering patterns have exactly the same class declaration with different names and different `matchAndRewrite` implementations, yet their declaration occupies near 1000 lines of code in `LowerToLLVM.h`, making this file difficult to read and boring to maintain. In this patch, I migrate their declarations to be generated from `CIROps.td` using `clang-tblgen`. Some extra `CIR_Op` TableGen fields are introduced to help this: - The `CIR_Op` class now defines a `bit` field `hasLLVMLowering` which defaults to `true`. If its value is `true`, `clang-tblgen` would generate an LLVM lowering pattern declaration for the operation. - Some LLVM lowering patterns has bounded recursion. This could be enabled by setting the `isLLVMLoweringRecursive` field in a `CIR_Op` record to `true`. - Some LLVM lowering patterns have defined additional class members. They could be listed in the `extraLLVMLoweringPatternDecl` field. Note that in the incubator we have a similar TableGen code generator that generates LLVM lowering code for CIR builtin ops which has a one-to-one correspondence to LLVM dialect operations. This patch does NOT try to upstream it. Some additional noticeable changes made by this patch: - This patch adds the `dataLayout` member to every LLVM lowering pattern class to make the job easier for a code generator. In the future we might want to add more members to the lowering patterns, and we will need to update the code generator to make such changes.
2 days[clang][bytecode] Optimize InterpStack (#159400)Timm Baeder2-33/+43
Replace `StackChunk::End` with `StackChunk::Size`, mark the allocating code paths as unlikely and move `grow()` into the header, which allows us to template this for the `Size` parameter. Since we only push our primitive types on the stack and all the sizes are aligned to pointer size multiples, this only results in a few instantiations.
2 days[Driver][AMDGPU][HIP][SPIRV] Disable optimizations for AMDGCN SPIR-V (#154765)Alex Voicu2-0/+20
SPIR-V specific optimizations can inadvertently remove information that is important for the AMDGPU BE / break certain code patterns we rely on. Therefore, for AMDGCN flavoured SPIR-V we disable optimizations over IR, to ensure that we operate directly on the output of Clang CodeGen when we finalise.
2 days[Headers][X86] Add constexpr support for some AVX512 int to f16 intrinsics. ↵sskzakaria1-9/+9
(#159231) Added constexpr to the remaining intrinsics: _mm256_cvtepu16_ph _mm256_mask_cvtepu16_ph _mm256_maskz_cvtepu16_ph _mm256_cvtepi32_ph _mm256_mask_cvtepi32_ph _mm256_maskz_cvtepi32_ph _mm256_cvtepu32_ph _mm256_mask_cvtepu32_ph _mm256_maskz_cvtepu32_ph Last part fixing #155798
2 days[clang][bytecode] Pass `SourceInfo` objects by value (#159532)Timm Baeder4-11/+11
They are only pointer-sized and copying them is cheaper than taking the const ref.
2 days [Headers][X86] Add constexpr support for some AVX512 masked ↵moorabbit3-81/+56
extension/truncation intrinsics. (#158663) The following AVX[512] intrinsics are now constexpr: - `_mm512_mask_cvtepi8_epi32` - `_mm512_maskz_cvtepi8_epi32` - `_mm512_mask_cvtepi8_epi64` - `_mm512_maskz_cvtepi8_epi64` - ` _mm512_mask_cvtepi16_epi32` - ` _mm512_maskz_cvtepi16_epi32` - ` _mm512_mask_cvtepi16_epi64` - ` _mm512_maskz_cvtepi16_epi64` - ` _mm512_mask_cvtepi32_epi64` - ` _mm512_maskz_cvtepi32_epi64` - ` _mm512_mask_cvtepu8_epi32` - ` _mm512_maskz_cvtepu8_epi32` - ` _mm512_mask_cvtepu8_epi64` - ` _mm512_maskz_cvtepu8_epi64` - ` _mm512_mask_cvtepu16_epi32` - ` _mm512_maskz_cvtepu16_epi32` - `_mm512_mask_cvtepu16_epi64` - `_mm512_maskz_cvtepu16_epi64` - `_mm512_mask_cvtepu32_epi64` - `_mm512_maskz_cvtepu32_epi64` - `_mm512_mask_cvtepi8_epi16` - `_mm512_maskz_cvtepi8_epi16` - `_mm512_mask_cvtepu8_epi16` - `_mm512_maskz_cvtepu8_epi16` - `_mm_cvtepi16_epi8` - `_mm256_cvtepi16_epi8` - `_mm256_mask_cvtepi16_epi8` - `_mm256_maskz_cvtepi16_epi8` This PR is part 1 of a series of PRs fixing [#154539](https://github.com/llvm/llvm-project/issues/154539)
3 days[clang] [OpenMP] New OpenMP 6.0 - Parsing and Sema support for groupprivate ↵Ritanya-B-Bharadwaj9-15/+200
(#158134)
3 days[clang] Remove Diag parameter from Expr::EvaluateKnownConstInt (#159512)Timm Baeder1-3/+1
If it's truly a known const int, it won't emit any diagnostics anyway. And if it did, we wouldn't notice because no call site passed something non-null.
3 days[OpenMP 5.2] New syntax for 'uses_allocators' clause (#157025)Urvi Rav2-4/+81
This patch updates the parsing changes to handle the new syntax of the `uses_allocators` clause as defined in OpenMP 5.2(Section 6.8). ``` // Case 1: Allocator without traits // < 5.2 → error // ≥ 5.2 → OK, empty traits set #pragma omp target teams uses_allocators(cgroup_alloc) // Case 2: Allocator with traits // Old syntax (< 5.2): #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits)) // New syntax (≥ 5.2): #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc) // Case 3: Multiple allocators // Old syntax (< 5.2), comma-separated: #pragma omp target teams uses_allocators(cgroup_alloc(cgroup_traits), aligned_alloc(aligned_traits)) // New syntax (≥ 5.2), semicolon-separated: #pragma omp target teams uses_allocators(traits(cgroup_traits) : cgroup_alloc; traits(aligned_traits) : aligned_alloc) ``` --------- Co-authored-by: urvi-rav <urvi.rav@hpe.com>