59714 Commits

Author SHA1 Message Date
Alex Voicu
06458fff87
[AMDGCNSPIRV][NFC] Add missing target features to AMDGCNSPIRV (#152057)
`gfx1250` bring-up omitted updating the `amdgcnspirv` feature list, this
fixes that oversight.
2025-08-05 15:29:48 +01:00
Aaron Danen
2444c4a698
[clang-repl] add %help, documentation, and tests for %commands (#150348)
1. Added %commands to documentation
2. Added %help command to clang repl
3. Expanded parsing to throw unique errors in the case of users entering
an invalid %command or using %lib without an argument
4. Added tests to check the behvaior of %help, %lib, and bad %commands
2025-08-05 14:50:48 +01:00
Timm Baeder
dc7c3c2b2b
[clang][bytecode] Disable location tracking for implicit field inits (#150190) 2025-08-05 13:14:01 +02:00
Sirui Mu
13600c72ce
[CIR] Add CIRGen for cir.unreachable and cir.trap (#151363) 2025-08-05 18:52:02 +08:00
Timm Baeder
b557cd3e8f
[clang][bytecode][NFC] Add a c++11 test case (#152104)
This test case breaks when ignoring trivial CXXConstructExprs of array
types, so make sure we don't do that.
2025-08-05 11:28:05 +02:00
Corentin Jabot
f72b3e1c07
[Clang] Add detailed notes explaining why is_constructible evaluates to false (Revert 16d5db7) (#151935)
Adds explanation why `is_constructible` evaluates to false.

This reapplies as-is e476f968bc8e438a0435d10934f148de570db8eb.
This was reverted in 16d5db71b3c38f21aa17783a8758f947dca5883f because of
a test failure in libc++.

The test failure in libc++ is interesting in that, in the absence of
nested diagnostics a bunch of diagnostics are emitted as error instead
of notes, which we cannot silence with `-verify-ignore-unexpected`.

The fix here is to prevent the diagnostics to be emitted in the first
place.
However this is clearly not ideal and we should make sure to deploy a
better solution in the clang 22 time frame, in the lines of
https://discourse.llvm.org/t/rfc-add-a-new-text-diagnostics-format-that-supports-nested-diagnostics/87641/12

Fixes #150601

---------

Co-authored-by: Shamshura Egor <164661612+egorshamshura@users.noreply.github.com>
2025-08-05 10:51:26 +02:00
Simon Tatham
87283db548
[clang][ARM] Fix build failure in <arm_acle.h> for __swp (#151354)
In commit d5985905ae8e5b2 I introduced a Sema check that prohibits
`__builtin_arm_ldrex` and `__builtin_arm_strex` for data sizes not
supported by the target architecture version. However, `arm_acle.h`
unconditionally uses those builtins with a 32-bit data size. So now
including that header will cause a build failure on Armv6-M, or historic
architectures like Armv5.

To fix it, `arm_acle.h` now queries the compiler-defined
`__ARM_FEATURE_LDREX` macro (also fixed recently in commit
34f59d79209268e so that it matches the target architecture). If 32-bit
LDREX isn't available it will fall back to the older SWP instruction, or
failing that (on Armv6-M), a libcall.

While I was modifying the header anyway, I also renamed the local
variable `v` inside `__swp` so that it starts with `__`, avoiding any
risk of user code having #defined `v`.
2025-08-05 08:45:54 +01:00
Timm Baeder
8f7dfc689c
[clang][bytecode] Call CheckLocalLoad in GetLocal (#152090)
I forgot to call this here as well. It was only used in the EvalEmitter
implementation of the function. Also fix a problem where we didn't
diagnose out-of-lifetime reads here.
2025-08-05 08:46:22 +02:00
Timm Baeder
df3f629735
[clang][bytecode][NFC] Only collect non-null args if we have to (#152074)
Only do this if the function really has a NonNullArg.
2025-08-05 07:54:25 +02:00
Timm Baeder
d02714c85a
[clang][bytecode] Return success for pointers to locals (#151980)
They aren't valid, but we leave them successful here and
CheckLValueConstantExpression will diagnose them later.
2025-08-05 05:18:47 +02:00
Stanislav Mekhanoshin
a153e83e41
[AMDGPU] gfx1250 v_wmma_scale[16]_f32_16x16x128_f8f6f4 codegen (#152036) 2025-08-04 19:16:34 -07:00
Andres-Salamanca
9f7f3d6548
[CIR] Implemented get/set for volatile bitfields (#151875)
This PR adds support for loading and storing volatile bit-field members
according to the AAPCS specification.

> A volatile bit-field must always be accessed using an access width
appropriate to the type of its container, except when any of the
following are true:
>
> * The bit-field container overlaps with a zero-length bit-field.
> * The bit-field container overlaps with a non-bit-field member.

For example, if a bit-field is declared as `int`, the load/store must
use a 32-bit access, even if the field itself is only 3 bits wide.
2025-08-04 17:29:25 -05:00
erichkeane
4e0b68cef0 [OpenACC] Implement warning restrictions for 'firstprivate'
'firstprivate' can't be generated unless we have a copy constructor, so
this patch implements the restriction as a warning, and prevents the
item from being added to the AST.
2025-08-04 11:42:33 -07:00
Erich Keane
66eadbb235
[OpenACC][CIR] Implement 'init' lowering for private clause vars (#151781)
Previously, #151360 implemented 'private' clause lowering, but didn't
properly initialize the variables. This patch adds that behavior to make
sure we correctly get the constructor or other init called.
2025-08-04 11:14:58 -07:00
Aaron Ballman
cb50d78a00
[C] static_assert in a for loop is not an extension (#151955)
The original wording can be squinted at to pretend this was always
allowed. GCC squints at it that way, so we're doing the same and no
longer issuing an extension diagnostic for use of static_assert in the
condition-1 of a for loop in C.

Fixes #149633
2025-08-04 12:46:53 -04:00
Fraser Cormack
df74736732
[clang] Add the ability to link libclc OpenCL libraries (#146503)
This commit adds driver support for linking libclc OpenCL libraries. It
takes the form of a new optional flag: --libclc-lib=namespec. Nothing is
linked unless this flag is specified.

Not all libclc targets have corresponding clang targets. For this reason
it is desirable for users to be able to specify a libclc library name.
We support this by taking both a library name (without the .bc suffix)
or a filename. Both of these are searched for in the clang resource
directory. Filenames are
also checked themselves so that absolute paths can be provided. The
syntax for specifying filenames (as opposed to library names) uses a
leading colon (:), inspired by the -l option.

To accommodate this option, libclc libraries are now placed into clang's
resource directory in an in-tree configuration. The libraries are all
placed in <resource-dir>/lib/libclc and
are not grouped under host-specific directories as some other runtime
libraries are; it is not expected that OpenCL libraries will differ
depending on the host toolchain.

Currently only the AMDGPU toolchain supports this option as a proof of
concept. Other targets such as NVPTX or SPIR/SPIR-V could support it
too. We could optionally let target toolchains search for libclc
libraries themselves, possibly when passed an empty --libclc-lib.
2025-08-04 15:37:22 +01:00
Simon Pilgrim
88c6448fa2
Revert "[VectorCombine] Shrink loads used in shufflevector rebroadcasts" (#151960)
Reverts llvm/llvm-project#128938 while a crash regression is investigated
2025-08-04 15:03:53 +01:00
Matt
2e404d1f80
clang: Make the type_info builtin declaration a singleton (#151277)
This fixes an ambiguous type type_info when you try and reference the
`type_info` type while using clang modulemaps with `-fms-compatibility`
enabled

Fixes #38400
2025-08-04 06:44:10 -07:00
Tomohiro Kashiwada
80dae15831
[clang][DebugInfo] Disable VTable debug info (#130255) on COFF platforms (#151684)
On COFF platform, d1b0cbff806b50d399826e79b9a53e4726c21302 generates a
debug info linked with VTable regardless definition is present or not.
If that VTable ends up implicitly dllimported from another DLL, ld.bfd
produces a runtime pseudo relocation for it (LLD doesn't, since
d17db6066d2524856fab493dd894f8396e896bc7). If the debug section is
stripped, the runtime pseudo relocation points to memory space outside
of the module, causing an access violation.

At this moment, we simply disable VTable debug info on COFF platform to
avoid this problem.
2025-08-04 16:07:02 +03:00
Endre Fülöp
a3d0c541eb
[clang][analyzer] Add StoreToImmutable checker (#150417)
This adds alpha.core.StoreToImmutable, a new alpha checker that detects
writes
to immutable memory regions, implementing part of SEI CERT Rule ENV30-C.
The
original proposal only handled global const variables, but this
implementation
extends it to also detect writes to:
- Local const variables
- String literals
- Const parameters and struct members
- Const arrays and pointers to const data

This checker is the continuation of the work started by zukatsinadze.
Discussion: https://reviews.llvm.org/D124244
2025-08-04 14:56:33 +02:00
Timm Baeder
76e38ca981
[clang][bytecode] Try to load primitive values directly (#151833)
Instead of doing a GetPtrLocal + Load or GetPtrGlobal + Load pair, try
to load the value directly.
2025-08-04 12:28:33 +02:00
Leon Clark
1feed444aa
[VectorCombine] Shrink loads used in shufflevector rebroadcasts (#128938)
Attempt to shrink the size of vector loads where only some of the incoming lanes are used for rebroadcasts in shufflevector instructions.

---------

Co-authored-by: Leon Clark <leoclark@amd.com>
Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-04 10:49:27 +01:00
Gergely Futo
1454db130a
[RISCV] Support resumable non-maskable interrupt handlers (#148134)
The `rnmi` interrupt attribute value has been added for the `Smrnmi`
extension.

---------

Co-authored-by: Sam Elliott <sam@lenary.co.uk>
2025-08-04 10:54:50 +02:00
Ilya Biryukov
0cfe9f7287
[Clang] Handle C++20 export declarations in -dump-minimization-hints (#151666)
Thanks to Justin Stitt for bringing this up, providing test cases and a
direction for the fix!
2025-08-04 10:12:52 +02:00
Corentin Jabot
28ed57eda8
[Clang] Initial support for P2841 (Variable template and concept template parameters) (#150823)
This is a first pass at implementing
[P2841R7](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p2841r7.pdf).

The implementation is far from complete; however, I'm aiming to do that
in chunks, to make our lives easier.

In particular, this does not implement
 - Subsumption
 - Mangling
- Satisfaction checking is minimal as we should focus on #141776 first
(note that I'm currently very stuck)

FTM, release notes, status page, etc, will be updated once the feature
is more mature. Given the state of the feature, it is not yet allowed in
older language modes.

Of note: 
- Mismatches between template template arguments and template template
parameters are a bit wonky. This is addressed by #130603
- We use `UnresolvedLookupExpr` to model template-id. While this is
pre-existing, I have been wondering if we want to introduce a different
OverloadExpr subclass for that. I did not make the change in this patch.
2025-08-04 08:51:22 +02:00
Aaron Puchert
a048aeb06e
Thread safety analysis: Don't warn on acquiring reentrant capability (#150857)
The point of reentrant capabilities is that they can be acquired
multiple times, so they should probably be excluded from requiring a
negative capability on acquisition via -Wthread-safety-negative.

However, we still propagate explicit negative requirements.
2025-08-03 19:50:17 +02:00
Aiden Grossman
90f1e04954 [clang] Try fixing implicit-module-header-maps.cpp
This is still crashing on AIX and Solaris. It looks like maybe issues
due to trying to delete the current working directory. cd to the source
directory beforehand to try and work around that.
2025-08-03 16:07:36 +00:00
Connector Switch
8b7f81f2de
[NFC] Fix assignment typo. (#151864) 2025-08-03 22:32:00 +08:00
Stanislav Mekhanoshin
d18511e10a
[AMDGPU] v_cvt_scalef32_sr_pk16_* gfx1250 instructions (#151810) 2025-08-02 15:21:59 -07:00
Aiden Grossman
b7b501e54c Reapply "[clang] Remove %T from tests (#151614)"
This reverts commit 4c80193a58a5c24e2bbebe291feb406191c4e2ab.

This relands the commit. The issues have theoretically been fixed.
2025-08-02 20:08:53 +00:00
Stanislav Mekhanoshin
bc463c059c
[AMDGPU] v_cvt_scalef32_pk16_* gfx1250 instructions (#151807) 2025-08-02 12:42:12 -07:00
Stanislav Mekhanoshin
7598c25b5a
[AMDGPU] v_cvt_scale_pk16 gfx1250 instructions (#151804) 2025-08-02 10:45:02 -07:00
Andres-Salamanca
7e9927127f
[CIR] Fix outdated bitfield iteration logic in accumulateFields (#151741)
This PR fixes the outdated logic for accumulating bitfields in
`accumulateFields`. The old approach remained after the algorithm was
updated. A non-bitfield member would act as a barrier, causing
`accumulateBitFields` to receive an incomplete range of fields. As a
result, it failed to accumulate them properly when clipping was
necessary.

For reference, in ClangIR we already handle this correctly:

[b647f4b97b/clang/lib/CIR/CodeGen/CIRRecordLayoutBuilder.cpp (L711-L714))
2025-08-02 09:39:51 -05:00
Timm Baeder
a1dfcc6e81
[clang][bytecode] Fix D3DCOLORtoUBYTE4 hlsl test (#151819)
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-08-02 16:18:38 +02:00
Iris Shi
eefc3d275f
[clang][diagnostics] Fix fix-it hint parenthesis placement for fold expressions (#151790)
- Closes #151787

Insert the right parenthesis one token later to correctly enclose the
expression.

---------

Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>
2025-08-02 16:53:06 +08:00
Nathan Chancellor
a1c3c6554f
[clang][test] Split out staticanalyzer portion of Modules/specializations-lazy-load-parentmap-crash.cpp (#151259)
When the static analyzer is disabled with
-DCLANG_ENABLE_STATIC_ANALYZER=OFF, the newly added
specializations-lazy-load-parentmap-crash.cpp test fails with:

  error: action RunAnalysis not compiled in

  --

  ********************
  ********************
  Failed Tests (1):
    Clang :: Modules/specializations-lazy-load-parentmap-crash.cpp

Split out the part of the test that requires the static analyzer so that
it does not run when the static analyzer is unavailable.
2025-08-01 23:53:17 -07:00
Stanislav Mekhanoshin
0988510ad4
[AMDGPU] gfx1250 v_perm_pk16_* instructions (#151773) 2025-08-01 20:12:35 -07:00
Stanislav Mekhanoshin
cc3932bf29
[AMDGPU] gfx1250 v_cvt_scalef32_sr_pk8_* instructions (#151765) 2025-08-01 19:25:57 -07:00
Stanislav Mekhanoshin
962ee7a568
[AMDGPU] gfx1250 v_cvt_scalef32_pk8_* instructions (#151758) 2025-08-01 18:29:45 -07:00
Bill Wendling
49a24b3116
[CodeGen][counted_by] Support use of the comma operator (#151776)
Writing something like this:

  __builtin_dynamic_object_size((0, p->array), 0)

is equivalent to writing this:

  __builtin_dynamic_object_size(p->array, 0)

though the former will give a warning about the first value being
unused.
2025-08-01 17:28:08 -07:00
Stanislav Mekhanoshin
33abf05af4
[AMDGPU] gfx1250 v_permlane_* instructions (#151749) 2025-08-01 16:14:19 -07:00
Artem Belevich
12eab1a7b8
[CUDA] Use --image3 to construct fat binary (#151760)
CUDA-12.9 has removed fatbinary tool's `--image` argument we've been
using till now.

--image3 has been supported since cuda-9, so we do not need CUDA SDK
version checks.
2025-08-01 13:14:14 -07:00
Andy Kaylor
c188e1db6a
[CIR] Add vptr type and generate vptr field when needed (#151377)
This adds a new CIR type, cir.vptr, and generates a field of that type
when a record is declared that requires a vptr member.
2025-08-01 12:10:04 -07:00
Andy Kaylor
a304e09fe7
[CIR] Handle expression with cleanups (#151600)
This adds code to handle expressions with cleanup, including
materializing a temporary object for the expression.
2025-08-01 11:38:35 -07:00
Eli Friedman
558277ae4d
[clang][ARM] Fix setting of MaxAtomicInlineWidth. (#151404)
2f497ec3a0056f15727ee6008211aeb2c4a8f455 updated the backend's rules for
when lock-free atomics are available, but we never made a corresponding
change to the frontend. Fix it to be consistent. This only affects
targets older than v7.
2025-08-01 11:03:21 -07:00
Steven Wu
bda9272591
[clang][ScanDeps] Clear compilation directory if needed (#150129)
During explicit module build, clear the compilation directory flags when
CWD optimization is on. Now clang CodeGen will not add compilation
directories to DIFile when the corresponding flags are not passed and
make debug info not dependent on CWD.
2025-08-01 11:01:34 -07:00
Aiden Grossman
4c80193a58 Revert "[clang] Remove %T from tests (#151614)"
This reverts commit 5a586375aa3a128dadc9473cfa196bf8588c2a82.

This breaks two buildbots with failures in
implicit-module-header-maps.cpp. No idea why these failures are
occurring.

https://lab.llvm.org/buildbot/#/builders/64/builds/5166
https://lab.llvm.org/buildbot/#/builders/13/builds/8725
2025-08-01 17:30:24 +00:00
Aaron Ballman
17327482f0
[Analyzer] No longer crash with VLA operands to unary type traits (#151719)
sizeof was handled correctly, but __datasizeof and _Countof were not.

Fixes #151711
2025-08-01 12:31:56 -04:00
Erich Keane
25c07763f7
[OpenACC][CIR] Implement 'private' clause lowering. (#151360)
The private clause is the first with 'recipes', so a lot of
infrastructure is included here, including some MLIR dialect changes
that allow simple adding of a privatization. We'll likely get similar
for firstprivate and reduction.

Also, we have quite a bit of infrastructure in clause lowering to make
sure we have most cases we could think of covered.

At the moment, ONLY private is implemented, so all it requires is an
'init' segment (that doesn't call any copy operations), and potentially
a 'destroy' segment. However, actually calling 'init' functions on each
of the elements in them are not properly implemented, and will be in a
followup patch.

This patch implements all of that, and adds tests in a way that will be
useful for firstprivate as well.
2025-08-01 09:27:15 -07:00
Aiden Grossman
5a586375aa
[clang] Remove %T from tests (#151614)
This patch removes %T from clang lit tests. %T has been deprecated for
about seven years and is not reccomended as it is not unique to each
test, which can lead to races. This patch is intended to remove usage in
tree with the end goal of removing support for %T within lit.
2025-08-01 08:25:14 -07:00