6014 Commits

Author SHA1 Message Date
David Tenty
63195d3d7a
[NFC][CMake] quote ${CMAKE_SYSTEM_NAME} consistently (#154537)
A CMake change included in CMake 4.0 makes `AIX` into a variable
(similar to `APPLE`, etc.)
ff03db6657

However, `${CMAKE_SYSTEM_NAME}` unfortunately also expands exactly to
`AIX` and `if` auto-expands variable names in CMake. That means you get
a double expansion if you write:

`if (${CMAKE_SYSTEM_NAME}  MATCHES "AIX")`
which becomes:
`if (AIX  MATCHES "AIX")`
which is as if you wrote:
`if (ON MATCHES "AIX")`

You can prevent this by quoting the expansion of "${CMAKE_SYSTEM_NAME}",
due to policy
[CMP0054](https://cmake.org/cmake/help/latest/policy/CMP0054.html#policy:CMP0054)
which is on by default in 4.0+. Most of the LLVM CMake already does
this, but this PR fixes the remaining cases where we do not.
2025-08-20 12:45:41 -04:00
Ilya Biryukov
85043c1c14
[Clang] Add a builtin that deduplicate types into a pack (#106730)
The new builtin `__builtin_dedup_pack` removes duplicates from list of
types.

The added builtin is special in that they produce an unexpanded pack
in the spirit of P3115R0 proposal.

Produced packs can be used directly in template argument lists and get
immediately expanded as soon as results of the computation are
available.

It allows to easily combine them, e.g.:

```cpp
template <class ...T>
struct Normalize {
  // Note: sort is not included in this PR, it illustrates the idea.
  using result = std::tuple<
    __builtin_sort_pack<
      __builtin_dedup_pack<int, double, T...>...
    >...>;
}
;
```

Limitations:
- only supported in template arguments and bases,
- can only be used inside the templates, even if non-dependent,
- the builtins cannot be assigned to template template parameters.

The actual implementation proceeds as follows:
- When the compiler encounters a `__builtin_dedup_pack` or other
type-producing
  builtin with dependent arguments, it creates a dependent
  `TemplateSpecializationType`.
- During substitution, if the template arguments are non-dependent, we
  will produce: a new type `SubstBuiltinTemplatePackType`, which stores
  an argument pack that needs to be substituted. This type is similar to
  the existing `SubstTemplateParmPack` in that it carries the argument
  pack that needs to be expanded further. The relevant code is shared.
- On top of that, Clang also wraps the resulting type into
  `TemplateSpecializationType`, but this time only as a sugar.
- To actually expand those packs, we collect the produced
  `SubstBuiltinTemplatePackType` inside `CollectUnexpandedPacks`.
  Because we know the size of the produces packs only after the initial
  substitution, places that do the actual expansion will need to have a
  second run over the substituted type to finalize the expansions (in
  this patch we only support this for template arguments, see
  `ExpandTemplateArgument`).

If the expansion are requested in the places we do not currently
support, we will produce an error.

More follow-up work will be needed to fully shape this:
- adding the builtin that sorts types,
- remove the restrictions for expansions,
- implementing P3115R0 (scheduled for C++29, see
  https://github.com/cplusplus/papers/issues/2300).
2025-08-20 18:11:36 +02:00
erichkeane
d0dc3799b7 [OpenACC][NFCI] Add AST Infrastructure for reduction recipes
This patch does the bare minimum to start setting up the reduction
recipe support, including adding a type to the AST to store it. No real
additional work is done, and a bunch of static_asserts are left around
to allow us to do this properly.
2025-08-19 07:58:11 -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
Joseph Huber
9da4d74a88
[Clang] Always pass detected CUDA path to 'clang-nvlink-wrapper' (#152789)
Summary:
We always want to use the detected path. The clang driver's detection is
far more sophisticated so we should use that whenever possible. Also
update the usage so we properly fall back to path instead of incorrectly
using the `/bin` if not provided.
2025-08-11 07:22:11 -05:00
Matheus Izvekov
91cdd35008
[clang] Improve nested name specifier AST representation (#147835)
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-09 05:06:53 -03:00
erichkeane
b291d02a93 [OpenACC][NFCI] Add extra data to firstprivate recipe AST node
During implementation I found that I need some additional data in the
AST node for codegen, so this patch adds the second declaration
reference.
2025-08-06 10:18:34 -07:00
erichkeane
056608a282 [OpenACC][NFC] Remove temporary assert from CIndex OpenACCBindClause
This was left over from implementation and shouldn't have been left in,
but in the end 'bind' doesn't require any additional work here, so this
patch removes the assert.
2025-08-06 09:05:14 -07:00
Kazu Hirata
cab2edd39a
[libclang] Remove unnecessary casts (NFC) (#152259)
stringVal is already of char *.
2025-08-06 07:10:40 -07:00
Fangrui Song
913c5b4d1f clang -cc1as: Remove a redundant initSections call
`Parser->Run(Opts.NoInitialTextSection)` calls initSections. Remove a
redundant initSections to remove an extra FT_Align fragment, observed
when investigating a missing MCOrgFragment relaxation issue
https://github.com/ClangBuiltLinux/linux/issues/2116
2025-08-05 10:02:53 -07:00
erichkeane
258997c16e [OpenACC][NFCI] Add 'InitRecipes' to 'firstprivate' AST node
This patch adds the 'init recipes' to firstprivate like I did for
'private', so that we can properly init these types.  At the moment,
the recipe init isn't generated (just the VarDecl), and this isn't
really used anywhere as it will be used exclusively in Codegen.
2025-08-05 09:26:47 -07: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
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
Joseph Huber
25c02fbc42
[Clang] Hide offload-arch initialization errors behind verbose flag (#151964)
Summary:
This tool tries to print the offloading architectures. If the user
doesn't have the HIP libraries or the CUDA libraries it will print and
error.
This isn't super helpful since we're just querying things. So, for
example, if we're on an AMD machine with no CUDA you'll get the AMD GPUs
and then an error message saying that CUDA wasn't found. This silences
the error just on failing to find the library unless verbose is on.
2025-08-04 09:31:44 -05:00
James Y Knight
4205da0f13
NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (#151782)
This commit handles the following types:
- clang::ExternalASTSource
- clang::TargetInfo
- clang::ASTContext
- clang::SourceManager
- clang::FileManager

Part of cleanup #151026
2025-08-01 22:23:30 -04:00
James Y Knight
c7f3437507
NFC: Clean up of IntrusiveRefCntPtr construction from raw pointers. (#151545)
Handles clang::DiagnosticsEngine and clang::DiagnosticIDs.

For DiagnosticIDs, this mostly migrates from `new DiagnosticIDs` to
convenience method `DiagnosticIDs::create()`.

Part of cleanup https://github.com/llvm/llvm-project/issues/151026
2025-07-31 15:07:35 -04:00
Daniel Paoliello
4adce336f4
[win][arm64ec] Fixes to unblock building LLVM and Clang as Arm64EC (#150068)
These changes allow LLVM and Clang to be built with Clang targeting
Arm64EC using the MSVC linker.

Built with these options:
```
-DLLVM_ENABLE_PROJECTS="clang"
-DLLVM_HOST_TRIPLE=arm64ec-pc-windows-msvc
-DCMAKE_C_COMPILER=clang-cl.exe
-DCMAKE_C_COMPILER_TARGET=arm64ec-pc-windows-msvc
-DCMAKE_CXX_COMPILER=clang-cl.exe
-DCMAKE_CXX_COMPILER_TARGET=arm64ec-pc-windows-msvc
-DCMAKE_LINKER_TYPE=MSVC
```
2025-07-31 09:30:05 -07:00
James Y Knight
9ddbb478ce
NFC: Clean up construction of IntrusiveRefCntPtr from raw pointers for llvm::vfs::FileSystem. (#151407)
This switches to `makeIntrusiveRefCnt<FileSystem>` where creating a new
object, and to passing/returning by `IntrusiveRefCntPtr<FileSystem>`
instead of `FileSystem*` or `FileSystem&`, when dealing with existing
objects.

Part of cleanup #151026.
2025-07-31 09:57:13 -04:00
Joel E. Denny
74e4a8645d
[LinkerWrapper] Fix -fsave-optimization-record default file (#149003)
As discussed in PR #145603, the following command seems to fail to
produce a YAML remarks file for offload LTO passes and thus for
kernel-info:

```
clang -O2 -g -fopenmp --offload-arch=native test.c -foffload-lto \
  -Rpass=kernel-info -fsave-optimization-record
```

The problem is that, in clang-linker-wrapper's clang call, clang names
the file based on clang's main output file (from `-o`). That is a
temporary file, so the YAML file becomes a temporary file, which the
user never sees.

This patch:
- Makes clang honor `-dumpdir` for the default YAML remarks file in the
case of LTO.
- Extends clang-linker-wrapper to specify that option to clang.

To demonstrate the appeal of the generality of `-dumpdir` (as opposed to
a one-off `-fsave-optimization-record` solution in
clang-linker-wrapper), this patch also fixes `-gsplit-dwarf`. Without
this patch, when using `-gsplit-dwarf` and later debugging using rocgdb,
the dwo directory for offload is a temporary file, so temporary file
cleanup causes rocgdb to lose debug symbols for offload code.

WARNING: The clang driver passes `-dumpdir` to various clang frontend
calls. For LTO, that was previously being ignored, and now it's not.
That changes some auxiliary file names, as revealed by changes in some
existing tests' expected output: `clang/test/Driver/opt-record.c` and
`clang/test/Driver/lto-dwo.c`. Hopefully this change does not introduce
a backward compatibility issue for users.
2025-07-30 10:25:37 -04:00
Ivan Butygin
e68a20e0b7
[mlir] Reland Move InitAll*** implementation into static library (#151150)
Reland https://github.com/llvm/llvm-project/pull/150805

Shared libs build was broken.

Add `${dialect_libs}` and `${conversion_libs}` to
`MLIRRegisterAllExtensions` because it depends on
`registerConvert***ToLLVMInterface` functions.
2025-07-29 18:15:33 +03:00
Mehdi Amini
7057eee481
Revert "[mlir][core] Move InitAll*** implementation into static library." (#151118)
Reverts llvm/llvm-project#150805

Some bots are failing.
2025-07-29 12:26:47 +02:00
Ivan Butygin
ace42cf063
[mlir][core] Move InitAll*** implementation into static library. (#150805)
`InitAll***` functions are used by `opt`-style tools to init all MLIR
dialects/passes/extensions. Currently they are implemeted as inline
functions and include essentially the entire MLIR header tree. Each file
which includes this header (~10 currently) takes 10+ sec and multiple GB
of ram to compile (tested with clang-19), which limits amount of
parallel compiler jobs which can be run. Also, flang just includes this
file into one of its headers.

Move the actual registration code to the static library, so it's
compiled only once.

Discourse thread
https://discourse.llvm.org/t/rfc-moving-initall-implementation-into-static-library/87559
2025-07-29 13:21:52 +03:00
Alan Zhao
92858528c2
[clang][timers][stats] Add a flag to enable timers in the stats file (#149946)
As reported in #138173, enabling `-ftime-report` adds pass timing info
to the stats file if `-stats-file` is specified. This was determined to
be WAI. However, if one intentionally wants to put timer information in
the stats file, using `-ftime-report` may lead to a lot of logspam (that
can't be removed by directing stderr to `/dev/null` as that would also
redirect compiler errors). To address this, this PR adds a flag
`-stats-file-timers` that adds timer data to the stats file without
outputting to stderr.
2025-07-22 18:50:45 -07:00
YexuanXiao
7c402b8b81
Reland [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types (#149613)
The checks for the 'z' and 't' format specifiers added in the original
PR #143653 had some issues and were overly strict, causing some build
failures and were consequently reverted at
4c85bf2fe8.

In the latest commit
27c58629ec,
I relaxed the checks for the 'z' and 't' format specifiers, so warnings
are now only issued when they are used with mismatched types.

The original intent of these checks was to diagnose code that assumes
the underlying type of `size_t` is `unsigned` or `unsigned long`, for
example:

```c
printf("%zu", 1ul); // Not portable, but not an error when size_t is unsigned long
```  

However, it produced a significant number of false positives. This was
partly because Clang does not treat the `typedef` `size_t` and
`__size_t` as having a common "sugar" type, and partly because a large
amount of existing code either assumes `unsigned` (or `unsigned long`)
is `size_t`, or they define the equivalent of size_t in their own way
(such as
sanitizer_internal_defs.h).2e67dcfdcd/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h (L203)
2025-07-19 03:44:14 -03:00
Kazu Hirata
4c85bf2fe8 Revert "[Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (#143653)"
This reverts commit c27e283cfbca2bd22f34592430e98ee76ed60ad8.

A builbot failure has been reported:
https://lab.llvm.org/buildbot/#/builders/186/builds/10819/steps/10/logs/stdio

I'm also getting a large number of warnings related to %zu and %zx.
2025-07-17 21:04:01 -07:00
YexuanXiao
c27e283cfb
[Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (#143653)
Including the results of `sizeof`, `sizeof...`, `__datasizeof`,
`__alignof`, `_Alignof`, `alignof`, `_Countof`, `size_t` literals, and
signed `size_t` literals, the results of pointer-pointer subtraction and
checks for standard library functions (and their calls).

The goal is to enable clang and downstream tools such as clangd and
clang-tidy to provide more portable hints and diagnostics.

The previous discussion can be found at #136542.

This PR implements this feature by introducing a new subtype of `Type`
called `PredefinedSugarType`, which was considered appropriate in
discussions. I tried to keep `PredefinedSugarType` simple enough yet not
limited to `size_t` and `ptrdiff_t` so that it can be used for other
purposes. `PredefinedSugarType` wraps a canonical `Type` and provides a
name, conceptually similar to a compiler internal `TypedefType` but
without depending on a `TypedefDecl` or a source file.

Additionally, checks for the `z` and `t` format specifiers in format
strings for `scanf` and `printf` were added. It will precisely match
expressions using `typedef`s or built-in expressions.

The affected tests indicates that it works very well.

Several code require that `SizeType` is canonical, so I kept `SizeType`
to its canonical form.

The failed tests in CI are allowed to fail. See the
[comment](https://github.com/llvm/llvm-project/pull/135386#issuecomment-3049426611)
in another PR #135386.
2025-07-17 22:45:57 -03:00
Yanzuo Liu
4a9eaad9e1
[Clang][AST][NFC] Introduce NamespaceBaseDecl (#149123)
Add `NamespaceBaseDecl` as common base class of `NamespaceDecl` and
`NamespaceAliasDecl`. This simplifies `NestedNameSpecifier` a bit.

Co-authored-by: Matheus Izvekov <mizvekov@gmail.com>
2025-07-18 09:01:47 +08:00
Sirraide
7e0fde0c2f
[Clang] Reintroduce obsolete symbols in libclang.map (#149190)
This is a follow-up to #149079. Seems like we forgot about the fact that
the symbols also need to be in `libclang.map`.
2025-07-16 19:30:50 -04:00
Sirraide
1600450f90
[Clang] Reintroduce obsolete libclang symbols to avoid an ABI break (#149079)
For more context, see
https://github.com/llvm/llvm-project/pull/119269#issuecomment-3075444493,
but briefly, when removing ARCMigrate, I also removed some symbols in
libclang, which constitutes an ABI break that we don’t want, so this pr
reintroduces the removed symbols; the declarations are marked as
deprecated for future removal, and the implementations print an error
and do nothing, which is what we used to do when ARCMigrate was
disabled.
2025-07-16 15:48:53 +02:00
Eli Friedman
116110e1a9
[libclang] Fix version for symbol clang_visitCXXMethods (#148958)
Happened to spot this while looking at libclang.map for other reasons.
clang_visitCXXMethods was added in LLVM 21, not LLVM 20.
2025-07-15 15:39:51 -07:00
Owen Pan
da283b54d9 Revert "[clang-format] Fix an off-by-1 bug with -length option (#143302)"
This reverts commit 1fae5918b3d6fbed8ce6d8a2edf31bdf304ca8db because it may
break VSCode.

Closes #146036
2025-07-14 22:42:12 -07:00
Cyndy Ishida
15c3793cdf
[clang][scan-deps] Report a scanned TU's visible modules (#147969)
Clients of the dependency scanning service may need to add dependencies
based on the visibility of importing modules, for example, when
determining whether a Swift overlay dependency should be brought in
based on whether there's a corresponding **visible** clang module for
it.
This patch introduces a new field `VisibleModules` that contains all the
visible top-level modules in a given TU.
Because visibility is determined by which headers or (sub)modules were
imported, and not top-level module dependencies, the scanner now
performs a separate DFS starting from what was directly imported for
this computation.

In my local performance testing, there was no observable performance
impact.

resolves: rdar://151416358

---------

Co-authored-by: Jan Svoboda <jan@svoboda.ai>
2025-07-11 09:33:55 -07:00
Joseph Huber
535d6917ec
[Clang] Extract offloading code from static libs with 'offload-arch=' (#147823)
Summary:
The semantics of static libraries only extract stuff that's used. We
somewhat extend this behavior with the linker wrapper only doing this to
fat binaries that match any found architectures. However, this has some
unfortunate effects when the user uses static libraries.

This is somewhat of a hack, but we now assume that if the user specified
`--offload-arch=` on the link job, they *definitely* want that
architecture to be used if it exists. This patch just forces extraction
of those libraries which resolves an issue observed with some customers.

The old behavior will still be present if the user does `--offload-link`
with no offloading architecture present, and for the vast, vast majority
of cases this will change nothing.

Fixes: https://github.com/llvm/llvm-project/issues/147788
2025-07-11 10:26:24 -05:00
darkbuck
378e9bb7e0
[cir-translate] Fix crash issue where the data layout string is missing (#147209)
- Targets like 'aarch64' or 'arm' only populate the data layout string
after the constructor. Need to call 'CreateTargetInfo' to setup them
properly.
2025-07-09 23:26:15 -04:00
Tomohiro Kashiwada
9c4e2dcb56
[libclang][Cygwin] Use LLVM_EXPORTED_SYMBOL_FILE (*.def file) for Cygwin (#147278)
This is not mandatory but recommended for completeness and consistency
with MinGW.
2025-07-09 23:57:12 +03:00
Yaxun (Sam) Liu
beea2a9414
[Clang] Respect MS layout attributes during CUDA/HIP device compilation (#146620)
This patch fixes an issue where Microsoft-specific layout attributes,
such as __declspec(empty_bases), were ignored during CUDA/HIP device
compilation on a Windows host. This caused a critical memory layout
mismatch between host and device objects, breaking libraries that rely
on these attributes for ABI compatibility.

The fix introduces a centralized hasMicrosoftRecordLayout() check within
the TargetInfo class. This check is aware of the auxiliary (host) target
and is set during TargetInfo::adjust if the host uses a Microsoft ABI.

The empty_bases, layout_version, and msvc::no_unique_address attributes
now use this centralized flag, ensuring device code respects them and
maintains layout consistency with the host.

Fixes: https://github.com/llvm/llvm-project/issues/146047
2025-07-09 08:53:10 -04:00
Haojian Wu
b7c4ac2db4 NFC, use structured binding to simplify the code. 2025-07-07 17:07:37 +02:00
Kazu Hirata
a244907922
[clang] Use range-based for loops (NFC) (#146811)
Note that LLVM Coding Standards discourages std::for_each and
llvm::for_each unless the callable object already exists.
2025-07-03 08:36:03 -07:00
Paddy McDonald
4db8ce7251
[clang-fuzzer] Fix latent race condition in build (#146119)
Add explicit dependency for gen_vt to the CMakeLists.txt for
clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp to prevent race
condition on generation of llvm/CodeGen/GenVT.inc This explicit
dependency was added in other CMakeLists.txt when the tablegen was added
for GenVT.inc file in https://reviews.llvm.org/D148770, but not for
handle-llvm

A similar fix was made in
https://github.com/llvm/llvm-project/pull/109306

rdar://151325382
2025-07-02 07:53:33 -07:00
SahilPatidar
3f531552e6
[REAPPLY][Clang-Repl] Add support for out-of-process execution. #110418 (#144064)
This PR introduces out-of-process (OOP) execution support for
Clang-Repl. With this enhancement, two new flags, oop-executor and
oop-executor-connect, are added to the Clang-Repl interface. These flags
enable the launch of an external executor (llvm-jitlink-executor), which
handles code execution in a separate process.
2025-06-28 08:42:59 +03:00
Haojian Wu
0b6ddb02ef
[clang] NFC: Add alias for std::pair<FileID, unsigned> used in SourceLocation (#145711)
Introduce a type alias for the commonly used `std::pair<FileID,
unsigned>` to improve code readability, and make it easier for future
updates (64-bit source locations).
2025-06-26 14:12:51 +02:00
wieDasDing
d76fdf7f53
[clang-c] introduce queries on GCC-style inline assembly statements (#143424)
[Discourse
link](https://discourse.llvm.org/t/a-small-proposal-for-extraction-of-inline-assembly-block-information/86658)

We strive for exposing such information using existing stable ABIs. In
doing so, queries are limited to what the original source holds or the
LLVM IR `asm` block would expose in connection with attributes that the
queries are concerned.

These APIs opens new opportunities for `rust-bindgen` to translate
inline assemblies in reasonably cases into Rust inline assembly blocks,
which would further aid better interoperability with other existing
code.

---------

Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
2025-06-25 10:08:56 -04:00
Naveen Seth Hanig
52fbefb281
[clang][clang-scan-deps] Add named modules to format 'experimental-full' (#145221) 2025-06-24 16:21:19 -07:00
Qinkun Bao
43d042b350
Revert "[clang][scan-deps] Add option to disable caching stat failures" (#145528)
Reverts llvm/llvm-project#144000

First buildbot failure:
https://lab.llvm.org/buildbot/#/builders/164/builds/11064
2025-06-24 11:12:05 -04:00
Miguel Cárdenas
e80acd4fae
[clang][nvlink-wrapper] Add support for opt-remarks command line options (#145365)
## Problem
When using `-fsave-optimization-record` with offloading, the Clang
driver passes optimization record options like
`-plugin-opt=opt-remarks-format=yaml` to `clang-nvlink-wrapper`.
However, the wrapper doesn't recognize these options, causing
compilation to fail.


## Solution
This patch adds support for the standard optimization record command
line options to `clang-nvlink-wrapper`, matching the interface provided
by LLD and gold-plugin as documented in the [LLVM Remarks
documentation](https://llvm.org/docs/Remarks.html).

## Changes
- **NVLinkOpts.td**: Added definitions for `opt-remarks-filename`,
`opt-remarks-format`, `opt-remarks-filter`, and
`opt-remarks-with-hotness` options
- **NVLinkOpts.td**: Added `plugin-opt=` aliases for these options to
match what the Clang driver sends
- **ClangNVLinkWrapper.cpp**: Updated `createLTO()` to use command line
arguments when available, falling back to existing global variables

## Testing
The fix allows `-fsave-optimization-record` to work correctly with
offloading, generating optimization records during the LTO phase without
throwing unknown argument errors.

This change maintains backward compatibility and follows the existing
pattern used by other LLVM linkers.
2025-06-23 13:15:04 -05:00
Michael Spencer
6110dead89
[clang][scan-deps] Add option to disable caching stat failures (#144000)
While the source code isn't supposed to change during a build, in some
environments it does. This adds an option that disables caching of stat
failures, meaning that source files can be added to the build during
scanning.

This adds a `-no-cache-negative-stats` option to clang-scan-deps to
enable this behavior. There are no tests for clang-scan-deps as there's
no reliable way to do so from it. A unit test has been added that
modifies the filesystem between scans to test it.
2025-06-20 13:28:05 -07:00
Joseph Huber
6fb36db481
[LinkerWrapper] Fix 'save-temps' when targeting SPIR-V (#144605)
Summary:
The logic here is flawed, it was only intended to apply to the CPU case
where we use the linker passed in on the command line. This was falsely
applying to SPIR-V which caused issues.
2025-06-17 16:16:37 -05:00
Aaron Ballman
9eef4d1c5f
Remove delayed typo expressions (#143423)
This removes the delayed typo correction functionality from Clang
(regular typo correction still remains) due to fragility of the
solution.

An RFC was posted here:
https://discourse.llvm.org/t/rfc-removing-support-for-delayed-typo-correction/86631
and while that RFC was asking for folks to consider stepping up to be
maintainers, and we did have a few new contributors show some interest,
experiments show that it's likely worth it to remove this functionality
entirely and focus efforts on improving regular typo correction.

This removal fixes ~20 open issues (quite possibly more), improves
compile time performance by roughly .3-.4%
(https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=AaronBallman&sortBy=date),
and does not appear to regress diagnostic behavior in a way we wouldn't
find acceptable.

Fixes #142457
Fixes #139913
Fixes #138850
Fixes #137867
Fixes #137860
Fixes #107840
Fixes #93308
Fixes #69470
Fixes #59391
Fixes #58172
Fixes #46215
Fixes #45915
Fixes #45891
Fixes #44490
Fixes #36703
Fixes #32903
Fixes #23312
Fixes #69874
2025-06-13 06:45:40 -04:00
Owen Pan
1fae5918b3
[clang-format] Fix an off-by-1 bug with -length option (#143302)
Also validate the argument value.

Fixes #56245
2025-06-13 00:45:52 -07:00
Yaxun (Sam) Liu
7232c07eb9 Reland [HIP] use offload wrapper for non-device-only non-rdc (#143964)
Fixed a typo:

-  auto Section = (Prefix + "llvm_offload_entries").str();
+  auto Section = (Prefix + "_offload_entries").str();

which broke buildbot e.g.

https://lab.llvm.org/buildbot/#/builders/208/builds/1948
2025-06-12 21:41:41 -04:00