59714 Commits

Author SHA1 Message Date
int-zjt
f4cf610159
[Coverage] Add gap region between binary operator '&& and ||' and RHS (#149085)
## Issue Summary
We identified an inaccuracy in line coverage reporting when short-circuit evaluation occurs in multi-line conditional expressions.

Specifically:
1. Un-executed conditions following line breaks may be incorrectly marked as covered
(e.g., conditionB in a non-executed && chain shows coverage)
```
    1|       |#include <iostream>
    2|       |
    3|      1|int main() {
    4|      1|    bool conditionA = false;
    5|      1|    bool conditionB = true;
    6|      1|    if (conditionA &&
    7|      1|        conditionB) {
    8|      0|        std::cout << "IF-THEN" << std::endl;
    9|      0|    }
   10|      1|    return 0;
   11|      1|}
```
2. Inconsistent coverage reporting across un-executed conditions
*(adjacent un-executed conditions may show 1 vs 0 line coverage)*
```
    1|       |#include <iostream>
    2|       |
    3|      1|int main() {
    4|      1|    bool conditionA = false;
    5|      1|    bool conditionB = true;
    6|      1|    bool conditionC = true;
    7|      1|    if (conditionA &&
    8|      1|        (conditionB ||
    9|      0|        conditionC)) {
   10|      0|        std::cout << "IF-THEN" << std::endl;
   11|      0|    }
   12|      1|    return 0;
   13|      1|}
```

This is resolved by inserting a GapRegion when mapping logical operators to isolate coverage contexts around short-circuit evaluation.
2025-08-08 12:50:52 -05:00
Drew Kersnar
90e8c8e718
[InferAlignment] Propagate alignment between loads/stores of the same base pointer (#145733)
We can derive and upgrade alignment for loads/stores using other
well-aligned loads/stores. This optimization does a single forward pass through
each basic block and uses loads/stores (the alignment and the offset) to
derive the best possible alignment for a base pointer, caching the
result. If it encounters another load/store based on that pointer, it
tries to upgrade the alignment. The optimization must be a forward pass within a basic
block because control flow and exception throwing can impact alignment guarantees.

---------

Co-authored-by: Nikita Popov <github@npopov.com>
2025-08-08 12:05:29 -05:00
Simon Pilgrim
45b4f1b438
[Headers][X86] Allow _mm512_set1_epi8/16/pd/ps intrinsics to be used in constexpr (#152746)
Pulled out of #152288 as I need this to proceed with several other patches
2025-08-08 17:04:08 +01:00
Orlando Cazalet-Hyams
1778669739
[KeyInstr] Remove LLVM_EXPERIMENTAL_KEY_INSTRUCTIONS CMake flag (#152735)
The CMake flag has been on by default for a month without any issues.

This makes the feature support in LLVM unconditional (but does not
enable the feature by default).
2025-08-08 17:03:28 +01:00
Simon Pilgrim
c8312bdd16
[Headers][X86] Enable constexpr handling for pmulhw/pmulhuw intrinsics (#152540)
This patch updates the pmulhw/pmulhuw builtins to support constant
expression handling - extending the VectorExprEvaluator::VisitCallExpr
handling code that handles elementwise integer binop builtins.

Hopefully this can be used as reference patch to show how to add future
target specific constexpr handling with minimal code impact.

I've also enabled pmullw constexpr handling (which are tagged on
#152490) as they all use very similar tests.

I've also had to tweak the MMX -> SSE2 wrapper as undefs are not
permitted in constexpr shuffle masks

Fixes #152524
2025-08-08 17:02:50 +01:00
Simon Pilgrim
f169893cbf
[Headers][X86] Allow BITALG vpopcntw/vpopcntb intrinsics to be used in constexpr (#152701)
Matches VPOPCNTDQ handling
2025-08-08 16:09:26 +01:00
Amina Chabane
478b415181
[AArch64] Enable svcompact intrinsic in streaming mode with SME2.2 (#151703)
When the target enables +sme2p2, the svcompact intrinsic is now
available in streaming SVE mode, through updating the guards in
arm_sve.td. Included Sema test acle_sve_compact.cpp.
2025-08-08 16:04:54 +01:00
Simon Pilgrim
e64224a224
[Headers][X86] Allow AVX cast intrinsics to be used in constexpr (#152730)
Still missing the "extend to 256-bit" casts - _mm256_castpd128_pd256 / _mm256_castps128_ps256 / _mm256_castsi128_si256 - due to constexpr not liking undefined/poison etc.
2025-08-08 15:39:39 +01:00
Timm Baeder
1b1f352cb9
[clang][bytecode] Handle reads on zero-size arrays (#152706) 2025-08-08 16:03:02 +02:00
Yaxun (Sam) Liu
479556c720
[HIP] compressed bundle format defaults to v3 (#152600)
HIP runtime support for compressed bundle format v3 is in place,
therefore switch the default compressed bundle format to v3 in compiler.

This allows both compressed and decompressed fat binary size to exceed
4GB by default.

Environment variable COMPRESSED_BUNDLE_FORMAT_VERSION=2 can be used for
backward compatibility for older HIP runtimes not supporting v3.

Fixes: SWDEV-548879
2025-08-08 08:53:01 -04:00
Simon Pilgrim
1e9ed918dd
[X86][AVX512BITALG] add C/C++ and 32/64-bit builtins test coverage (#152693) 2025-08-08 13:12:06 +01:00
Simon Pilgrim
691ede2830
[Headers][X86] Allow _mm512_set1_epi32/64 intrinsics to be used in constexpr (#152674)
Pulled out of #152288 as I need this to proceed with several other patches
2025-08-08 11:02:08 +01:00
Nikita Popov
c23b4fbdbb
[IR] Remove size argument from lifetime intrinsics (#150248)
Now that #149310 has restricted lifetime intrinsics to only work on
allocas, we can also drop the explicit size argument. Instead, the size
is implied by the alloca.

This removes the ability to only mark a prefix of an alloca alive/dead.
We never used that capability, so we should remove the need to handle
that possibility everywhere (though many key places, including stack
coloring, did not actually respect this).
2025-08-08 11:09:34 +02:00
Hood Chatham
b9c328480c
[clang][WebAssembly] Support reftypes & varargs in test_function_pointer_signature (#150921)
I fixed support for varargs functions
(previously it didn't crash but the codegen was incorrect).

I added tests for structs and unions which already work. With the
multivalue abi they crash in the backend, so I added a sema check that
rejects structs and unions for that abi.

It will also crash in the backend if passed an int128 or float128 type.
2025-08-07 13:07:04 -07:00
Andy Kaylor
1e2e903684
[CIR] Add VTableAddrPointOp (#148730)
This change adds the definition of VTableAddrPointOp and the related
AddressPointAttr to the CIR dialect, along with tests for the parsing
and verification of these elements.

Code to generate this operation will be added in a later change.
2025-08-07 11:25:40 -07:00
Aiden Grossman
660555191b
[Clang] Fix __cpuidex conflict with CUDA (#152556)
The landing of #126324 made it so that __has_builtin returns false for
aux triple builtins. CUDA offloading can sometimes compile where the
host is in the aux triple (ie x86_64). This patch explicitly carves out
NVPTX so that we do not run into redefinition errors.
2025-08-07 11:11:30 -07:00
Amr Hesham
093395ca6b
[CIR] Mul CompoundAssignment support for ComplexType (#152354)
This change adds support for Mul CompoundAssignment for ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-08-07 19:42:15 +02:00
Timm Baeder
193995d5a2
[clang][bytecode] Handle more invalid member pointer casts (#152546) 2025-08-07 19:24:01 +02:00
gitoleg
d97f0e9364
[CIR] add support for file scope assembly (#152093)
This PR adds a support for file scope assembly in CIR.
2025-08-07 10:12:58 -07:00
Pedro Lobo
f3bf8e0166
[clang][x86] Add C/C++ and 32/64-bit test coverage to constexpr tests (#152478)
Adds missing C++ run lines to test files containing `constexpr` tests.
Also adds missing 32/64-bit test coverage to the following tests:
- `clang/test/CodeGen/X86/avx512-reduceIntrin.c`
- `clang/test/CodeGen/X86/avx512-reduceMinMaxIntrin.c`
- `clang/test/CodeGen/X86/avx512vpopcntdq-builtins.c`
- `clang/test/CodeGen/X86/avx512vpopcntdqvl-builtins.c`

Additionally, fixes a `_mm512_popcnt_epi64` `constexpr` test that
incorrectly assumed 32-bit integers, leading to incorrect bit counts.
This change updates the test result to assume 64-bit integers.
2025-08-07 13:50:52 +01:00
Simon Pilgrim
f24c50a635 [X86] avx512dq-builtins.c - add C/C++ and 32/64-bit test coverage
Inspired by #152478
2025-08-07 12:08:48 +01:00
Yi-Chi Lee
e1d6753006
[Headers][X86] Update AVX/AVX512 float/double add/sub/mul/div/unpck intrinsics to be used in constexpr (#152435)
Fixed #152313

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-07 11:21:58 +01:00
Pedro Lobo
5805e88745
[Headers][X86] Allow AVX512 reduction intrinsics to be used in constexpr (#152363)
Closes #152324.
Part of #30794.

This PR adds `constexpr` support for the following AVX512 integer
reduction intrinsics:

- `_mm512_reduce_add_epi32`
- `_mm512_reduce_add_epi64`
- `_mm512_reduce_mul_epi32`
- `_mm512_reduce_mul_epi64`
- `_mm512_reduce_and_epi32`
- `_mm512_reduce_and_epi64`
- `_mm512_reduce_or_epi32`
- `_mm512_reduce_or_epi64`
- `_mm512_reduce_max_epi32`
- `_mm512_reduce_max_epi64`
- `_mm512_reduce_min_epi32`
- `_mm512_reduce_min_epi64`
- `_mm512_reduce_max_epu32`
- `_mm512_reduce_max_epu64`
- `_mm512_reduce_min_epu32`
- `_mm512_reduce_min_epu64`

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-07 10:46:22 +01:00
Simon Pilgrim
6abf4f376e
[Headers][X86] Allow AVX movddup/movsldup/movshdup intrinsics to be used in constexpr (#152340)
Matches SSE3 handling
2025-08-07 08:17:31 +01:00
Simon Pilgrim
b83f7f195c
[Headers][X86] Update SSE/AVX and/andnot/or/xor intrinsics to be used in constexpr (#152305) 2025-08-07 08:16:26 +01:00
Simon Pilgrim
edad89e4e0
[Headers][X86] Update MMX arithmetic intrinsics to be used in constexpr (#152296)
Update the easy add/sub/mul/logic/cmp/scalar_to_vector intrinsics to be
constexpr compatible.

I'm not expecting anyone to be very interested in using MMX intrinsics,
but they're smaller than the other types and are useful to test the
constexpr handling and test methods before we start applying them to
SSE/AVX2/AVX512 intrinsics.
2025-08-07 08:05:05 +01:00
Ziqing Luo
0abf4975bb
[-Wunsafe-buffer-usage] Do not warn about class methods with libc function names (#151270)
This commit fixes the false positive that C++ class methods with libc
function names would be false warned about. For example,

```
struct T {void strcpy() const;};
void test(const T& t) {  str.strcpy(); // no warn }
```

rdar://156264388
2025-08-07 14:31:13 +08:00
Florian Mayer
a7f1702f2c
[NFC] [CFI] correct comment in test (#152399)
It incorrectly stated that `const char*` gets normalized to ptr, while
it should say that `char*` does.
2025-08-06 16:07:40 -07:00
erichkeane
26dde15ed4 [OpenACC] Add warning for VLAs in a private/firstprivate clause
private/firstprivate typically do copy operations, however copying a VLA
isn't really possible.  This patch introduces a warning to alert the
person that this copy isn't happening correctly.

As a future direction, we MIGHT consider doing additional work to make
sure they are initialized/copied/deleted/etc correctly.
2025-08-06 13:14:20 -07:00
Douglas
ec138c7fa7
[OpenACC] Improve C++20 compatibility of private/firstprivate test (#152233)
Under C++17, `DeletedCopy` and `DefaultedCopy` in the test
`clang/test/SemaOpenACC/private_firstprivate_reduction_required_ops.cpp`
are eligible for aggregate initialization. Under C++20 and up, that is
no longer the case. Therefore, an explicit constructor must be declared
to avoid additional diagnostics which the test does not expect.

This test was failing in our downstream testing where our toolchain uses
C++20 as the default dialect.

See this reduced example for more details:
https://godbolt.org/z/46oErYT43
2025-08-06 10:25:59 -07:00
Oliver Hunt
c548c47476
[clang] Fix crash in dynamic_cast final class optimization (#152076)
This corrects the codegen for the final class optimization to
correct handle the case where there is no path to perform the
cast, and also corrects the codegen to handle ptrauth protected
vtable pointers.

As part of this fix we separate out the path computation as
that makes it easier to reason about the failure code paths
and more importantly means we can know what the type of the
this object is during the cast.

The allows us to use the GetVTablePointer interface which
correctly performs the authentication operations required when
pointer authentication is enabled. This still leaves incorrect
authentication behavior in the multiple inheritance case but
currently the optimization is disabled entirely if pointer
authentication is enabled.

Fixes #137518
2025-08-06 09:52:34 -07:00
Amr Hesham
4c9bb65639
[CIR] Plus & Minus CompoundAssignment support for ComplexType (#150759)
This change adds support for Plus & Minus CompoundAssignment for
ComplexType

https://github.com/llvm/llvm-project/issues/141365
2025-08-06 18:13:48 +02:00
Timm Baeder
8704ca0fb8
[clang][ExprConst] Consider integer pointers of value 0 nullptr (#150164)
When casting a 0 to a pointer type, the IsNullPtr flag was always set to
false, leading to weird results like a pointer with value 0 that isn't a
null pointer.

This caused

```c++
struct B { const int *p;};
template<B> void f() {}
template void f<B{nullptr}>();
template void f<B{fold(reinterpret_cast<int*>(0))}>();
```

to be valid code, since nullptr and (int*)0 aren't equal. This seems
weird and GCC doesn't behave like this.
2025-08-06 16:49:00 +02:00
Morris Hafner
4f166513df
[CIR] Upstream support for variable template specializations (#151069) 2025-08-06 16:43:42 +02:00
Joseph Huber
56ba1181e9
[Clang] Fix warning on synthetic offload arch argument in host only mode (#151969)
Summary:
These arguments are synthetically generated and should always be
considered used. This was emitting a warning on the new driver.
2025-08-06 07:30:07 -05:00
Himadhith
1f1b903a64
[NFC][PowerPC] Cleaning up test file and removing redundant front-end test (#151971)
NFC patch to clean up extra lines of code in the file
`llvm/test/CodeGen/PowerPC/check-zero-vector.ll` as the current one has
loop unrolled.
Also removing the file `clang/test/CodeGen/PowerPC/check-zero-vector.c`
as the patch affects only the backend.

Co-authored-by: himadhith <himadhith.v@ibm.com>
2025-08-06 15:59:47 +05:30
Simon Pilgrim
a5d85a6ab5
[Headers][X86] Allow AVX _mm256_set* intrinsics to be used in constexpr (#152173) 2025-08-06 11:14:22 +01:00
Timm Baeder
90d1d23507
[clang][bytecode] Overrride locs for certain CXXConstructExprs (#152185)
Do it only if we will end up skipping the initializer anyway because
it's a trivial copy or move constructor.
2025-08-06 09:07:40 +02:00
Vincent
3339a0045d
[clang] Respect [[gnu::error]] on functions passed to [[gnu::cleanup]] (#152082)
Forward SourceLocation to `EmitCall` so that clang triggers an error
when a function inside `[[gnu::cleanup(func)]]` is annotated with
`[[gnu::error("some message")]]`.

resolves #146520
2025-08-05 21:21:36 -07:00
Steven Perron
fe0948c9a5
[HLSL][SPIRV] Add vk::binding attribute (#150957)
The vk::binding attribute allows users to explicitly set the set and
binding for a resource in SPIR-V without chaning the "register"
attribute, which will be used when targeting DXIL.

Fixes https://github.com/llvm/llvm-project/issues/136894
2025-08-05 21:00:06 -04:00
Oliver Hunt
7268478295
[clang][PAC] Fix PAC codegen for final class dynamic_cast optimization (#152227)
The codegen for the final class dynamic_cast optimization fails to
consider pointer authentication. This change resolves this be simply
disabling the optimization when pointer authentication enabled.
2025-08-05 17:41:55 -07:00
Stanislav Mekhanoshin
34aed0ed56
[AMDGPU] Add gfx1250 wmma_scale[16]_f32_32x16x128_f4 instructions (#152194) 2025-08-05 15:15:21 -07:00
keinflue
81ed75679d
[clang] Fix constant evaluation of member pointer access into sibling class. (#150829)
HandleMemberPointerAccess considered whether the lvalue path in a member
pointer access matched the bases of the containing class of the member,
but neglected to check the same for the containing class of the member
itself, thereby ignoring access attempts to members in direct sibling
classes.

Fixes #150705.
Fixes #150709.
2025-08-05 14:44:15 -07:00
Helena Kotas
3b2a1a5d9b
[HLSL][NFC] Move all resource tests under CodeGenHLSL\resources (#152035)
Also removes an outdated test buffer-array-operator.hlsl. Array operator on resources is tested in StructuredBuffers-subscripts.hlsl and RWBuffer-subscript.hlsl.
2025-08-05 10:05:05 -07:00
zGoldthorpe
d7074b63ed
[Clang][AMDGPU] Add builtins for some buffer resource atomics (#149216)
This patch exposes builtins for atomic `add`, `max`, and `min` operations that
operate over buffer resource pointers.
2025-08-05 11:04:15 -06:00
Balazs Benics
6c9f1ce429 [analyzer] Add missing expected-warning after #151908 2025-08-05 17:28:49 +02:00
erichkeane
74af2cec7b [OpenACC] Fix 'type' checks in private/firstprivate for array types
These would not give a correct initializer, but they are not possible
to generate correctly anyway, so this patch makes sure we look through
the array type to correctly diagnose these.
2025-08-05 08:25:34 -07:00
Balazs Benics
0a1eff2ece
[analyzer] Drop assertion enforcing that assume args are known constants (#151908)
We sometimes don't know if the operand of [[assume]] is true/false, and
that's okay. We can just ignore the attribute in that case.

If we wanted something more fancy, we could bring the assumption to the
constraints, but dropping them should be just as fine for now.

Fixes #151854
2025-08-05 17:03:53 +02:00
Ritanya-B-Bharadwaj
1d594fdb8d
[Clang][OpenMP] Fixing Clang error for metadirective with multiple when clauses and no otherwise (#148583)
Fixing - https://github.com/llvm/llvm-project/issues/147336
2025-08-05 20:02:44 +05:30
Alex Voicu
ff8b4f8151
[AMDGCNSPIRV][NFC] Match AMDGPU's __builtin_va_list type (#152044)
AMDGCN flavoured SPIRV should math AMDGPU TI as much as possible, and
the va_list difference was spurious.
2025-08-05 15:30:16 +01:00