117361 Commits

Author SHA1 Message Date
Erich Keane
dcdbd5b55d
[OpenACC][NFCI] Implement 'recipe' generation for firstprivate copy (#153622)
The 'firstprivate' clause requires that we do a 'copy' operation, so
this patch creates some AST nodes from which we can generate the copy
operation, including a 'temporary' and array init. For the most part
this is pretty similar to what 'private' does other than the fact that
the source is copy (and not default init!), and that there is a
temporary from which to copy.

---------

Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
2025-08-15 18:42:40 +00:00
Aaron Ballman
ed6d505fab
[C][Docs] Add backported language features (#153837)
We've backported a lot more features from C to previous C standards than
we were documenting. I took a pass over the c_status page for Clang and
pulled more entries to add to our documentation.
2025-08-15 13:59:41 -04:00
Simon Pilgrim
92cb0414ca [X86] avx512vnni-builtins.c / avx512vlvnni-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 17:55:33 +01:00
keinflue
af96ed6bf6
[clang] Inject IndirectFieldDecl even if name conflicts. (#153140)
This modifies InjectAnonymousStructOrUnionMembers to inject an
IndirectFieldDecl and mark it invalid even if its name conflicts with
another name in the scope.

This resolves a crash on a further diagnostic
diag::err_multiple_mem_union_initialization which via
findDefaultInitializer relies on these declarations being present.

Fixes #149985
2025-08-15 09:43:29 -07:00
Simon Pilgrim
2c20a9bfb3 [X86] avx512bf16-builtins.c / avx512vlbf16-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 17:38:43 +01:00
Phoebe Wang
b0d2b57f7e
[Headers][X86] Remove more duplicated typedefs (#153820)
They are defined in mmintrin.h
2025-08-16 00:21:40 +08:00
Shafik Yaghmour
868efdcf38
[Clang][Bytecode][NFC] Move Result into APSInt constructor (#153664)
Static analysis flagged this line because we are copying Result instead
of moving it.
2025-08-15 08:52:49 -07:00
Simon Pilgrim
38eb14f27c [X86] avx512vbmi2-builtins.c / avx512vlvbmi2-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 16:35:16 +01:00
Simon Pilgrim
7df862818e [X86] avx512vbmi-builtins.c / avx512vbmivl-builtin.c - add C/C++ and 32/64-bit test coverage 2025-08-15 16:35:15 +01:00
Phoebe Wang
f24d91eb2c
[Headers][X86] Remove duplicate __v8hu, NFCI (#153734)
Newly added in xmmintrin.h by c8312bdd1665225c585dd2b0bff5e46d569edd45
2025-08-15 22:48:59 +08:00
Simon Pilgrim
09267f6720 [X86] avx512vp2intersect-builtins.c / avx512vlvp2intersect-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 15:39:12 +01:00
Simon Pilgrim
17dd57b00e [X86] avxvnni-builtins.c / avxvnniint8-builtins.c / avxvnniint16-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 15:17:15 +01:00
Erich Keane
15d7a95ea9
[CIR] Refactor recipe init generation, cleanup after init (#153610)
In preperation of the firstprivate implementation, this separates out
some functions to make it easier to read.

Additionally, it cleans up the VarDecl->alloca relationship, which will
prevent issues if we have to re-use the same vardecl for a future
generated recipe (and causes concerns in firstprivate later).
2025-08-15 06:41:42 -07:00
Simon Pilgrim
6ad39bc866 [X86] avxifma-builtins.c / avx512ifma-builtins.c / avx512ifmavl-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 12:09:54 +01:00
Yanzuo Liu
3b27d50cc7
[LLVM][utils] Add script which clears release notes (#153593)
The script copies `ReleaseNotesTemplate.txt` to corresponding
`ReleaseNotes.rst`/`.md` to clear release notes.

The suffix of `ReleaseNotesTemplate.txt` must be `.txt`. If it is
`.rst`/`.md`, it will be treated as a documentation source file when
building documentation.
2025-08-15 19:00:08 +08:00
Simon Pilgrim
b014d10ed7 [X86] avx512cd-builtins.c + avx512vlcd-builtins.c - add C/C++ and 32/64-bit test coverage 2025-08-15 09:44:18 +01:00
Doug Gregor
ae90b60fc8
[APINotes] Add SwiftDestroyOp API note to map to the "destroy" function (#153261)
Like retain/release for reference types, "destroy" lets us specify an
operation that is used to deinitialize an instance of a noncopyable
type.
2025-08-15 08:02:14 +01:00
Ami-zhang
a1b6e7ff39
[clang][LoongArch] Ensure target("lasx") implies LSX support (#153542)
Currently, `__attribute__((target("lasx")))` does not automatically
enable LSX support, causing Clang to fail with `-mno-lsx`. Since
LASX depends on LSX, enabling LASX should implicitly enable LSX to
avoid clang error.
    
Fixes #149512.

Depends on #153541
2025-08-15 09:53:08 +08:00
Shafik Yaghmour
c22ec9cde3
[Clang][Sema] Add nullptr check in IsFunctionConversion (#153710)
Static analysis flagged this code b/c ToFPT could be nullptr but we were
not checking it even though in the previous if statement we did. It
looks like this was a mistaken refactor from:

https://github.com/llvm/llvm-project/pull/135836

In the older code ToFPT was set using a cast which would have asserted
but no longer in the new code.
2025-08-14 18:42:59 -07:00
Ami-zhang
793a6b4fd4
[NFC] Precommit test for issue #149512 (#153541) 2025-08-15 09:15:15 +08:00
Oliver Hunt
fb14f91305
[clang][Obj-C][PAC] Make block descriptor pointer signing configurable (#153700)
Pointer auth protection of the block descriptor pointer is only
supported in some constrained environments so we do actually need it to
be configurable.

We had made it non configurable in the first PR to protect block
metadata because we believed that was an option but subsequently
realised it does need to remain configurable.

This PR revives the flags that permit this.
2025-08-14 17:20:27 -07:00
Daniel Paoliello
fc4df2c917
[win][arm64ec] XFAIL x64 intrinsic tests on Arm64EC (#153474)
Clang defines the x64 preprocessor macro (`__x86_64__`) when building
Arm64EC, however the tests for x64 built-ins and intrinsics are
currently failing since the relevant functions don't exist, resulting in
errors like:

```
Line 165: invalid conversion between vector type '__v2di' (vector of 2 'long long' values) and integer type 'int' of different size
```

(Clang doesn't know the intrinsics being called, and so treats it like
an undefined function, which makes it assume the return type is `int`)

For now, expect these tests to fail until someone decides to implement
these intrinsics.
2025-08-14 15:29:20 -07:00
Stanislav Mekhanoshin
57c1e01e48
[AMDGPU] Don't allow wgp mode on gfx1250 (#153680)
- gfx1250 only supports cu mode
2025-08-14 15:16:56 -07:00
Andy Kaylor
a1529cd85a
[CIR] Add index support for global_view (#153254)
The #cir.global_view attribute was initially added without support for
the optional index list. This change adds index list support. This is
used when the address of an array or structure member is used as an
initializer.

This patch does not include support for taking the address of a
structure or class member. That will be added later.
2025-08-14 15:14:12 -07:00
Morris Hafner
e56ae9651b
[CIR][NFC] Add Symbol Table to CIRGenFunction (#153625)
This patchs adds a symbol table to CIRGenFunction plus scopes and
insertions to the table where we were missing them previously.
2025-08-14 22:53:09 +02:00
Bill Wendling
1e9fc8edd0 [Clang][attr] Add '-std=c11' to allow for typedef redefinition 2025-08-14 13:51:58 -07:00
Bill Wendling
aa4805a090
[Clang][attr] Add 'cfi_salt' attribute (#141846)
The 'cfi_salt' attribute specifies a string literal that is used as a
"salt" for Control-Flow Integrity (CFI) checks to distinguish between
functions with the same type signature. This attribute can be applied
to function declarations, function definitions, and function pointer
typedefs.

This attribute prevents function pointers from being replaced with
pointers to functions that have a compatible type, which can be a CFI
bypass vector.

The attribute affects type compatibility during compilation and CFI
hash generation during code generation.

  Attribute syntax: [[clang::cfi_salt("<salt_string>")]]
  GNU-style syntax: __attribute__((cfi_salt("<salt_string>")))

- The attribute takes a single string of non-NULL ASCII characters.
- It only applies to function types; using it on a non-function type
  will generate an error.
- All function declarations and the function definition must include
  the attribute and use identical salt values.

Example usage:

  // Header file:
  #define __cfi_salt(S) __attribute__((cfi_salt(S)))

  // Convenient typedefs to avoid nested declarator syntax.
  typedef int (*fp_unsalted_t)(void);
  typedef int (*fp_salted_t)(void) __cfi_salt("pepper");

  struct widget_ops {
    fp_unsalted_t init;     // Regular CFI.
    fp_salted_t exec;       // Salted CFI.
    fp_unsalted_t teardown; // Regular CFI.
  };

  // bar.c file:
  static int bar_init(void) { ... }
  static int bar_salted_exec(void) __cfi_salt("pepper") { ... }
  static int bar_teardown(void) { ... }

  static struct widget_generator _generator = {
    .init = bar_init,
    .exec = bar_salted_exec,
    .teardown = bar_teardown,
  };

  struct widget_generator *widget_gen = _generator;

  // 2nd .c file:
  int generate_a_widget(void) {
    int ret;

    // Called with non-salted CFI.
    ret = widget_gen.init();
    if (ret)
      return ret;

    // Called with salted CFI.
    ret = widget_gen.exec();
    if (ret)
      return ret;

    // Called with non-salted CFI.
    return widget_gen.teardown();
  }

Link: https://github.com/ClangBuiltLinux/linux/issues/1736
Link: https://github.com/KSPP/linux/issues/365

---------

Signed-off-by: Bill Wendling <morbo@google.com>
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-08-14 13:07:38 -07:00
Matheus Izvekov
eeada0d30f
[clang] fix source range computation for DeducedTemplateSpecializationType (#153646)
This was a regression introduced in
https://github.com/llvm/llvm-project/pull/147835

Since this regression was never released, there are no release notes.

Fixes https://github.com/llvm/llvm-project/issues/153540
2025-08-14 16:42:34 -03:00
Kaitlin Peng
cbfc22c06b
Fix typo in step intrinsic comment (#153642)
`y` should be the first argument and `x` should be the second, otherwise
the formula is wrong. This also matches the documentation
[here](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-step).
2025-08-14 12:02:34 -07:00
Iris Shi
dc0becc4d0
[CIR] Add InlineAsmOp lowering to LLVM (#153387)
- Part of #153267

Added support for lowering `InlineAsmOp` directly to LLVM IR

---------
Co-authored-by: Morris Hafner <mhafner@nvidia.com>
2025-08-14 17:48:14 +00:00
Iris Shi
9a28783f5d
[CIR] Add InlineAsmOp (#153362)
- Part of #153267

---------

Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
Co-authored-by: Morris Hafner <mmha@users.noreply.github.com>
2025-08-14 17:34:38 +00:00
Andy Kaylor
45066c2937
[CIR] Add lowering for the cir.vtable.address_point operation (#153243)
This adds support for lowering the cir.vtable.address_point operation to
the LLVM dialect, as well as type converter support for the cir.vptr
type.
2025-08-14 10:07:54 -07:00
Mikołaj Piróg
768eae72cd
[Clang] Honor -flax-vector-conversions=none on some tests (#153433)
As in title. This is done as a step towards enabling the
`-flax-vector-conversions=none` globally as a default
2025-08-14 17:02:52 +02:00
Krzysztof Parzyszek
c9bf00a83d
[docs][OpenMP] Claim groupprivate for flang (#153586) 2025-08-14 09:39:02 -05:00
Simon Pilgrim
179698a0fb [X86] ssse3-builtins.c - add -fno-signed-char test coverage 2025-08-14 14:20:35 +01:00
Kajetan Puchalski
d3d96e2057
[flang][OpenMP] Add -f[no]-openmp-simd (#150269)
Both clang and gfortran support the -fopenmp-simd flag, which enables
OpenMP support only for simd constructs, while disabling the rest of
OpenMP.

Implement the appropriate parse tree rewriting to remove non-SIMD OpenMP
constructs at the parsing stage.

Add a new SimdOnly flang OpenMP IR pass which rewrites generated OpenMP
FIR to handle untangling composite simd constructs, and clean up OpenMP
operations leftover after the parse tree rewriting stage.
With this approach, the two parts of the logic required to make the flag
work can be self-contained within the parse tree rewriter and the MLIR
pass, respectively. It does not need to be implemented within the core
lowering logic itself.

The flag is expected to have no effect if -fopenmp is passed explicitly,
and is only expected to remove OpenMP constructs, not things like OpenMP
library functions calls. This matches the behaviour of other compilers.

---------

Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
2025-08-14 14:20:15 +01:00
Vladimir Vuksanovic
9d1dd9a264
[Sema] Fix false positive warnings for misaligned member access (#150025)
These warnings are reported on a per expression basis, however some
potential misaligned accesses are discarded before that happens. The
problem is when a new expression starts while processing another
expression. The new expression will end first and emit all potential
misaligned accesses collected up to that point. That includes candidates
that were found in the parent expression, even though they might have
gotten discarded later.

Fixed by checking if the candidate is located withing the currently
processed expression.

Fixes #144729
2025-08-14 06:14:43 -07:00
Michael Klemm
2211394705
[NFC][OpenMP][Docs] Claim work on OpenMP workdistribute construct (#153573) 2025-08-14 15:02:08 +02:00
Ritanya-B-Bharadwaj
e3dcdb64ee
Claiming support for groupprivate and variable-category (#153553) 2025-08-14 18:15:46 +05:30
Vincent
d3bbdc7bde
[clang] constexpr __builtin_elementwise_abs support (#152497)
Added constant evaluation support for `__builtin_elementwise_abs` on integer, float and vector type.

fixes #152276

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-14 12:34:23 +01:00
mdenson
f5b36eb3a4
[clang] fix comment lexing of command names with underscore (#152943)
Comment lexer fails to parse non-alphanumeric names.

fixes #33296

---------

Co-authored-by: Brock Denson <brock.denson@virscient.com>
2025-08-14 13:03:55 +02:00
Corentin Jabot
186176de45
[Clang] Do not consider a variadic function ellipsis part of a default arg (#153496)
When stashing the tokens of a parameter of a member function, we would
munch an ellipsis, as the only considered terminal conditions were `,`
and `)`.

Fixes #153445
2025-08-14 12:51:58 +02:00
Matheus Izvekov
9255580a3a
[clang] fix skipped parsing of late parsed attributes (#153558) 2025-08-14 06:42:55 -03:00
TianYe
44e6bc6fc0
[Headers][X86] Allow AVX2/AVX512 broadcast intrinsics to be used in Constexpr (#153363)
Fix [issue](https://github.com/llvm/llvm-project/issues/152499)
This patch adds support for the following broadcast intrinsics
by wrapping them around existing generic shuffle implementations:
```
_mm_broadcastb_epi8
_mm_broadcastw_epi16
_mm_broadcastd_epi32
_mm_broadcastq_epi64
_mm_broadcastss_ps
_mm_broadcastsd_pd

_mm256_broadcastb_epi8
_mm256_broadcastw_epi16
_mm256_broadcastd_epi32
_mm256_broadcastq_epi64
_mm256_broadcastss_ps
_mm256_broadcastsd_pd

_mm256_broadcastsi128_si256

_mm512_broadcastb_epi8
_mm512_broadcastw_epi16
_mm512_broadcastd_epi32
_mm512_broadcastq_epi64
_mm512_broadcastss_ps
_mm512_broadcastsd_pd

_mm512_broadcast_f32x2 _mm256_broadcast_f32x2
_mm512_broadcast_i32x2 _mm256_broadcast_i32x2 _mm_broadcast_i32x2
_mm512_broadcast_f32x4 _mm256_broadcast_f32x4
_mm512_broadcast_i32x4 _mm256_broadcast_i32x4
_mm512_broadcast_f32x8
_mm512_broadcast_i32x8
_mm512_broadcast_f64x2 _mm256_broadcast_f64x2
_mm512_broadcast_i64x2 _mm256_broadcast_i64x2
_mm512_broadcast_f64x4
_mm512_broadcast_i64x4
```

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-14 09:40:11 +01:00
mcbarton
b24b8a5bb4
Enable running ClangReplInterpreterTests in an Emscripten environment (#150977)
@vgvassilev @anutosh491 This is what it took for me to enable running
ClangReplInterpreterTests in an Emscripten environment. When I ran this
patch for llvm 20 we could run InterpreterTest.InstantiateTemplate , but
now it crashes gtest when running in node. Let me know what you think.
2025-08-14 14:07:13 +05:30
Chuanqi Xu
ab5a5a90c0 [C++20] [Modules] Fix incorrect diagnostic for using befriend target
Close https://github.com/llvm/llvm-project/issues/138558

The compiler failed to understand the redeclaration-relationship when
performing checks when MergeFunctionDecl. This seemed to be a complex
circular problem (how can we know the redeclaration relationship before
performing merging?). But the fix seems to be easy and safe. It is fine
to only perform the check only if the using decl is a local decl.
2025-08-14 14:23:14 +08:00
Oliver Hunt
d8850ee6c0
[clang][Obj-C][PAC] Add support for authenticating block metadata (#152978)
Introduces the use of pointer authentication to protect the invocation,
copy and dispose, reference, and descriptor pointers in Objective-C
block objects.

Resolves #141176
2025-08-13 22:01:24 -07:00
Andy Kaylor
f2d76b58f8
[CIR] Use a loop for array initialization (#153499)
This updates the array initialization loop to use a do..while loop
rather than a fully serialized initialization. It also allows the
initialization of destructed objects when exception handling is not
enabled.

Array initialization when exception handling is enabled remains
unimplemented, but more precise messages are now emitted.
2025-08-13 16:14:32 -07:00
Jasmine Tang
da422daea9
Fix wrong function signature for #153102 (#153473)
- Fixes wrong function signature for #153102
2025-08-13 13:58:52 -07:00
Joseph Huber
dedc5916a5
[LinkerWrapper] Remove special handling for archives (#114843)
Summary:
Previously we extracted archives and did special symbol resolution on
them, this was mostly done because the nvlink executable couldn't handle
archives natively. Since I have added a wrapper around it that handles
that, we can now remove a lot of this complexity and just create a new
archive and pass it to the device linker.

The one issue here is that for offloading code, we often have references
to kernels that do not come from the device link job, but from the host
that wishes to call them. Under normal circumstances we would ignore
them because they are not referenced, but we need them. For now I am
just passing `--whole-archive`. In a future patch I will likely add some
logic to create a linker script that will tell the linker which symbols
we want to be extracted. That won't work for NVPTX but it's the most
canonical solution.

Also some ugliness in this patch where I need to juggle whether or not
the input is an archive and throw pairs around, I may merge that into
the `OffloadFile` struct in a later patch.
2025-08-13 14:24:47 -05:00