Compare commits

...

739 Commits

Author SHA1 Message Date
Simon Pilgrim
2a79ef66eb
[AMDGPU] canCreateUndefOrPoisonForTargetNode - BFE_I32/U32 can't create poison/undef (#154932)
Add AMDGPUTargetLowering::canCreateUndefOrPoisonForTargetNode handler
and tag BFE_I32/U32 nodes as they can only propagate poison, not create
poison/undef.

Fighting some of the remaining regressions in #152107
2025-08-22 12:14:45 +00:00
Jungwook Park
b149fc7755
[mlir][scf] Quick fix to scf.execute_region no_inline (#154931)
Asm printer should exclude `no_inline` attr during printing optional
attrs at the bottom.
2025-08-22 13:11:27 +01:00
Michael Halkenhäuser
7c1d2467f1
Reland: [OpenMP] Add ompTest library to OpenMP (#154786)
Reland of https://github.com/llvm/llvm-project/pull/147381

Added changes to fix observed BuildBot failures:
 * CMake version (reduced minimum to `3.20`, was: `3.22`)
 * GoogleTest linking (missing `./build/lib/libllvm_gtest.a`)
* Related header issue (missing `#include
"llvm/Support/raw_os_ostream.h"`)

Original message

Description
===========
OpenMP Tooling Interface Testing Library (ompTest) ompTest is a unit testing framework for testing OpenMP implementations. It offers a simple-to-use framework that allows a tester to check for OMPT events in addition to regular unit testing code, supported by linking against GoogleTest by default. It also facilitates writing concise tests while bridging the semantic gap between the unit under test and the OMPT-event testing.

Background
==========
This library has been developed to provide the means of testing OMPT implementations with reasonable effort. Especially, asynchronous or unordered events are supported and can be verified with ease, which may prove to be challenging with LIT-based tests. Additionally, since the assertions are part of the code being tested, ompTest can reference all corresponding variables during assertion.

Basic Usage
===========
OMPT event assertions are placed before the code, which shall be tested. These assertion can either be provided as one block or interleaved with the test code. There are two types of asserters: (1) sequenced "order-sensitive" and (2) set "unordered" assserters. Once the test is being run, the corresponding events are triggered by the OpenMP runtime and can be observed. Each of these observed events notifies asserters, which then determine if the test should pass or fail.

Example (partial, interleaved)
==============================
```c++
  int N = 100000;
  int a[N];
  int b[N];

  OMPT_ASSERT_SEQUENCE(Target, TARGET, BEGIN, 0);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, ALLOC, N * sizeof(int)); // a ?
  OMPT_ASSERT_SEQUENCE(TargetDataOp, H2D, N * sizeof(int), &a);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, ALLOC, N * sizeof(int)); // b ?
  OMPT_ASSERT_SEQUENCE(TargetDataOp, H2D, N * sizeof(int), &b);
  OMPT_ASSERT_SEQUENCE(TargetSubmit, 1);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, D2H, N * sizeof(int), nullptr, &b);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, D2H, N * sizeof(int), nullptr, &a);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, DELETE);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, DELETE);
  OMPT_ASSERT_SEQUENCE(Target, TARGET, END, 0);

#pragma omp target parallel for
  {
    for (int j = 0; j < N; j++)
      a[j] = b[j];
  }
```

References
==========
This work has been presented at SC'24 workshops, see: https://ieeexplore.ieee.org/document/10820689

Current State and Future Work
=============================
ompTest's development was mostly device-centric and aimed at OMPT device callbacks and device-side tracing. Consequentially, a substantial part of host-related events or features may not be supported in its current state. However, we are confident that the related functionality can be added and ompTest provides a general foundation for future OpenMP and especially OMPT testing. This PR will allow us to upstream the corresponding features, like OMPT device-side tracing in the future with significantly reduced risk of introducing regressions in the process.

Build
=====
ompTest is linked against LLVM's GoogleTest by default, but can also be built 'standalone'. Additionally, it comes with a set of unit tests, which in turn require GoogleTest (overriding a standalone build). The unit tests are added to the `check-openmp` target.

Use the following parameters to perform the corresponding build: 
`LIBOMPTEST_BUILD_STANDALONE` (Default: ${OPENMP_STANDALONE_BUILD})
`LIBOMPTEST_BUILD_UNITTESTS` (Default: OFF)

---------

Co-authored-by: Jan-Patrick Lehr <JanPatrick.Lehr@amd.com>
Co-authored-by: Joachim <protze@rz.rwth-aachen.de>
Co-authored-by: Joachim Jenke <jenke@itc.rwth-aachen.de>
2025-08-22 13:56:12 +02:00
Leandro Lacerda
15a192cde5
[libc] Enable double math functions on the GPU (#154857)
This patch adds the `acos` math function to the NVPTX build. It also
adds the `sincos` math function to the `math.h` header.
2025-08-22 06:52:13 -05:00
paperchalice
2014890c09
[SelectionDAG] Remove UnsafeFPMath in visitFP_ROUND (#154768)
Remove `UnsafeFPMath` in `visitFP_ROUND` part, it blocks some bugfixes
related to clang and the ultimate goal is to remove `resetTargetOptions`
method in `TargetMachine`, see FIXME in `resetTargetOptions`.
See also
https://discourse.llvm.org/t/rfc-honor-pragmas-with-ffp-contract-fast

https://discourse.llvm.org/t/allowfpopfusion-vs-sdnodeflags-hasallowcontract

Now all UnsafeFPMath uses are eliminated in LLVMCodeGen
2025-08-22 19:46:33 +08:00
Simon Pilgrim
d8769bb5b7 [AMDGPU] bf16-conversions.ll - regenerate checks
Reduce diffs in #152107
2025-08-22 12:20:50 +01:00
Lang Hames
3292edb7b4
[orc-rt] Add C and C++ APIs for WrapperFunctionResult. (#154927)
orc_rt_WrapperFunctionResult is a byte-buffer with inline storage and a
builtin error state. It is intended as a general purpose return type for
functions that return a serialized result (e.g. for communication across
ABIs or via IPC/RPC).

orc_rt_WrapperFunctionResult contains a small amount of inline storage,
allowing it to avoid heap-allocation for small return types (e.g. bools,
chars, pointers).
2025-08-22 21:18:30 +10:00
Mehdi Amini
d2b810e24f [MLIR] Apply clang-tidy fixes for readability-identifier-naming in DataFlowFramework.cpp (NFC) 2025-08-22 04:12:50 -07:00
Mehdi Amini
a8aacb1b66 [MLIR] Apply clang-tidy fixes for misc-use-internal-linkage in toy Tutorial (NFC) 2025-08-22 04:12:50 -07:00
Mehdi Amini
d2dee948a4 [MLIR] Improve clang-tidy script
This just helping to better keep track of the failures.
2025-08-22 04:12:50 -07:00
Jacek Caban
a6fcd1a663
[LLD][COFF] Set isUsedInRegularObj for target symbols in resolveAlternateNames (#154837)
Fixes: #154595

Prior to commit bbc8346e6bb543b0a87f52114fed7d766446bee1, this flag was
set by `insert()` from `addUndefined()`. Set it explicitly now.
2025-08-22 13:05:19 +02:00
Ramkumar Ramachandra
2975e674ec
[VPlan] Improve style in match_combine_or (NFC) (#154793) 2025-08-22 12:01:42 +01:00
Hans Wennborg
ee5367bedb Revert "[compiler-rt]: fix CodeQL format-string warnings via explicit casts (#153843)"
It broke the build:

compiler-rt/lib/hwasan/hwasan_thread.cpp:177:11: error: unknown type name 'ssize_t'; did you mean 'size_t'?
   177 |          (ssize_t)unique_id_, (void *)this, (void *)stack_bottom(),
       |           ^~~~~~~
       |           size_t

> This change addresses CodeQL format-string warnings across multiple
> sanitizer libraries by adding explicit casts to ensure that printf-style
> format specifiers match the actual argument types.
>
> Key updates:
> - Cast pointer arguments to (void*) when used with %p.
> - Use appropriate integer types and specifiers (e.g., size_t -> %zu,
> ssize_t -> %zd) to avoid mismatches.
> - Fix format specifier mismatches across xray, memprof, lsan, hwasan,
> dfsan.
>
> These changes are no-ops at runtime but improve type safety, silence
> static analysis warnings, and reduce the risk of UB in variadic calls.

This reverts commit d3d5751a39452327690b4e011a23de8327f02e86.
2025-08-22 12:50:53 +02:00
Lang Hames
d5af08a221
[orc-rt] Add inline specifier to orc_rt::make_error. (#154922)
Prevents linker errors for duplicate definitions when make_error is used
from more than one file.
2025-08-22 20:37:10 +10:00
nerix
d6fcaef281
[LLDB][Value] Require type size when reading a scalar (#153386)
When reading a value as a scalar, the type size is required. It's
returned as a `std::optional`. This optional isn't checked for scalar
values, where it is unconditionally accessed.

This came up in the
[Shell/Process/Windows/msstl_smoke.cpp](4e10b62442/lldb/test/Shell/Process/Windows/msstl_smoke.cpp)
test. There, LLDB breaks at the function entry, so all locals aren't
initialized yet. Most values will contain garbage. The [`std::list`
synthetic
provider](4e10b62442/lldb/source/Plugins/Language/CPlusPlus/GenericList.cpp (L517))
tries to read the value using `GetData`. However, in
[`ValueObject::GetData`](4e10b62442/lldb/source/ValueObject/ValueObject.cpp (L766)),
[`ValueObjectChild::UpdateValue`](88c993fbc5/lldb/source/ValueObject/ValueObjectChild.cpp (L102))
fails because the parent already failed to read its data, so `m_value`
won't have a compiler type, thus the size can't be read.
2025-08-22 12:26:03 +02:00
Ross Brunton
17dbb92612
[Offload][NFC] Use tablegen names rather than name parameter for API (#154736) 2025-08-22 11:13:57 +01:00
tangaac
8439777131
[LoongArch] Pre-commit tests for vecreduce_and/or/... (#154879) 2025-08-22 17:52:43 +08:00
YafetBeyene
fda24dbc16
[BOLT] Add dump-dot-func option for selective function CFG dumping (#153007)
## Change:
* Added `--dump-dot-func` command-line option that allows users to dump
CFGs only for specific functions instead of dumping all functions (the
current only available option being `--dump-dot-all`)

## Usage:
* Users can now specify function names or regex patterns (e.g.,
`--dump-dot-func=main,helper` or `--dump-dot-func="init.*`") to generate
.dot files only for functions of interest
* Aims to save time when analysing specific functions in large binaries
(e.g., only dumping graphs for performance-critical functions identified
through profiling) and we can now avoid reduce output clutter from
generating thousands of unnecessary .dot files when analysing large
binaries

## Testing
The introduced test `dump-dot-func.test` confirms the new option does
the following:

- [x] 1. `dump-dot-func` can correctly filter a specified functions
- [x] 2. Can achieve the above with regexes
- [x] 3. Can do 1. with a list of functions
- [x] No option specified creates no dot files
- [x] Passing in a non-existent function generates no dumping messages
- [x] `dump-dot-all` continues to work as expected
2025-08-22 10:51:09 +01:00
Ivan Kosarev
7594b4b8d1 [AMDGPU] Fix compilation errors. 2025-08-22 10:30:43 +01:00
Abhinav Garg
bfc16510c7
[AMDGPU] Regenerate test case to cover gfx10 check lines. (#154909)
Check lines for GFX10 is missing in this test case. Regenerate to fix
test case.
2025-08-22 15:00:28 +05:30
Nikolas Klauser
fd52f4d232
[libc++][NFC] Simplify the special member functions of the node containers (#154707)
This patch does two things:
- Remove exception specifications of `= default`ed special member
functions
- `= default` special member functions

The first part is NFC because the explicit specification does exactly
the same as the implicit specification. The second is NFC because it
does exactly what the `= default`ed special member does.
2025-08-22 11:24:28 +02:00
Florian Hahn
8bc038daf2
[InstComb] Allow more user for (add (ptrtoint %B), %O) to GEP transform. (#153566)
Generalize the logic from
https://github.com/llvm/llvm-project/pull/153421 to support additional
cases where the pointer is only used as integer.

Alive2 Proof: https://alive2.llvm.org/ce/z/po58pP

This enables vectorizing std::find for some cases, if additional
assumptions are provided: https://godbolt.org/z/94oq3576E

Depends on https://github.com/llvm/llvm-project/pull/15342.

PR: https://github.com/llvm/llvm-project/pull/153566
2025-08-22 10:17:12 +01:00
Ivan Kosarev
faca8c9ed4
[AMDGPU][NFC] Only include CodeGenPassBuilder.h where needed. (#154769)
Saves around 125-210 MB of compilation memory usage per source for
roughly one third of our backend sources, ~60 MB on average.
2025-08-22 10:05:06 +01:00
Simon Pilgrim
1b4fe26343
[clang][x86] Add release note entries describing recent work to making SSE intrinsics generic and usable with constexpr (#154737)
I haven't created an exhaustive list of intrinsic changes, but I suppose I could if people see a strong need for it.
2025-08-22 09:59:10 +01:00
Baranov Victor
00a405f666
[clang-tidy][NFC] Fix "llvm-prefer-static-over-anonymous-namespace" warnings 1/N (#153885) 2025-08-22 11:54:17 +03:00
Hans Wennborg
8bf105cb01
[asan] Build the Windows runtime with /hotpatch (#154694)
Win/ASan relies on the runtime's functions being 16-byte aligned so it
can intercept them with hotpatching. This used to be true (but not
guaranteed) until #149444.

Passing /hotpatch will give us enough alignment and generally ensure
that the functions are hotpatchable.
2025-08-22 10:40:04 +02:00
Bjorn Pettersson
2d3167f8d8
[SeparateConstOffsetFromGEP] Avoid miscompiles related to trunc nuw/nsw (#154582)
Drop poison generating flags on trunc when distributing trunc over
add/sub/or. We need to do this since for example
(add (trunc nuw A), (trunc nuw B)) is more poisonous than
(trunc nuw (add A, B))).

In some situations it is pessimistic to drop the flags. Such as
if the add in the example above also has the nuw flag. For now we
keep it simple and always drop the flags.

Worth mentioning is that we drop the flags when cloning
instructions and rebuilding the chain. This is done after the
"allowsPreservingNUW" checks in ConstantOffsetExtractor::Extract.
So we still take the "trunc nuw" into consideration when determining
if nuw can be preserved in the gep (which should be ok since that
check also require that all the involved binary operations has nuw).

Fixes #154116
2025-08-22 10:27:57 +02:00
Bjorn Pettersson
4ff7ac2330
[SeparateConstOffsetFromGEP] Add test case with trunc nuw/nsw showing miscompile
Pre commit a test case for issue #154116. When redistributing
trunc over add/sub/or we may need to drop poison generating flags
from the trunc.
2025-08-22 10:26:09 +02:00
Simon Pilgrim
8d7df8bba1
[X86] Allow AVX2 per-element shift intrinsics to be used in constexpr (#154780)
This handles constant folding for the AVX2 per-element shift intrinsics, which handle out of bounds shift amounts (logical result = 0, arithmetic result = signbit splat)

AVX512 intrinsics will follow in follow up patches

First stage of #154287
2025-08-22 09:24:24 +01:00
Pierre van Houtryve
4ab5efd48d
[AMDGPU][gfx1250] Add memory legalizer tests (NFC) (#154725) 2025-08-22 10:14:09 +02:00
Fangrui Song
f1aee598e7 ARM: Remove unneeded ARM::fixup_arm_thumb_bl special case
This is a weird special case added in 2015, simplifying an even older
condition. It is a no-op for ELF (isExternal is always false) and seems
unneeded for non-ELF.
2025-08-22 01:08:33 -07:00
LLVM GN Syncbot
2a59400003 [gn build] Port 2b8e80694263 2025-08-22 08:03:17 +00:00
Muhammad Omair Javaid
2b8e806942 Revert "[lldb-dap] Add module symbol table viewer to VS Code extension #140626 (#153836)"
This reverts commit 8b64cd8be29da9ea74db5a1a21f7cd6e75f9e9d8.

This breaks lldb-aarch64-* bots causing a crash in lldb-dap while
running test TestDAP_moduleSymbols.py

https://lab.llvm.org/buildbot/#/builders/59/builds/22959
https://lab.llvm.org/buildbot/#/builders/141/builds/10975
2025-08-22 13:02:52 +05:00
Zhaoxin Yang
149d9a38e1
[ELF][LoongArch] -r: Synthesize R_LARCH_ALIGN at input section start (#153935)
Similay to

94655dc8ae

The difference is that in LoongArch, the ALIGN is synthesized when the
alignment is >4, (instead of >=4), and the number of bytes inserted is
`sec->addralign - 4`.
2025-08-22 16:02:41 +08:00
Connector Switch
6560adb584
[flang] optimize atand/atan2d precision (#154544)
Part of https://github.com/llvm/llvm-project/issues/150452.
2025-08-22 15:55:46 +08:00
Matt Arsenault
2b46f31ee3
AMDGPU: Sign extend immediates for 32-bit subregister extracts (#154870)
extractSubregFromImm previously would sign extend the 16-bit subregister
extracts, but not the 32-bit. We try to consistently store immediates
as sign extended, since not doing it can result in misreported
isInlineImmediate checks.
2025-08-22 16:50:36 +09:00
Stanislav Mekhanoshin
e0945dfa30
[AMDGPU] Add test to show failure with SRC_*_HI registers. NFC. (#154828)
Since src_{private|shared}_{base|limit} registers are added and
are not artifical compiler happily uses it when it can. In HW
these registers do not exist and the encoding belongs to their
64-bit super-register or 32-bit low register. Same instructions
will produce relocation if run through asm.
2025-08-22 00:50:25 -07:00
Jay Foad
cf5243619a
[AMDGPU] Common up two local memory size calculations. NFCI. (#154784) 2025-08-22 08:44:11 +01:00
serge-sans-paille
50f7c6a5b9
Default to GLIBCXX_USE_CXX11_ABI=ON
Because many of our bots actually don't run a listdc++ compatible with
_GLIBCXX_USE_CXX11_ABI=0. See
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html for
details.

This is a follow-up to be179d069664ce03c485e49fa1f6e2ca3d6286fa related
to #154447.
2025-08-22 09:35:40 +02:00
paperchalice
945a186089
[DAGCombiner] Remove most UnsafeFPMath references (#146295)
This pull request removes all references to `UnsafeFPMath` in dag
combiner except FP_ROUND.
- Set fast math flags in some tests.
2025-08-22 15:27:25 +08:00
Fangrui Song
06ab660911 MCSymbol: Avoid isExported/setExported
The next change will move these methods from the base class.
2025-08-22 00:25:55 -07:00
Durgadoss R
36dc6146b8
[MLIR][NVVM] Update TMA tensor prefetch Op (#153464)
This patch updates the TMA Tensor prefetch Op
to add support for im2col_w/w128 and tile_gather4 modes.
This completes support for all modes available in Blackwell.
* lit tests are added for all possible combinations.
* The invalid tests are moved to a separate file with more coverage.

Signed-off-by: Durgadoss R <durgadossr@nvidia.com>
2025-08-22 12:51:29 +05:30
Djordje Todorovic
5050da7ba1
[RISCV] Add initial assembler/MC layer support for big-endian (#146534)
This patch adds basic assembler and MC layer infrastructure for
RISC-V big-endian targets (riscv32be/riscv64be):
      - Register big-endian targets in RISCVTargetMachine
      - Add big-endian data layout strings
      - Implement endianness-aware fixup application in assembler
        backend
      - Add byte swapping for data fixups on BE cores
      - Update MC layer components (AsmInfo, MCTargetDesc, Disassembler,
        AsmParser)
    
This provides the foundation for BE support but does not yet include:
      - Codegen patterns for BE
      - Load/store instruction handling
      - BE-specific subtarget features
2025-08-22 09:21:10 +02:00
Jason Molenda
a2f542b7a5
[lldb][debugserver] update --help to list all the options (#154853)
These are almost all for internal-developer-users only so "look at
debugserver.cpp" wasn't unreasonable, but we rarely add any new options
so a simple list of all recognized options isn't a burden to throw in
the help method.
2025-08-22 00:05:13 -07:00
Fangrui Song
04a3dd5a19 MCSymbol: Avoid isExported/setExported
The next change will move it to MCSymbol{COFF,MachO,Wasm} to make it
clear that other object file formats (e.g. ELF) do not use this field.
2025-08-22 00:00:29 -07:00
Fangrui Song
1def457228 MC: Avoid MCSymbol::isExported
This bit is only used by COFF/MachO. The upcoming change will move
isExported/setExported to MCSymbolCOFF/MCSymbolMachO.
2025-08-21 23:26:53 -07:00
Amit Kumar Pandey
d3d5751a39
[compiler-rt]: fix CodeQL format-string warnings via explicit casts (#153843)
This change addresses CodeQL format-string warnings across multiple
sanitizer libraries by adding explicit casts to ensure that printf-style
format specifiers match the actual argument types.

Key updates:
- Cast pointer arguments to (void*) when used with %p.
- Use appropriate integer types and specifiers (e.g., size_t -> %zu,
ssize_t -> %zd) to avoid mismatches.
- Fix format specifier mismatches across xray, memprof, lsan, hwasan,
dfsan.

These changes are no-ops at runtime but improve type safety, silence
static analysis warnings, and reduce the risk of UB in variadic calls.
2025-08-22 11:51:13 +05:30
Med Ismail Bennani
595148ab76
[lldb/crashlog] Avoid StopAtEntry when launch crashlog in interactive mode (#154651)
In 88f409194, we changed the way the crashlog scripted process was
launched since the previous approach required to parse the file twice,
by stopping at entry, setting the crashlog object in the middle of the
scripted process launch and resuming it.

Since then, we've introduced SBScriptObject which allows to pass any
arbitrary python object accross the SBAPI boundary to another scripted
affordance.

This patch make sure of that to include the parse crashlog object into
the scripted process launch info dictionary, which eliviates the need to
stop at entry.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-08-21 23:16:45 -07:00
Brad Smith
0fff460592
[Driver] DragonFly does not support C11 threads (#154886) 2025-08-22 02:02:52 -04:00
Rajat Bajpai
b08b219650
[MLIR][NVVM] Add "blocksareclusters" kernel attribute support (#154519)
This change adds "nvvm.blocksareclusters" kernel attribute support in NVVM Dialect/MLIR.
2025-08-22 11:32:21 +05:30
Mike Hommey
be179d0696
Be explicit about what libstdc++ C++11 ABI to use (#154447)
libstdc++ can be configured to default to a different C++11 ABI, and
when the system that is used to build clang has a different default than
the system used to build a clang plugin, that leads to uses of different
ABIs, leading to breakage (missing symbols) when using clang APIs that
use types like std::string.

We arbitrarily choose to default to the old ABI, but the user can opt-in
to the new ABI. The important part is that whichever is picked is
reflected in llvm-config's output.
2025-08-22 05:55:42 +00:00
Craig Topper
dee25a8a8e
[TableGen] Validate the shift amount for !srl, !shl, and !sra operators. (#132492)
The C operator has undefined behavior for out of bounds shifts so we
should check this.
2025-08-21 22:41:36 -07:00
Frederik Harwath
d6fae7f921
Reapply "[Clang] Take libstdc++ into account during GCC detection" #145056 (#154487)
The Generic_GCC::GCCInstallationDetector class picks the GCC installation directory with the largest version number. Since the location of the libstdc++ include directories is tied to the GCC version, this can break C++ compilation if the libstdc++ headers for this particular GCC version are not available. Linux distributions tend to package the libstdc++ headers separately from GCC. This frequently leads to situations in which a newer version of GCC gets installed as a dependency of another package without installing the corresponding libstdc++ package. Clang then fails to compile C++ code because it cannot find the libstdc++ headers. Since libstdc++ headers are in fact installed on the system, the GCC installation continues to work, the user may not be aware of the details of the GCC detection, and the compiler does not recognize the situation and emit a warning, this behavior can be hard to understand - as witnessed by many related bug reports over the years.

The goal of this work is to change the GCC detection to prefer GCC installations that contain libstdc++ include directories over those which do not. This should happen regardless of the input language since picking different GCC installations for a build that mixes C and C++ might lead to incompatibilities.
Any change to the GCC installation detection will probably have a negative impact on some users. For instance, for a C user who relies on using the GCC installation with the largest version number, it might become necessary to use the --gcc-install-dir option to ensure that this GCC version is selected.
This seems like an acceptable trade-off given that the situation for users who do not have any special demands on the particular GCC installation directory would be improved significantly.
 
This patch does not yet change the automatic GCC installation directory choice. Instead, it does introduce a warning that informs the user about the future change if the chosen GCC installation directory differs from the one that would be chosen if the libstdc++ headers are taken into account.

See also this related Discourse discussion: https://discourse.llvm.org/t/rfc-take-libstdc-into-account-during-gcc-detection/86992.

This patch reapplies #145056. The test in the original PR did not specify a target in the clang RUN line and used a wrong way of piping to FileCheck.
2025-08-22 07:39:11 +02:00
Craig Topper
630712f4c1
[RISCV] Add a helper class to reduce PseudoAtomicLoadNand* pattern duplication. NFC (#154838) 2025-08-21 22:35:28 -07:00
Matt Arsenault
b1b5102624
AMDGPU: Start considering new atomicrmw metadata on integer operations (#122138)
Start considering !amdgpu.no.remote.memory.access and
!amdgpu.no.fine.grained.host.memory metadata when deciding to expand
integer atomic operations. This does not yet attempt to accurately
handle fadd/fmin/fmax, which are trickier and require migrating the
old "amdgpu-unsafe-fp-atomics" attribute.
2025-08-22 05:29:36 +00:00
Lang Hames
c1625fad02
[orc-rt] Rename unique_function to move_only_function. (#154888)
This will allow the ORC runtime and its clients to easily adopt the
c++-23 std::move_only_function type.
2025-08-22 15:26:10 +10:00
Craig Topper
c346f4079a
[RISCV] Use llvm_anyint_ty instead of llvm_any_ty for scalar intrinsics. NFC (#154816) 2025-08-21 22:18:39 -07:00
Matt Arsenault
fc5fcc0c95
AMDGPU: Start using AV_MOV_B64_IMM_PSEUDO (#154500) 2025-08-22 13:59:36 +09:00
Matt Arsenault
01f785cac4
AMDGPU: Expand remaining system atomic operations (#122137)
System scope atomics need to use cmpxchg loops if we know
nothing about the allocation the address is from.
aea5980e26e6a87dab9f8acb10eb3a59dd143cb1 started this, this
expands the set to cover the remaining integer operations.

Don't expand xchg and add, those theoretically should work over PCIe.
This is a pre-commit which will introduce performance regressions.
Subsequent changes will add handling of new atomicrmw metadata, which
will avoid the expansion.

Note this still isn't conservative enough; we do need to expand
some device scope atomics if the memory is in fine-grained remote
memory.
2025-08-22 13:55:04 +09:00
Sergei Barannikov
6a7ade03d1
[TableGen][DecoderEmitter] Remove redundant variable (NFC) (#154880)
`NumFiltered` is the number of elements in all vectors in a map.
It is ever compared to 1, which is equivalent to checking if the map
contains exactly one vector with exactly one element.
2025-08-22 04:42:06 +00:00
Craig Topper
586a7131d3
[RISCV][LoongArch] Prefix tablegen class names for intrinsics with 'RISCV'. NFC (#154821)
All targets are included by Intrinsics.td so we should name things
carefully to avoid interfering with other targets.

Copy one class that LoongArch was also using.
2025-08-21 21:40:35 -07:00
Jordan Rupprecht
49d4712129
[bazel] Port #154774: unroll vector.from_elements (#154882) 2025-08-22 04:33:50 +00:00
Lang Hames
6df9a13e40
[orc-rt] Use LLVM-style header naming scheme. (#154881)
This is more consistent with the rest of the LLVM project, and the
resulting names are closer to the types defined in each of the headers.
2025-08-22 14:28:02 +10:00
dpalermo
d26ea02060
Revert "Fix Debug Build Using GCC 15" (#154877)
Reverts llvm/llvm-project#152223
2025-08-21 21:54:58 -05:00
Yang Bai
f1f194bf10
[mlir][vector] fix: unroll vector.from_elements in gpu pipelines (#154774)
### Problem

PR #142944 introduced a new canonicalization pattern which caused
failures in the following GPU-related integration tests:

-
mlir/test/Integration/GPU/CUDA/TensorCore/sm80/transform-mma-sync-matmul-f16-f16-accum.mlir
-
mlir/test/Integration/GPU/CUDA/TensorCore/sm80/transform-mma-sync-matmul-f32.mlir

The issue occurs because the new canonicalization pattern can generate
multi-dimensional `vector.from_elements` operations (rank > 1), but the
GPU lowering pipelines were not equipped to handle these during the
conversion to LLVM.

### Fix

This PR adds `vector::populateVectorFromElementsLoweringPatterns` to the
GPU lowering passes that are integrated in `gpu-lower-to-nvvm-pipeline`:

- `GpuToLLVMConversionPass`: the general GPU-to-LLVM conversion pass.
- `LowerGpuOpsToNVVMOpsPass`: the NVVM-specific lowering pass.

Co-authored-by: Yang Bai <yangb@nvidia.com>
2025-08-21 21:46:06 -05:00
Sergei Barannikov
418fb50301
[TableGen][DecoderEmitter] Calculate encoding bits once (#154026)
Parse the `Inst` and `SoftField` fields once and store them in
`InstructionEncoding` so that we don't parse them every time
`getMandatoryEncodingBits()` is called.
2025-08-22 05:19:35 +03:00
Lang Hames
273b6f2911
[orc-rt] Add orc_rt::unique_function. (#154874)
A bare-bones version of LLVM's unique_function: this behaves like a
std::unique_function, except that it supports move only callable types.
2025-08-22 12:19:15 +10:00
Muhammad Bassiouni
4d323206ed
[libc][math] Refactor cospif16 implementation to header-only in src/__support/math folder. (#154222)
Part of #147386

in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-08-22 05:04:13 +03:00
Lang Hames
3ce25abd4a
[orc-rt] Add error.h: structured error support. (#154869)
Adds support for the Error class, Expected class template, and related
APIs that will be used for error propagation and handling in the new ORC
runtime.

The implementations of these types are cut-down versions of similar APIs
in llvm/Support/Error.h. Most advice on llvm::Error and llvm::Expected
(e.g. from the LLVM Programmer's manual) applies equally to
orc_rt::Error and orc_rt::Expected.

Ported from the old ORC runtime at compiler-rt/lib/orc.
2025-08-22 11:53:47 +10:00
Muhammad Bassiouni
783859b2a0
[libc][math] Refactor cospif implementation to header-only in src/__support/math folder. (#154215)
Part of #147386

in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-08-22 04:53:18 +03:00
Aiden Grossman
9d2a66fb32 [Clang] Slightly clean up __cpuidex_conflict.c
This was intended to be fixed in #154217, but given that didn't land, it
still needs to be done. I think it still makes sense to have this change
in.
2025-08-22 01:37:17 +00:00
Anthony Latsis
0bc02096f6
[clang] Upstream clang::CodeGen::getConstantSignedPointer (#154453)
This function was introduced to Swift's fork in

https://github.com/swiftlang/llvm-project/commit/a9dd959e60c32#diff-db27b2738ad84e3f1093f9174710710478f853804d995a6de2816d1caaad30d1.

The Swift compiler cannot use `CodeGenModule::getConstantSignedPointer`,
to which it forwards, because that is a private interface.
2025-08-21 17:55:57 -07:00
Craig Topper
6167b1e6e9
[TableGen] Remove unnecessary use of utostr when writing to raw_ostream. NFC (#154800)
raw_ostream is capable of printing unsigned or uint64_t directly.
2025-08-21 17:44:53 -07:00
Sergei Barannikov
b3f04bf44c [M68k] Rename a generated file to be consistent with other targets (NFC) 2025-08-22 03:38:30 +03:00
Rahul Joshi
4eeeb8a01e
[NFC][MC][Decoder] Fix off-by-one indentation in generated code (#154855) 2025-08-21 17:20:05 -07:00
Luke Lau
c97c6869b6
[VPlan] Allow folding not (cmp eq) -> icmp ne with other select users (#154497)
Currently we only allow folding not (cmp eq) -> icmp ne if the not is
the only user of the compare.
However a common scenario is that some select might also use the
compare. We can still fold the not if we also swizzle the arms of the
selects.

This helps avoid regressions in #150368
2025-08-22 07:59:14 +08:00
Wenju He
e6d095e89c
[libclc] Only create a target per each compile command for cmake MSVC generator (#154479)
libclc sequential build issue addressed in commit 0c21d6b4c8ad is
specific to cmake MSVC generator. Therefore, this PR avoids creating a
large number of targets when a non-MSVC generator is used, such as the
Ninja generator, which is used in pre-merge CI on Windows in
llvm-project repo. We plan to migrate from MSVC generator to Ninja
generator in our downstream CI to fix flaky cmake bug `Cannot restore
timestamp`, which might be related to the large number of targets.
2025-08-22 07:45:42 +08:00
Med Ismail Bennani
05b1ec3724
[lldb/API] Add setters to SBStructuredData (#154445)
This patch adds setters to the SBStruturedData class to be able to
initialize said object from the client side directly.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
2025-08-21 16:40:01 -07:00
Peter Collingbourne
ff85dbdf6b
ThinLTOBitcodeWriter: Emit __cfi_check to full LTO part of bitcode file.
The CrossDSOCFI pass runs on the full LTO module and fills in the
body of __cfi_check. This function must have the correct attributes in
order to be compatible with the rest of the program. For example, when
building with -mbranch-protection=standard, the function must have the
branch-target-enforcement attribute, which is normally added by Clang.
When __cfi_check is missing, CrossDSOCFI will give it the default set
of attributes, which are likely incorrect. Therefore, emit __cfi_check
to the full LTO part, where CrossDSOCFI will see it.

Reviewers: efriedma-quic, vitalybuka, fmayer

Reviewed By: efriedma-quic

Pull Request: https://github.com/llvm/llvm-project/pull/154833
2025-08-21 16:31:32 -07:00
David Majnemer
f961b61f88 [APFloat] Properly implement DoubleAPFloat::compareAbsoluteValue
The prior implementation would treat X+Y and X-Y as having equal
magnitude.  Rework the implementation to be more resilient.
2025-08-21 15:42:07 -07:00
Sergei Barannikov
c74afaac6c
[TableGen][DecoderEmitter] Use KnownBits for filters/encodings (NFCI) (#154691)
`KnownBits` is faster and smaller than `std::vector<BitValue>`.
It is also more convenient to use.
2025-08-22 01:37:47 +03:00
Alex MacLean
a3ed96b899
[NVPTX] Legalize aext-load to zext-load to expose more DAG combines (#154251) 2025-08-21 15:33:23 -07:00
Patrick Simmons
304373fb6d
Fix Debug Build Using GCC 15 (#152223)
Flang currently doesn't build in debug mode on GCC 15 due to missing
dynamic libraries in some CMakeLists.txt files, and OpenMP doesn't link
in debug mode due to the atomic library pulling in libstdc++ despite an
incomplete attempt in the CMakeLists.txt to disable glibcxx assertions.
This PR fixes these issues and allows Flang and the OpenMP runtime to
build and link on GCC 15 in debug mode.

---------

Co-authored-by: ronlieb <ron.lieberman@amd.com>
2025-08-21 18:28:01 -04:00
John Harrison
36d07ad83b
Reapply "[lldb-dap] Re-land refactor of DebugCommunication. (#147787)" (#154832)
This reverts commit 0f33b90b6117bcfa6ca3779c641c1ee8d03590fd and
includes a fix for the added test that was submitted between my last
update and pull.
2025-08-21 15:26:52 -07:00
Sergei Barannikov
33f6b10c17
[TableGen][DecoderEmitter] Resolve a FIXME in emitDecoder (#154649)
As the FIXME says, we might generate the wrong code to decode an
instruction if it had an operand with no encoding bits. An example is
M68k's `MOV16ds` that is defined as follows:

```
dag OutOperandList = (outs MxDRD16:$dst);
dag InOperandList = (ins SRC:$src);
list<Register> Uses = [SR];
string AsmString = "move.w\t$src, $dst"
dag Inst = (descend { 0, 1, 0, 0, 0, 0, 0, 0, 1, 1 },
            (descend { 0, 0, 0 }, (operand "$dst", 3)));
```

The `$src` operand is not encoded, but what we see in the decoder is:
```C++
    tmp = fieldFromInstruction(insn, 0, 3);
    if (!Check(S, DecodeDR16RegisterClass(MI, tmp, Address, Decoder)))
    { return MCDisassembler::Fail; }
    if (!Check(S, DecodeSRCRegisterClass(MI, insn, Address, Decoder)))
    { return MCDisassembler::Fail; }
    return S;
```

This calls DecodeSRCRegisterClass passing it `insn` instead of the value
of a field that doesn't exist. DecodeSRCRegisterClass has an
unconditional llvm_unreachable inside it.

New decoder looks like:
```C++
    tmp = fieldFromInstruction(insn, 0, 3);
    if (!Check(S, DecodeDR16RegisterClass(MI, tmp, Address, Decoder)))
    { return MCDisassembler::Fail; }
    return S;
```

We're still not disassembling this instruction right, but at least we no
longer have to provide a weird operand decoder method that accepts
instruction bits instead of operand bits.

See #154477 for the origins of the FIXME.
2025-08-21 22:22:16 +00:00
Dave Lee
d4b9acad58
[lldb] Fix TestSettings.py (#154849)
Fixes a few test failures on windows. See
https://github.com/llvm/llvm-project/pull/153233
2025-08-21 15:19:44 -07:00
Shubham Sandeep Rastogi
7f0e70fd2d [CMake] Update CMAKE_OSX_DEPLOYMENT_TARGET to 10.13.
The greendragon standalone bot is complaining about the deployment
target needing to be 10.13 or above. This change makes it 10.13
2025-08-21 15:09:31 -07:00
Rahul Joshi
22f8693248
[NFC][MC][Decoder] Extract fixed pieces of decoder code into new header file (#154802)
Extract fixed functions generated by decoder emitter into a new
MCDecoder.h header.
2025-08-21 15:06:43 -07:00
Kazu Hirata
628280b597
[memprof] Tidy up #includes (NFC) (#154684)
We've reorganized some code within memprof, but #indludes haven't
quite followed the code that moved.
2025-08-21 15:03:40 -07:00
Kazu Hirata
67e95c6f60
[llvm] Proofread DebuggingCoroutines.rst (#154681) 2025-08-21 15:03:32 -07:00
Kazu Hirata
4e98641451
[ADT] Use SmallPtrSet or SmallSet flexibly (NFC) (#154680)
I'm trying to remove the redirection in SmallSet.h:

template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

to make it clear that we are using SmallPtrSet.  There are only
handful places that rely on this redirection.

Now, this unit test is unique in that supply multiple key types via
TYPED_TESTS.

This patch adds UniversalSmallSet to work around the problem.
2025-08-21 15:03:24 -07:00
Kazu Hirata
ec07d8e941
[clang-tidy] Use SmallPtrSet directly instead of SmallSet (NFC) (#154679)
I'm trying to remove the redirection in SmallSet.h:

template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

to make it clear that we are using SmallPtrSet.  There are only
handful places that rely on this redirection.

This patch replaces SmallSet to SmallPtrSet where the element type is
a pointer.
2025-08-21 15:03:16 -07:00
Kazu Hirata
f5f6613af6
[Scalar] Use SmallSetVector instead of SmallVector (NFC) (#154678)
insertParsePoints collects live variables and then deduplicate them
while retaining the original insertion order, which is exactly what
SetVector is designed for.  This patch replaces SmallVector with
SetSmallVector while deleting unique_unsorted.

While we are at it, this patch reduces the number of inline elements
to a reasonable level for linear search.
2025-08-21 15:03:08 -07:00
Thurston Dang
e45210afe2
[msan] Handle AVX512 VCVTPS2PH (#154460)
This extends handleAVX512VectorConvertFPToInt() from
556c8467d15a131552e3c84478d768bafd95d4e6
(https://github.com/llvm/llvm-project/pull/147377) to handle AVX512
VCVTPS2PH.
2025-08-21 15:03:01 -07:00
Valentin Clement (バレンタイン クレメン)
1d05d693a1
[flang][cuda] Fix offset with multiple assumed size shared array (#154844)
When multiple assumed size variable are used in a kernel with dynamic
shared memory, each variable use the 0 offset. Update the pass to
account for that.

```
attributes(global) subroutine testany( a )
    real(4), shared :: smasks(*)
    real(8), shared :: dmasks(*)
end subroutine
```
2025-08-21 21:51:43 +00:00
Justin Riddell
fa67855c99
[CIR] Handle FunctionToPointerDecay casts (#153657) (#154060)
Add upstream support for handling implicit FunctionToPointerDecay casts
2025-08-21 14:40:14 -07:00
Sergei Barannikov
2421929ca6
[TableGen][DecoderEmitter] Infer encoding's HasCompleteDecoder earlier (NFCI) (#154644)
If an encoding has a custom decoder, the decoder is assumed to be
"complete" (always succeed) if hasCompleteDecoder field is true. We
determine this when constructing InstructionEncoding.

If the decoder for an encoding is *generated*, it always succeeds if
none of the operand decoders can fail. The latter is determined based on
the value of operands' DecoderMethod/hasCompleteDecoder. This happens
late, at table construction time, making the code harder to follow.

This change moves this logic to the InstructionEncoding constructor.
2025-08-21 21:35:30 +00:00
Rahul Joshi
d38a5afa5a
[NFC][MC][ARM] Fix formatting for ITStatus and VPTStatus (#154815) 2025-08-21 14:26:18 -07:00
Craig Topper
04a271adf8
[RISCV] Reorder atomic pseudo instructions and isel patterns. NFC (#154835)
Instead of interleaving the pseudo definitions and their patterns,
define all the pseudos together and all the patterns together.

Add IsRV32 predicate to the patterns.
2025-08-21 14:22:02 -07:00
Joseph Huber
c704dabe88
[Clang] Fix incorrect return type for __builtin_shufflevector (#154817)
Summary:
The `__builtin_shufflevector` call would return a GCC vector in all
cases where the vector type was increased. Change this to preserve
whether or not this was an extended vector.

Fixes: https://github.com/llvm/llvm-project/issues/107981
2025-08-21 16:13:52 -05:00
Michael Buch
8fa55a023b
[clang][DebugInfo][test] Move debug-info tests from CodeGenObjC to DebugInfo directory (#154781)
This patch works towards consolidating all Clang debug-info into the
`clang/test/DebugInfo` directory
(https://discourse.llvm.org/t/clang-test-location-of-clang-debug-info-tests/87958).

Here we move only the `clang/test/CodeGenObjC` tests.

The list of files i came up with is:
1. searched for anything with `*debug-info*` in the filename
2. searched for occurrences of `debug-info-kind` in the tests
2025-08-21 22:09:34 +01:00
Dan Liew
09612007f1
[NFC][Diagnostics] Reformat DiagnosticIDs.h and AllDiagnostics.h (#154628)
When trying to add a new diagnostic category (e.g. #154618) I discovered
`clang-format` really wanted to reformat these files.

My initial attempt was just to suppress the reformatting with `//
clang-format (on|off)` directives but reviewers preferred just
reformatting the files so these two files have been completely
reformatted.

`clang-format` has been disabled for the enum that declares the
`DIAG_START_*` constants because its much less readable after
formatting.
2025-08-21 14:06:49 -07:00
Florian Hahn
300d2c6d20
[VPlan] Move SCEV expansion to VPlan transform. (NFCI).
Move the logic to expand SCEVs directly to a late VPlan transform that
expands SCEVs in the entry block. This turns VPExpandSCEVRecipe into an
abstract recipe without execute, which clarifies how the recipe is
handled, i.e. it is not executed like regular recipes.

It also helps to simplify construction, as now scalar evolution isn't
required to be passed to the recipe.
2025-08-21 22:03:26 +01:00
ykhatav
38f0b9e6d9
Fix scope of typedefs present inside a template class (#146729)
When a typedef is declared within a templated class, clang incorrectly
assigns the typedef to the compilation unit (CU) scope rather than the
intended scope of the templated class. This issue arises because, during
the creation of the typedef, the context lookup in the RegionMap fails
to locate the templated class, despite its prior creation.
The problem stems from the way the context is stored in the RegionMap.
When handling templated types, the current implementation stores the
class specialization rather than the templated declaration itself. This
leads to a mismatch when attempting to retrieve the context for the
typedef.
To address this issue, the solution involves modifying the
CreatedLimitedType() function. Specifically, when a struct or class is a
templated type, we should store the actual templated declaration in the
RegionMap instead of the class specialization. This ensures that
subsequent lookups for context, such as those needed for typedef
declarations, correctly identify the templated class scope.
Fixes https://github.com/llvm/llvm-project/issues/91451
2025-08-21 16:58:25 -04:00
Alex MacLean
9b24ccca73
[NVPTX] Allow more argument integer types, such as i256 and i96 (#154824)
The refactoring of ComputePTXValueVTs in #154476 caused the complier to
no longer crash when lowering i256 and i96. This has caused a few tests
to unexpectedly pass.

Update these tests and tweak how we emit parameter declarations to
correctly lower these types.
2025-08-21 13:54:38 -07:00
Dave Lee
933d8723b0
[llvm][utils] Improve the StringRef summary formatter (#151594)
Improve the `StringRef` summary formatter in the following ways:
* inherit adherence to the `target.max-string-summary-length` setting
* support non-printable bytes (such as null bytes, and any other binary data)

With the previous implementation, some non-printable bytes would raise a
Python exception.
2025-08-21 13:42:49 -07:00
Dave Lee
545cda649e
[lldb] Add flag to "settings show" to include default values (#153233)
Adds a `--defaults`/`-d` flag to `settings show`. This mode will _optionally_ show a
setting's default value. In other words, this does not always print a default value for
every setting.

A default value is not shown when the current value _is_ the default.

Note: some setting types do not print empty or invalid values. For these setting types,
if the default value is empty or invalid, the same elision logic is applied to printing
the default value.
2025-08-21 13:41:38 -07:00
Florian Hahn
ba5d487ac4
[LV] Add test with interleave groups separated by offset.
Adds extra test coverage for
https://github.com/llvm/llvm-project/pull/91196.
2025-08-21 21:40:47 +01:00
Alex MacLean
4a9d2187ee
[SeparateConstOffsetFromGEP] propagate const offset through GEP chains (#143470)
When separating the constant offset from a GEP, if the pointer operand
is a constant ptradd (likely generated when we performed this transform
on that GEP), we accumulate the offset into the current offset. This
ensures that when there is a chain of GEPs the constant offset reaches
the final memory instruction where it can likely be folded into the
addressing.
2025-08-21 13:37:24 -07:00
Scott Linder
76b8e19203
[LangRef] Rework DIExpression docs (#153072)
Factor out most of the DIExpression docs from LangRef.rst into
SourceLevelDebugging.rst

What remains in LangRef is just enough context to make sense of how
DIExpression-as-metadata fits into the IR, including some examples of
the DIExpression syntax.

The rest now lives in the SourceLevelDebugging document, which gives
more context to make sense of DIExpression-as-semantic-entity.

Use sections to clearly separate DWARF opcodes from LLVM internal-only
opcodes, where before the distinction was only explicit in the source
code.

Also make some other changes like fixing typos, using :ref: rather than
unchecked links, and rewording DW_OP_LLVM_entry_value.
2025-08-21 16:32:53 -04:00
Dave Lee
a447fc63f9
[lldb] Improve error message in ResolveSDKPathFromDebugInfo (NFC) (#154607)
While debugging, I saw a log line of:

> Failed to resolve SDK path: Error while searching for SDK (XcodeSDK ''): Unrecognized SDK type:

Looking into how this might happen, it seems `ResolveSDKPathFromDebugInfo` appears to
(implicitly) assume there's at least one compile unit. This change adds a precondition
to return a meaningful error when there are no compile units.

Original: https://github.com/llvm/llvm-project/pull/146062
2025-08-21 13:23:38 -07:00
James Newling
a64e6f4928
[MLIR][Vector] Test to accompany bug fix (#154434)
Bug introduced in 
https://github.com/llvm/llvm-project/pull/93664

The bug was fixed in
https://github.com/llvm/llvm-project/pull/152957

But there was no test. This PR adds a test that hits the assertion
failure if the fix is reverted (if I change dyn_cast to cast).
2025-08-21 13:00:41 -07:00
Ramkumar Ramachandra
de7bac6426
[VPlan/PatternMatch] Strip outdated hdr comment (NFC) (#154794) 2025-08-21 20:43:03 +01:00
Carlos Galvez
344793e513
[clang-tidy][doc] Improve option docs for readability-identifier-naming (#154806)
Currently it's hard to find the "general" options, since they are listed
in the middle of the "specific" options. Split them into two categories
so they are easier to find.

This can help in adding a potential new general option in a follow-up
patch.

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
2025-08-21 21:41:24 +02:00
Peter Collingbourne
b3baa4d063 gn build: Port 4c9b7ff04cb4 2025-08-21 12:15:37 -07:00
Peter Collingbourne
779bb04a9a [gn build] Port fea7e6934a25 2025-08-21 12:15:37 -07:00
Peter Collingbourne
9b5282723b [gn build] Port eb764040bccc 2025-08-21 12:15:37 -07:00
Peter Collingbourne
4e7779c099 [gn build] Port deab049b5cc8 2025-08-21 12:15:36 -07:00
Peter Collingbourne
8d69c83808 [gn build] Port 8b64cd8be29d 2025-08-21 12:15:36 -07:00
Peter Collingbourne
7d1f15c985 [gn build] Port 87a1d42bed3d 2025-08-21 12:15:36 -07:00
Peter Collingbourne
f66d7b50ff [gn build] Port 15babbaf5d40 2025-08-21 12:15:36 -07:00
Shubham Sandeep Rastogi
0f33b90b61 Revert "[lldb-dap] Re-land refactor of DebugCommunication. (#147787)"
This reverts commit 13eca5248c7bf625af9c7af898d48e8c0a441496.

This change broke greendragon lldb test:

lldb-api.tools/lldb-dap/moduleSymbols.TestDAP_moduleSymbols.py
2025-08-21 12:12:46 -07:00
Craig Topper
424521f599
[RISCV] Correct the OperandType for simm8_unsigned and simm10_unsigned. (#154667) 2025-08-21 12:01:07 -07:00
William Huynh
1b9e9e29e2
[libc] Add boot code for AArch64 (#154789)
This is required in hermetic testing downstream. It is not complete, and
will not work on hardware, however it runs on QEMU, and can report a
pass/fail on our tests.
2025-08-21 18:47:34 +00:00
Tom Honermann
c80b7822e3
[NFC][SYCL] Test use of sycl_kernel_entry_point with null declarations and statements. (#154583)
The `sycl_kernel_entry_point` attribute only appertains to functions.
This change adds missing tests to validate that an appropriate
diagnostic is issued for likely unintentional application of the
attribute to a null declaration or a null statement; perhaps due to an
unintended semicolon.
2025-08-21 14:47:07 -04:00
Thurston Dang
de64f85f5d
[hwasan] Port "[Asan] Skip pre-split coroutine and noop coroutine frame (#99415)" (#154803)
Originally suggested by rnk@

(this is the simplified function-level skip version, to unblock builds
ASAP)
2025-08-21 11:20:35 -07:00
Sebastian Pop
e42ef8083c
[delinearize] use update_analyze_test_checks.py in delinearization testcases (#153831)
In this patch:
1. Adapt the output of printDelinearization() to match what the script
   expects to see, "Printing analysis 'Delinearization' for function".
2. Register the "Delinearization" pass in the update script.
3. Automatically remove the existing CHECK statements.
4. Update the tests with a run of:
```
$ ~/llvm-project/llvm/utils/update_analyze_test_checks.py
        --opt=~/llvm-project/build/bin/opt
        ~/llvm-project/llvm/test/Analysis/Delinearization/*.ll
```
5. Drop llvm/test/Analysis/Delinearization/undef.ll because the test
   does not pass the github-actions "undef deprecator."
6. Only run delinearization pretty-print pass on the most internal loop.
7. Only run delinearization pretty-print pass on load and store
   instructions.
2025-08-21 13:02:56 -05:00
Timm Baeder
8b091961b1
[clang][bytecode] Implement Pointer::getType() for function pointers (#154788)
Fixes #152920
2025-08-21 20:01:22 +02:00
Florian Hahn
e41aaf5a64
[VPlan] Use VPIRMetadata for VPInterleaveRecipe. (#153084)
Use VPIRMetadata for VPInterleaveRecipe to preserve noalias metadata
added by versioning.

This still uses InterleaveGroup's logic to preserve existing metadata
from IR. This can be migrated separately.

Fixes https://github.com/llvm/llvm-project/issues/153006.

PR: https://github.com/llvm/llvm-project/pull/153084
2025-08-21 18:58:10 +01:00
Florian Hahn
21cca5ea9d
[VPlan] Rely on VPlan opts to simplify multiply by 1 (NFCI). 2025-08-21 18:43:47 +01:00
David Green
11994e8da7
[AArch64][GlobalISel] Mark G_BR as always legal. NFC (#153545)
As far as I understand this will not affect anything, just lower the
exposure to the legacy legalizer rules.
2025-08-21 18:42:44 +01:00
Craig Topper
c91f7dc7cd
[TableGen] Remove dummy UINT64_C(0) from end of InstBits table. NFC (#154778)
I suspect this originally existed to avoid a trailing comma from the
previous entry. C++ allows trailing commas in arrays so this isn't
necessary.
2025-08-21 10:42:37 -07:00
David Green
1a09581aa1
[AArch64][GlobalISel] Be more precise in RegBankSelect for s/uitofp (#154489)
We can generate fpr->fpr instructions for G_SITOFP and G_UITOFP. It was
previously marking the instructions as FPR but then generating GPR
instructions and introducing a copy.
2025-08-21 17:41:01 +00:00
Finn Plummer
87a1d42bed
[DirectX] Add support for remove-section of DXContainer for llvm-objcopy (#153246)
This pr implements the `remove-section` option for a `DXContainer`
object in `llvm-objcopy`.

It implements a base `removeParts` to the minimal `object`
representation of a `DXContainerObject`.

This is the second step to implement
https://github.com/llvm/llvm-project/issues/150275 as a compiler actions
that invokes llvm-objcopy for functionality.
2025-08-21 10:30:54 -07:00
Alex MacLean
a9de1ab44d
[NVPTX] Disable v2f32 registers when no operations supported, or via cl::opt (#154476)
The addition of v2f32 as a legal type, supported by the B64 register
class, has caused performance regressions, broken inline assembly, and
resulted in a couple (now fixed) mis-compilations. In order to mitigate
these issues, only mark this as a legal type when there exist operations
that support it, since for targets where this is not the case it serves
no purpose. To enable further debugging, add an option to disable v2f32.

In order to allow for a target-dependent set of legal types,
ComputePTXValueVTs has been fully re-written to take advantage of
TargetLowering call-lowering APIs.
2025-08-21 10:30:36 -07:00
Aiden Grossman
0319a7970d
[CI] Disable PIE on Linux Premerge Builds (#154584)
We do not gain any additional security from having PIE on the test
binaries, and this does have an impact on test times. It is about 10%
from my measurements. Not as much as previous reports
(https://reviews.llvm.org/D140880), but still significant. This is a
similar gain to finish enabling the lit internal shell, which will take
significantly more effort. I also do not think this is a meaningful
enough difference from the "default" configuration to keep it the
default, especially given the option is mostly set by distros.
2025-08-21 10:21:02 -07:00
John Harrison
13eca5248c
[lldb-dap] Re-land refactor of DebugCommunication. (#147787)
Originally commited in 362b9d78b4ee9107da2b5e90b3764b0f0fa610fe and then
reverted in cb63b75e32a415c9bfc298ed7fdcd67e8d9de54c.

This re-lands a subset of the changes to
dap_server.py/DebugCommunication and addresses the python3.10
compatibility issue.

This includes less type annotations since those were the reason for the
failures on that specific version of python.

I've done additional testing on python3.8, python3.10 and python3.13 to
further validate these changes.
2025-08-21 10:20:01 -07:00
Anchu Rajendran S
bce9b6d177
[Flang][Flang-Driver]Fix to add atomic control options in non-fc1 mode (#154638) 2025-08-21 10:15:33 -07:00
Andy Kaylor
c5466c64d4
[CIR] Add CIR vtable attribute (#154415)
This adds the #cir.vtable attribute definition and verification.
Generation of the vtable will be implemented in a later change.
2025-08-21 09:52:14 -07:00
7mile
761125f267
[CIR][Dialect] Add SourceLangAttr (#152511)
This patch upstreams `SourceLangAttr` and its CodeGen logic in the CGM,
which encodes the source language in CIR.
2025-08-21 09:51:37 -07:00
Shafik Yaghmour
436f391d1d
[Clang][Codegen][NFC] Apply rule of three to some classes (#154671)
Static analysis flagged these classes as having implemented the
destructor but not applying rule of three. This could lead to accidental
misuse and so it makes sense to apply it.
2025-08-21 09:36:25 -07:00
Florian Hahn
b5fc4fd009
[LAA] Add test requiring runtime checks with -max-dependences flag.
Adds extra test coverage for
https://github.com/llvm/llvm-project/pull/91196.
2025-08-21 17:31:53 +01:00
Jordan Rupprecht
9576a100ae
[bazel] Port #152474: RemarkEngine (#154792) 2025-08-21 16:29:50 +00:00
Leandro Lacerda
eed5f06ae8
[Offload][Conformance] Add randomized tests for single-precision bivariate math functions (#154663)
This patch adds a new set of randomized conformance tests for
single-precision bivariate math functions.

The functions included in this set were selected based on the following
criteria:
- An implementation exists in `libc/src/math/generic` (i.e., it is not
just a wrapper around a compiler built-in).
- The corresponding LLVM CPU libm implementation is correctly rounded.
- The function is listed in Table 65 of the OpenCL C Specification
v3.0.19.
2025-08-21 11:27:25 -05:00
Tim Gymnich
e20fa4f412
[mlir][AMDGPU] Add PermlaneSwapOp (#154345)
- Add PermlaneSwapOp that lowers to `rocdl.permlane16.swap` and
`rocdl.permlane32.swap`

---------

Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
2025-08-21 18:21:43 +02:00
Andres-Salamanca
fc62990657
[CIR] Upstream GotoSolver pass (#154596)
This PR upstreams the GotoSolver pass.  
It works by walking the function and matching each label to a goto. If a
label is not matched to a goto, it is removed and not lowered.
2025-08-21 11:02:29 -05:00
Timm Baeder
3923adfa3f
[clang][bytecode] Guard strcmp against differing element types (#154777)
This can happen when casts are involved.

Fixes #154006
2025-08-21 18:02:08 +02:00
Dave Lee
dacabc1fee
[lldb] Tweak check for CommandLineTools in ParseXcodeSDK (#154574)
Follow up to https://github.com/llvm/llvm-project/pull/128712
2025-08-21 08:56:17 -07:00
Dave Lee
86c9a7b0c1
[lldb] Remove unused XcodeSDK::SupportsSwift (NFC) (#154572) 2025-08-21 08:55:50 -07:00
Kazu Hirata
035dd1d854 [ADT] Fix a warning
This patch fixes:

  third-party/unittest/googletest/include/gtest/gtest.h:1379:11:
  error: comparison of integers of different signs: 'const unsigned
  long' and 'const int' [-Werror,-Wsign-compare]
2025-08-21 08:49:56 -07:00
Ramkumar Ramachandra
a96b78cf41
[SCEVPatternMatch] Add signed cst match; use in LV (NFC) (#154568)
Add a m_scev_SpecificSInt for matching a sign-extended value, and use it
to improve some code in LoopVectorize.
2025-08-21 15:46:53 +00:00
Guray Ozen
5c36fb3303
[MLIR][NVVM] Improve inline_ptx, add readwrite support (#154358)
Key Features
1. Multiple SSA returns – no struct packing/unpacking required.
2. Automatic struct unpacking – values are directly usable.
3. Readable register mapping
    * {$rwN} → read-write
    * {$roN} → read-only
    * {$woN} → write-only
4. Full read-write support (+ modifier).
5. Simplified operand specification – avoids cryptic
"=r,=r,=f,=f,f,f,0,1" constraints.
6. Predicate support: PTX `@p` predication support

IR Example:
```
%wo0, %wo1 = nvvm.inline_ptx """
 .reg .pred p;
 setp.ge.s32 p,   {$r0}, {$r1};
 selp.s32 {$rw0}, {$r0}, {$r1}, p;
 selp.s32 {$rw1}, {$r0}, {$r1}, p;
 selp.s32 {$w0},  {$r0}, {$r1}, p;
 selp.s32 {$w1},  {$r0}, {$r1}, p;
""" ro(%a, %b : f32, f32) rw(%c, %d : i32, i32) -> f32, f32
```

After lowering
```
 %0 = llvm.inline_asm has_side_effects asm_dialect = att
 "{
                              .reg .pred p;\
                              setp.ge.s32 p, $4, $5;   \
                              selp.s32   $0, $4, $5, p;\
                              selp.s32   $1, $4, $5, p;\
                              selp.s32   $2, $4, $5, p;\
                              selp.s32   $3, $4, $5, p;\
   }"
   "=r,=r,=f,=f,f,f,0,1"
   %c500_i32, %c400_i32, %cst, %cst_0
   : (i32, i32, f32, f32)
   -> !llvm.struct<(i32, i32, f32, f32)>

 %1 = llvm.extractvalue %0 : !llvm.struct<(i32, i32, f32, f32)>
 %2 = llvm.extractvalue %0 : !llvm.struct<(i32, i32, f32, f32)>
 %3 = llvm.extractvalue %0 : !llvm.struct<(i32, i32, f32, f32)>
 %4 = llvm.extractvalue %0 : !llvm.struct<(i32, i32, f32, f32)>

 // Unpacked result from nvvm.inline_ptx
 %5 = arith.addi %1, %2 : i32
 // read only
 %6 = arith.addf %cst, %cst_0 : f32
 // write only
 %7 = arith.addf %3, %4 : f32
```
2025-08-21 17:42:18 +02:00
Florian Hahn
1b0b59ae43
[InstComb] Fold inttoptr (add (ptrtoint %B), %O) -> GEP for ICMP users. (#153421)
Replace inttoptr (add (ptrtoint %B), %O) with (getelementptr i8, %B, %o)
if all users are ICmp instruction, which in turn means only the address
value is compared. We should be able to do this, if the src pointer,
the integer type and the destination pointer types have the same
bitwidth and address space.

A common source of such (inttoptr (add (ptrtoint %B), %O)) is from
various iterations in libc++.

In practice this triggers in a number of files in Clang and various open
source projects, including cppcheck, diamond, llama and more.

Alive2 Proof with constant offset: https://alive2.llvm.org/ce/z/K_5N_B

PR: https://github.com/llvm/llvm-project/pull/153421
2025-08-21 16:36:25 +01:00
Jay Foad
0594bad039
[AMDGPU] Remove "using namespace" from a header. NFC. (#154776) 2025-08-21 16:29:43 +01:00
Chao Chen
68d6866428
[mlir][XeGPU] add WgToSg distribution pattern for load_matrix and store_matrix. (#154403) 2025-08-21 10:02:45 -05:00
Renato Golin
32a5adbd42
[MLIR][Linalg] Rename convolution pass (#154400)
Rename the pass `LinalgNamedOpConversionPass` to
`SimplifyDepthwiseConvPass` to avoid conflating it with the new
morphisms we are creating between the norms.
2025-08-21 15:57:16 +01:00
Steven Perron
a53e73e6ef
[SPIRV][HLSL] Add DXC compatibility option for extension (#151554)
The default behaviour in DXC is to allow all extesions the compiler
knows about. We did the same in clang: all extensions that clang knows
about. However, this causes the shader to use different extensions
because the two compilers have different sets of extensions.

To avoid using a new extension when moving from DXC to Clang, we add the
special DXC suboptions to `-fspv-extension`. If `-fspv-extension=DXC` is
used, then the available extensions will be those available in DXC.

---------

Co-authored-by: Chris B <beanz@abolishcrlf.org>
2025-08-21 14:43:29 +00:00
Florian Hahn
cfef05e69c
[InstCombine] Add tests for (inttoptr (add (ptrtoint %Base), %Offset)).
Precommit tests for https://github.com/llvm/llvm-project/pull/153421.
2025-08-21 15:42:39 +01:00
jyli0116
dbadab96eb
[GlobalISel] Support saturated truncate (#150219)
Implements combining and legalization of G_TRUNC_SSAT_S, G_TRUNC_SSAT_U,
and G_TRUNC_USAT_U, which where previously added to SDAG with the below
patterns:

```
truncate(smin(smax(x, C1), C2)) -> trunc_ssat_s(x)
truncate(smax(smin(x, C2), C1)) -> trunc_ssat_s(x)

truncate(smax(smin(x, C), 0)) -> trunc_ssat_u(x)
truncate(smin(smax(x, 0), C)) -> trunc_ssat_u(x)
truncate(umin(smax(x, 0), C)) -> trunc_ssat_u(x)

truncate(umin(x, C)) -> trunc_usat_u(x)
```
2025-08-21 15:37:53 +01:00
Timm Baeder
3f97736181
[clang][bytecode] Implement ia32_select* builtins (#154758) 2025-08-21 16:34:57 +02:00
Aaron Ballman
17eb05ddd3
Revert "[C++] Expose nullptr_t from stddef.h in C++ mode" (#154767)
Reverts llvm/llvm-project#154599

It seems to be causing staging failures:
    https://lab.llvm.org/staging/#/builders/192/builds/1329
    https://lab.llvm.org/staging/#/builders/192/builds/1330
2025-08-21 10:05:41 -04:00
Guray Ozen
3d41197d68
[MLIR] Introduce RemarkEngine + pluggable remark streaming (YAML/Bitstream) (#152474)
This PR implements structured, tooling-friendly optimization remarks
with zero cost unless enabled. It implements:
- `RemarkEngine` collects finalized remarks within `MLIRContext`.
- `MLIRRemarkStreamerBase` abstract class streams them to a backend.
- Backends: `MLIRLLVMRemarkStreamer` (bridges to llvm::remarks →
YAML/Bitstream) or your own custom streamer.
- Optional mirroring to DiagnosticEngine (printAsEmitRemarks +
categories).
- Off by default; no behavior change unless enabled. Thread-safe;
ordering best-effort.


## Overview

```
Passes (reportOptimization*)
         │
         ▼
+-------------------+
|  RemarkEngine     |   collects
+-------------------+
     │         │
     │ mirror  │ stream
     ▼         ▼
emitRemark    MLIRRemarkStreamerBase (abstract)
                   │
                   ├── MLIRLLVMRemarkStreamer → llvm::remarks → YAML | Bitstream
                   └── CustomStreamer → your sink
```

## Enable Remark engine and Plug LLVM's Remark streamer
```
// Enable once per MLIRContext. This uses `MLIRLLVMRemarkStreamer`
mlir::remark::enableOptimizationRemarksToFile(
    ctx, path, llvm::remarks::Format::YAML, cats);
```

## API to emit remark
```
// Emit from a pass
 remark::passed(loc, categoryVectorizer, myPassname1)
        << "vectorized loop";

remark::missed(loc, categoryUnroll, "MyPass")
        << remark::reason("not profitable at this size")   // Creates structured reason arg
        << remark::suggest("increase unroll factor to >=4");   // Creates structured suggestion arg

remark::passed(loc, categoryVectorizer, myPassname1)
        << "vectorized loop" 
        << remark::metric("tripCount", 128);                // Create structured metric on-the-fly
```
2025-08-21 16:02:31 +02:00
Jay Foad
5d4aa87ca5 [AMDGPU] Remove redundant isAMDGCN check. NFC. 2025-08-21 14:54:53 +01:00
Bjorn Pettersson
e21b0dd819
[llvm-lit] Second attempt to fix print-relative-path.py
This is a fixup for #154317
2025-08-21 15:47:49 +02:00
Luke Lau
42cf9c60d7
[RISCV] Mark Sub/AddChainWithSubs as legal reduction types (#154753)
We used to vectorize these scalably but after #147026 they were split
out from RecurKind::Add into their own RecurKinds, and we didn't mark
them as supported in isLegalToVectorizeReduction.

This caused the loop vectorizer to drop the scalable VPlan because it
thinks the reductions will be scalarized.

This fixes it by just marking them as supported.

Fixes #154554
2025-08-21 21:43:48 +08:00
Matt Arsenault
b614975e97 AMDGPU: Fix expensive_checks machine verifier errors in new tests 2025-08-21 22:33:26 +09:00
enh-google
71dd4e17dd
[libc] fix strsep()/strtok()/strtok_r() "subsequent searches" behavior. (#154370)
These functions turned out to have the same bug that was in wcstok()
(fixed by 4fc9801), so add the missing tests and fix the code in a way
that matches wcstok().

Also fix incorrect test expectations in existing tests.

Also update the BUILD.bazel files to actually build the strsep() test.
2025-08-21 09:32:35 -04:00
Joseph Huber
e90ce511e0 Disable asan on last wide string function 2025-08-21 08:30:47 -05:00
Joseph Huber
3596005148 Fix wide read defaults 2025-08-21 08:17:06 -05:00
Krzysztof Parzyszek
bd63d9349a
[flang][OpenMP] Sort OpenMP-related names in dump-parse-tree.h, NFC (#154589) 2025-08-21 08:15:03 -05:00
Aaron Ballman
7d167f4564
[C++] Expose nullptr_t from stddef.h in C++ mode (#154599)
The C++ standard requires stddef.h to declare all of its contents in the
global namespace. We were only doing it when trying to be compatible
with Microsoft extensions. Now we expose in C++11 or later, in addition
to exposing it in Microsoft extensions mode.

Fixes #154577
2025-08-21 09:11:41 -04:00
Timm Baeder
f09ac1bf86
[clang][bytecode] Fix an out-of-bounds access with ia32_pmul* (#154750)
... builtins. We used to access the I'th index of the output vector, but
that doesn't work since the output vector is only half the size of the
input vector.
2025-08-21 15:09:08 +02:00
Aaron Ballman
a33e505c1a
[C99] Update documentation for scope of variables in loops; NFC (#154744)
I tracked down the document which changed the way variables are handled
in for loops for C99, it was the same document that allowed mixing code
and declarations but the editor's report made it seem like the features
came from different papers.

This is an extension we backported to C89 but it's sufficiently distinct
in the tracking page so I've added it explicitly to the backported
features documentation.
2025-08-21 12:46:57 +00:00
Michael Buch
f3508aa94a
[llvm][Support] Fix missing-field-initializer warnings for crashreporter_annotations_t (#154716)
Use `CRASHREPORTER_ANNOTATIONS_INITIALIZER` when possible, which will
handle the field initialization for us. That's what we already do in
compiler-rt:

0c480dd4b6/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp (L799-L817)

This way we won't get these warnings when the layout of
crashreporter_annotations_t changes:
```
llvm/lib/Support/PrettyStackTrace.cpp:92:65: warning: missing field 'blah' initializer [-Wmissing-field-initializers]
        = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0, 0 };
                                                                  ^
1 warning generated
```
2025-08-21 13:40:57 +01:00
Joseph Huber
6ac01d12d6
Reapply "[libc] Enable wide-read memory operations by default on Linux (#154602)" (#154640)
Reland afterr the sanitizer and arm32 builds complained.
2025-08-21 07:40:23 -05:00
Mikhail R. Gadelha
2b1dcf5383
[libc] Remove hardcoded sizeof in __barrier_type.h (#153718)
This PR modifies the static_asserts checking the expected sizes in
__barrier_type.h, so that we can guarantee that our internal
implementation fits the public header.
2025-08-21 09:37:56 -03:00
donald chen
5af7263d42
[mlir] add getViewDest method to viewLikeOpInterface (#154524)
The viewLikeOpInterface abstracts the behavior of an operation view one
buffer as another. However, the current interface only includes a
"getViewSource" method and lacks a "getViewDest" method.

Previously, it was generally assumed that viewLikeOpInterface operations
would have only one return value, which was the view dest. This
assumption was broken by memref.extract_strided_metadata, and more
operations may break these silent conventions in the future. Calling
"viewLikeInterface->getResult(0)" may lead to a core dump at runtime.
Therefore, we need 'getViewDest' method to standardize our behavior.

This patch adds the getViewDest function to viewLikeOpInterface and
modifies the usage points of viewLikeOpInterface to standardize its use.
2025-08-21 20:09:52 +08:00
Jan Patrick Lehr
9ccdadd2a5
Revert "[OpenMP] Add ompTest library to OpenMP" (#154742)
Reverts llvm/llvm-project#147381

A few buildbot failures for different reasons.
2025-08-21 14:09:07 +02:00
Matt Arsenault
13ae82d6ea
AMDGPU: Fix broken check lines in test (#154690)
SelectionDAG checks were dropped, regenerate the test to
restore them.
2025-08-21 21:00:55 +09:00
Chaitanya Koparkar
ad63a70d6d
[ADT] Add fshl/fshr operations to APInt (#153790)
These operations are required for #153151.
2025-08-21 12:52:18 +01:00
Michael Halkenhäuser
35f01cea65
[OpenMP] Add ompTest library to OpenMP (#147381)
Description
===========
OpenMP Tooling Interface Testing Library (ompTest) ompTest is a unit
testing framework for testing OpenMP implementations. It offers a
simple-to-use framework that allows a tester to check for OMPT events in
addition to regular unit testing code, supported by linking against
GoogleTest by default. It also facilitates writing concise tests while
bridging the semantic gap between the unit under test and the OMPT-event
testing.

Background
==========
This library has been developed to provide the means of testing OMPT
implementations with reasonable effort. Especially, asynchronous or
unordered events are supported and can be verified with ease, which may
prove to be challenging with LIT-based tests. Additionally, since the
assertions are part of the code being tested, ompTest can reference all
corresponding variables during assertion.

Basic Usage
===========
OMPT event assertions are placed before the code, which shall be tested.
These assertion can either be provided as one block or interleaved with
the test code. There are two types of asserters: (1) sequenced
"order-sensitive" and (2) set "unordered" assserters. Once the test is
being run, the corresponding events are triggered by the OpenMP runtime
and can be observed. Each of these observed events notifies asserters,
which then determine if the test should pass or fail.

Example (partial, interleaved)
==============================
```c++
  int N = 100000;
  int a[N];
  int b[N];

  OMPT_ASSERT_SEQUENCE(Target, TARGET, BEGIN, 0);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, ALLOC, N * sizeof(int)); // a ?
  OMPT_ASSERT_SEQUENCE(TargetDataOp, H2D, N * sizeof(int), &a);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, ALLOC, N * sizeof(int)); // b ?
  OMPT_ASSERT_SEQUENCE(TargetDataOp, H2D, N * sizeof(int), &b);
  OMPT_ASSERT_SEQUENCE(TargetSubmit, 1);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, D2H, N * sizeof(int), nullptr, &b);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, D2H, N * sizeof(int), nullptr, &a);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, DELETE);
  OMPT_ASSERT_SEQUENCE(TargetDataOp, DELETE);
  OMPT_ASSERT_SEQUENCE(Target, TARGET, END, 0);

#pragma omp target parallel for
  {
    for (int j = 0; j < N; j++)
      a[j] = b[j];
  }
```

References
==========
This work has been presented at SC'24 workshops, see:
https://ieeexplore.ieee.org/document/10820689

Current State and Future Work
=============================
ompTest's development was mostly device-centric and aimed at OMPT device
callbacks and device-side tracing. Consequentially, a substantial part
of host-related events or features may not be supported in its current
state. However, we are confident that the related functionality can be
added and ompTest provides a general foundation for future OpenMP and
especially OMPT testing. This PR will allow us to upstream the
corresponding features, like OMPT device-side tracing in the future with
significantly reduced risk of introducing regressions in the process.

Build
=====
ompTest is linked against LLVM's GoogleTest by default, but can also be
built 'standalone'. Additionally, it comes with a set of unit tests,
which in turn require GoogleTest (overriding a standalone build). The
unit tests are added to the `check-openmp` target.

Use the following parameters to perform the corresponding build: 
`LIBOMPTEST_BUILD_STANDALONE` (Default: ${OPENMP_STANDALONE_BUILD})
`LIBOMPTEST_BUILD_UNITTESTS` (Default: OFF)

---------

Co-authored-by: Jan-Patrick Lehr <JanPatrick.Lehr@amd.com>
Co-authored-by: Joachim <protze@rz.rwth-aachen.de>
2025-08-21 13:46:30 +02:00
Bjorn Pettersson
40b129a9bd
[llvm-lit] Fix test checks for print-relative-path.py
Make sure we support windows style paths.

This is a fixup for #154317
2025-08-21 13:28:26 +02:00
Luke Lau
5ef28e0a88
[VPlan] Add m_c_Add to VPlanPatternMatch. NFC (#154730)
Same thing as #154705, and useful for simplifying the matching in
#152167
2025-08-21 11:26:08 +00:00
Timm Baeder
2ea5ec78db
[clang][bytecode] Fix a crash in Destroy op (#154695)
The local we're destroying might've been created for an expression, in
which case asDecl() on the DeclDesc returns nullptr.

Fixes #152958
2025-08-21 13:23:57 +02:00
Timm Baeder
c9bb3bdbca
[clang][bytecode] Fix a crash with typeid pointers (#154692)
That code is from a time when typeid pointers didn't exist. We can get
there for non-block, non-integral pointers, but we can't meaningfully
handle that case. Just return false.

Fixes #153712
2025-08-21 13:13:02 +02:00
Aleksandr Platonov
f306e0aeb2
Revert "[clangd] Add feature modules registry" (#154711)
Reverts llvm/llvm-project#153756

It leads to new build bot failure.
https://lab.llvm.org/buildbot/#/builders/145/builds/9200

```
BUILD FAILED: failed build (failure)

Step 5 (build-unified-tree) failure: build (failure) ...
254.983 [140/55/1504] Building CXX object tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/ClangdMain.cpp.o
FAILED: tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/ClangdMain.cpp.o
ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/tools/extra/clangd/tool -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/tool -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/../include-cleaner/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/tools/extra/clangd/../clang-tidy -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-
 rhel-test/clang-ppc64le-rhel/build/tools/clang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/tools/clang/tools/extra/clangd -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe  -unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/ClangdMain.cpp.o -MF tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/ClangdMain.cpp.o.d -o tools/clang/tools/extra/clangd/tool/CMakeFiles/obj.clangdMain.dir/ClangdMain.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:10:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/ClangdLSPServer.h:12:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/ClangdServer.h:12:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/CodeComplete.h:18:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/ASTSignals.h:12:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/ParsedAST.h:23:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/CollectMacros.h:12:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/Protocol.h:26:
In file included from /home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/URI.h:14:
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/Support/Registry.h:110:47: error: instantiation of variable 'llvm::Registry<clang::clangd::FeatureModule>::Head' required here, but no definition is available [-Werror,-Wundefined-var-template]
  110 |     static iterator begin() { return iterator(Head); }
      |                                               ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/Support/Registry.h:114:25: note: in instantiation of member function 'llvm::Registry<clang::clangd::FeatureModule>::begin' requested here
  114 |       return make_range(begin(), end());
      |                         ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:1021:64: note: in instantiation of member function 'llvm::Registry<clang::clangd::FeatureModule>::entries' requested here
 1021 |   for (FeatureModuleRegistry::entry E : FeatureModuleRegistry::entries()) {
      |                                                                ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/Support/Registry.h:61:18: note: forward declaration of template entity is here
   61 |     static node *Head;
      |                  ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/llvm-project/llvm/include/llvm/Support/Registry.h:110:47: note: add an explicit instantiation declaration to suppress this warning if 'llvm::Registry<clang::clangd::FeatureModule>::Head' is explicitly instantiated in another translation unit
  110 |     static iterator begin() { return iterator(Head); }
      |                                               ^
1 error generated.
```

I need some time to fix this in a correct way
2025-08-21 13:02:06 +02:00
Timm Baeder
21bd3a7fa8
[clang][bytecode] Check for unknown size array pointers in InitField* (#154689)
This can happen when the base pointer is an unknown size array, where
!isOnePastEnd(), but isPastEnd().

Fixes #153990
2025-08-21 13:01:45 +02:00
Florian Hahn
d67dba5e88
[VPlan] Check Def2LaneDefs first in cloneForLane. (NFC)
If we have entries in Def2LaneDefs, we always have to use it. Move the
check before.

Otherwise we may not pick the correct operand, e.g. if Op was a
replicate recipe that got single-scalar after replicating it.

Fixes https://github.com/llvm/llvm-project/issues/154330.
2025-08-21 11:34:49 +01:00
Mehdi Amini
b20c291bae
[MLIR] Adopt LDBG() debug macro in PatternApplicator.cpp (NFC) (#154724) 2025-08-21 10:32:21 +00:00
Mary Kassayova
98867bf8de
[AArch64] [CostModel] Fix cost modelling for saturating arithmetic intrinsics (#152333)
The cost model previously overestimating throughput costs to wide
fixed-length saturating arithmetic intrinsics when using SVE with a
fixed vscale of 2. These costs ended up much higher than for the same
operations using NEON, despite being fully legal and efficient with SVE.
This patch adjusts the cost model to avoid penalising these intrinsics
under SVE.
2025-08-21 11:31:34 +01:00
Mehdi Amini
acda808304
[MLIR] Adopt LDBG() macro in BuiltinAttributes.cpp (NFC) (#154723) 2025-08-21 10:31:18 +00:00
Mehdi Amini
b916df3a08
[MLIR] Adopt LDBG() in Transform/IR/Utils.cpp (NFC) (#154722) 2025-08-21 10:30:01 +00:00
Mehdi Amini
30f9428f14
[MLIR] Adopt LDBG() macro in LLVM/NVVM/Target.cpp (#154721) 2025-08-21 10:29:37 +00:00
Mehdi Amini
db0529dca3
[MLIR] Use LDBG() macro in Dialect.cpp (NFC) (#154720) 2025-08-21 10:28:51 +00:00
Björn Pettersson
59286193fc
[lit] Add support to print paths relative to CWD in the test summary report (#154317)
This patch adds a -r|--relative-paths option to llvm-lit, which when
enabled will print test case names using paths relative to the current
working directory. The legacy default without that option is that test
cases are identified using a path relative to the test suite.

Only the summary report is impacted. That normally include failed tests,
unless unless options such as --show-pass.

Background to this patch was the discussion here

https://discourse.llvm.org/t/test-case-paths-in-llvm-lit-output-are-lacking-the-location-of-the-test-dir-itself/87973
with a goal to making it easier to copy-n-paste the path to the failing
test cases.

Examples showing difference in "Passed Tests" and "Failed Tests":

 > llvm-lit --show-pass test/Transforms/Foo
 PASS: LLVM :: Transforms/Foo/test1.txt (1 of 2)
 FAIL: LLVM :: Transforms/Foo/test2.txt (2 of 2)
 Passed Tests (1):
   LLVM :: Transforms/Foo/test1.txt
 Failed Tests (1):
   LLVM :: Transforms/Foo/test2.txt

 > llvm-lit --show-pass --relative-paths test/Transforms/Foo
 PASS: LLVM :: Transforms/Foo/test1.txt (1 of 2)
 FAIL: LLVM :: Transforms/Foo/test2.txt (2 of 2)
 Passed Tests (1):
   test/Transforms/Foo/test1.txt
 Failed Tests (1):
   test/Transforms/Foo/test2.txt
2025-08-21 12:18:00 +02:00
Matthias Springer
60ee0560da
[flang] Fix replaceAllUsesWith API violations (1/N) (#154698)
`replaceAllUsesWith` is not safe to use in a dialect conversion and will
be deactivated soon (#154112). Fix commit fixes some API violations.
Also some general improvements.
2025-08-21 11:48:14 +02:00
macurtis-amd
0c480dd4b6
[clang][CodeGen] cast addr space of ReturnValue if needed (#154380)
Fixes a bug on AMDGPU targets where a pointer was stored as address
space 5, but then loaded as address space 0.

Issue found as part of [Kokkos](https://github.com/kokkos/kokkos)
testing, specifically `hip.atomics` (see
[core/unit_test/TestAtomics.hpp](https://github.com/kokkos/kokkos/blob/develop/core/unit_test/TestAtomics.hpp)).

Issue was introduced by commit
[39ec9de7c230](https://github.com/llvm/llvm-project/commit/39ec9de7c230)
- [clang][CodeGen] sret args should always point to the alloca AS, so
use that (https://github.com/llvm/llvm-project/pull/114062).
2025-08-21 04:38:55 -05:00
Luke Lau
955c475ae6
[VPlan] Add m_Sub to VPlanPatternMatch. NFC (#154705)
To mirror PatternMatch.h, and we'll also be able to use it in #152167
2025-08-21 09:33:46 +00:00
Guray Ozen
7439d22970
[MLIR][NVVM] Add nanosleep (#154697) 2025-08-21 11:30:41 +02:00
Simon Pilgrim
4da69721f9 [X86] test_mm512_mask_fmadd_ps - add missing select checks 2025-08-21 10:27:06 +01:00
David Green
5db67e1c86
[GlobalISel] Add a fadd 0.0 combine with nsz (#153748)
This is surprisingly helpful, coming up a lot from fadd reductions.
2025-08-21 10:19:39 +01:00
Peter Smith
bcf09c1bc7
[ARM][Disassembler] Advance IT State when instruction is unknown (#154531)
When an instruction that the disassembler does not recognize is in an IT
block, we should still advance the IT state otherwise the IT state
spills over into the next recognized instruction, which is incorrect.

We want to avoid disassembly like:
it eq
<unknown> // Often because disassembler has insufficient target info. 
addeq r0,r0,r0 // eq spills over into add.

Fixes #150569
2025-08-21 10:14:30 +01:00
Ilya Biryukov
26d4e56be8 [Clang] Fix dedup-types-builtin.cpp test when -std=c++20
It was previously failing because of a warning marking a C++20 feature
as an extension.

This is a follow-up to 85043c1c146fd5658ad4c5b5138e58994333e645 that
introduced the test.
2025-08-21 11:05:02 +02:00
Benjamin Maxwell
bfab8085af
[libunwind] Add support for the AArch64 "Vector Granule" (VG) register (#153565)
The vector granule (AArch64 DWARF register 46) is a pseudo-register that
contains the available size in bits of SVE vector registers in the
current call frame, divided by 64. The vector granule can be used in
DWARF expressions to describe SVE/SME stack frame layouts (e.g., the
location of SVE callee-saves).

The first time VG is evaluated (if not already set), it is initialized
to the result of evaluating a "CNTD" instruction (this assumes SVE is
available).

To support SME, the value of VG can change per call frame; this is
currently handled like any other callee-save and is intended to support
the unwind information implemented in #152283. This limits how VG is
used in the CFI information of functions with "streaming-mode changes"
(mode changes that change the SVE vector length), to make the unwinder's
job easier.
2025-08-21 10:01:40 +01:00
Lang Hames
9039b591d0 [orc-rt] Add rtti header and unit tests.
The orc-rt extensible RTTI mechanism is used to provide simple dynamic RTTI
checks for orc-rt types that do not depend on standard C++ RTTI (meaning that
they will work equally well for programs compiled with -fno-rtti).
2025-08-21 18:59:46 +10:00
Lang Hames
ca0a8d99bb [orc-rt] Add bitmask-enum helper utilities.
ORC_RT_MARK_AS_BITMASK_ENUM and ORC_RT_DECLARE_ENUM_AS_BITMASK can be used to
easily add support for bitmask operators (&, |, ^, ~) to enum types.

This code was derived from LLVM's include/llvm/ADT/BitmaskEnum.h header.
2025-08-21 18:59:46 +10:00
Lang Hames
2380d0ad1d [orc-rt] Add preliminary math.h header and basic operations.
The initial operations, isPowerOf2 and nextPowerOf2 will be used in an upcoming
patch to add support for bitmask-enums.
2025-08-21 18:59:46 +10:00
Lang Hames
8a10fbb2cb [orc-rt] Expand span.h file comment. NFC. 2025-08-21 18:59:46 +10:00
Abhishek Kaushik
f9c20ba040
[X86] Rename fp80-strict-vec-cmp.ll to scalarize-strict-fsetcc.ll (#154688)
The test name in #154486 mentioned fp80 which we are not testing in the
tests.
2025-08-21 14:28:39 +05:30
David Green
d9d71bdc14
[AArch64] Move BSL generation to lowering. (#151855)
It is generally better to allow the target independent combines before
creating AArch64 specific nodes (providing they don't mess it up). This
moves the generation of BSL nodes to lowering, not a combine, so that
intermediate nodes are more likely to be optimized. There is a small
change in the constant handling to detect legalized buildvector
arguments correctly.

Fixes #149380 but not directly. #151856 contained a direct fix for
expanding the pseudos.
2025-08-21 09:54:42 +01:00
Pengcheng Wang
17a98f85c2
[RISCV] Optimize the spill/reload of segment registers (#153184)
The simplest way is:

1. Save `vtype` to a scalar register.
2. Insert a `vsetvli`.
3. Use segment load/store.
4. Restore `vtype` via `vsetvl`.

But `vsetvl` is usually slow, so this PR is not in this way.

Instead, we use wider whole load/store instructions if the register
encoding is aligned. We have done the same optimization for COPY in
https://github.com/llvm/llvm-project/pull/84455.

We found this suboptimal implementation when porting some video codec
kernels via RVV intrinsics.
2025-08-21 16:38:53 +08:00
Ross Brunton
2e74cc6c04
[Offload][NFC] Use a sensible order for APIGen (#154518)
The order entries in the tablegen API files are iterated is not the
order
they appear in the file. To avoid any issues with the order changing
in future, we now generate all definitions of a certain class before
class that can use them.

This is a NFC; the definitions don't actually change, just the order
they exist in in the OffloadAPI.h header.
2025-08-21 09:38:21 +01:00
Ross Brunton
273ca1f77b
[Offload] Fix OL_DEVICE_INFO_MAX_MEM_ALLOC_SIZE on AMD (#154521)
This wasn't handled with the normal info API, so needs special handling.
2025-08-21 09:37:58 +01:00
Luke Lau
a9692391f6
[RISCV] Move volatile check to isCandidate in VL optimizer. NFC (#154685)
This keeps it closer to the other legality checks like the FP exceptions
check.
It also means that isSupportedInstr only needs to check the opcode,
which allows it to be replaced with a TSFlags based check in a later
patch.
2025-08-21 16:37:10 +08:00
Fraser Cormack
5c411b3c0b
[libclc] Use elementwise ctlz/cttz builtins for CLC clz/ctz (#154535)
Using the elementwise builtin optimizes the vector case; instead of
scalarizing we can compile directly to the vector intrinsics.
2025-08-21 09:32:03 +01:00
Michael Buch
f2aedc21f9
[clang][DebugInfo][test] Move debug-info tests from CodeGenCXX to DebugInfo directory (#154538)
This patch works towards consolidating all Clang debug-info into the
`clang/test/DebugInfo` directory
(https://discourse.llvm.org/t/clang-test-location-of-clang-debug-info-tests/87958).

Here we move only the `clang/test/CodeGenCXX` tests. I created a `CXX`
subdirectory for now because many of the tests I checked actually did
seem C++-specific. There is probably overlap between the `Generic` and
`CXX` subdirectory, but I haven't gone through and audited them all.

The list of files i came up with is:
1. searched for anything with `*debug-info*` in the filename
2. searched for occurrences of `debug-info-kind` in the tests

There's a couple of tests in `clang/test/CodeGenCXX` that still set
`-debug-info-kind`. They probably don't need to do that, but I'm not
changing that as part of this PR.
2025-08-21 09:26:08 +01:00
Simon Pilgrim
e4b110ab9f
[Headers][X86] Allow FMA3/FMA4 vector intrinsics to be used in constexpr (#154558)
Now that #152455 is done, we can make all the vector fma intrinsics that wrap __builtin_elementwise_fma to be constexpr

Fixes #154555
2025-08-21 09:09:40 +01:00
Benjamin Maxwell
810ea69edd
[LiveRegUnits] Exclude runtime defined liveins when computing liveouts (#154325)
These liveins are not defined by predecessors, so should not be 
considered as liveouts in predecessor blocks. This resolves:

- https://github.com/llvm/llvm-project/pull/149062#discussion_r2285072001
- https://github.com/llvm/llvm-project/pull/153417#issuecomment-3199972351
2025-08-21 09:06:32 +01:00
Aleksandr Platonov
ff5767a02c
[clangd] Add feature modules registry (#153756)
This patch adds feature modules registry, as discussed with @kadircet in
[discourse](https://discourse.llvm.org/t/rfc-registry-for-feature-modules/87733).
Feature modules, which added into the feature module set from registry
entries, can't expose public API, but still can be used via
`FeatureModule` interface.
2025-08-21 10:30:37 +03:00
Stephan T. Lavavej
f60ff00939
[libcxx][test] Silence nodiscard warnings (#154622)
MSVC's STL marks `std::make_shared`, `std::allocate_shared`,
`std::bitset::to_ulong`, and `std::bitset::to_ullong` as
`[[nodiscard]]`, which causes these libcxx tests to emit righteous
warnings. They should use the traditional `(void)` cast technique to
ignore the return values.
2025-08-21 00:28:17 -07:00
Dominik Adamski
b69fd34e76
[Offload] Add oneInterationPerThread param to loop device RTL (#151959)
Currently, Flang can generate no-loop kernels for all OpenMP target
kernels in the program if the flags
-fopenmp-assume-teams-oversubscription or
-fopenmp-assume-threads-oversubscription are set.
If we add an additional parameter, we can choose
in the future which OpenMP kernels should be generated as no-loop
kernels.

This PR doesn't modify current behavior of oversubscription flags.

RFC for no-loop kernels:
https://discourse.llvm.org/t/rfc-no-loop-mode-for-openmp-gpu-kernels/87517
2025-08-21 09:03:56 +02:00
Mythreya Kuricheti
0977a6d9e7
[clang][CodeComplete] Consider qualifiers of explicit object parameters in overload suggestions (#154041)
Fixes https://github.com/llvm/llvm-project/issues/109608
2025-08-21 02:32:41 -04:00
Timm Baeder
e0acf6592b
[clang][bytecode] Call CheckFinalLoad in all language modes (#154496)
Fixes #153997
2025-08-21 08:24:09 +02:00
Yi Kong
1ff7c8bf0d [compiler-rt] Fix musl build
The change in PR #154268 introduced a dependency on the `__GLIBC_PREREQ`
macro, which is not defined in musl libc. This caused the build to fail
in environments using musl.

This patch fixes the build by including
`sanitizer_common/sanitizer_glibc_version.h`. This header provides a
fallback definition for `__GLIBC_PREREQ` when LLVM is built against
non-glibc C libraries, resolving the compilation error.
2025-08-21 15:19:06 +09:00
Sergei Barannikov
b96d5c2452
[TableGen][DecoderEmitter] Outline InstructionEncoding constructor (NFC) (#154673)
It is going to grow, so it makes sense to move its definition
out of class. Instead, inline `populateInstruction()` into it.
Also, rename a couple of methods to better convey their meaning.
2025-08-21 06:08:57 +00:00
Abhishek Kaushik
62aaa96d6f
[SDAG[[X86] Added method to scalarize STRICT_FSETCC (#154486)
Fixes #154485
2025-08-21 11:27:27 +05:30
Carlos Galvez
3baddbbb0a
Do not trigger -Wmissing-noreturn on lambdas prior to C++23 (#154545)
Fixes #154493

Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
2025-08-21 07:30:57 +02:00
Jim Lin
3a715107c2 [RISCV] Fold argstr into class for XSMTVDot instructions. NFC.
All of them use the same argstr "$vd, $vs1, $vs2".
2025-08-21 13:12:46 +08:00
Craig Topper
2d3d8df0e0 [RISCV] Use RVPTernary_rrr for a few more instructions.
This doesn't really affect the assembler, but will
be important when we eventually do codegen.
2025-08-20 21:13:40 -07:00
Sergei Barannikov
d6679d5a5f
[Target] Remove SoftFail field on targets that don't use it (NFC) (#154659)
That is, on all targets except ARM and AArch64.
This field used to be required due to a bug, it was fixed long ago
by 23423c0ea8d414e56081cb6a13bd8b2cc91513a9.
2025-08-21 05:21:42 +03:00
Jordan Rupprecht
918c0ac762
[bazel] Port #154616: LDBG in ConvertToLLVMPass (#154661) 2025-08-20 21:21:14 -05:00
Jordan Rupprecht
90d601d50b
[bazel][LLVMIR] Port #145899: Add target attrs (#154660) 2025-08-21 01:59:41 +00:00
Sirui Mu
91569fa030
[CIR][NFC] Use Op::create to create CIR operations in CIRGenBuilder (#154540) 2025-08-21 09:46:45 +08:00
Aiden Grossman
c811f522f6
[ProfCheck] Add list of xfail tests (#154655)
This patch contains a list of tests that are currently failing in the
LLVM_ENABLE_PROFCHECK=ON build. This enables passing them to lit through
the LIT_XFAIL env variable. This is necessary for getting a buildbot
spun up to catch regressions while work is being done to fix the
existing issues.

We need to keep this in the LLVM tree so that tests can be removed from
the list at the same time the passes causing issues are fixed.

Issue #147390
2025-08-21 01:28:05 +00:00
Matt Arsenault
e414585545
AMDGPU: Add baseline test for mfma rewrite with phi (#153021) 2025-08-21 10:25:05 +09:00
Matt Arsenault
bcf41e03c7
AMDGPU: Add baseline test for vgpr mfma with copied-from AGPR (#153020) 2025-08-21 10:24:27 +09:00
Matt Arsenault
eefad7438c
AMDGPU: Handle rewriting VGPR MFMA to AGPR with subregister copies (#153019)
This should address the case where the result isn't fully used,
resulting in partial copy bundles from the MFMA result.
2025-08-21 01:17:03 +00:00
Jim Lin
fd28257195
[DAGCombiner] Fold umax/umin operations with vscale operands (#154461)
If umax/umin operations with vscale operands, that can be constant
folded.
2025-08-21 09:15:40 +08:00
PiJoules
3c8652e737
[compiler-rt][Fuchsia] Change GetMaxUserVirtualAddress to invoke syscall (#153309)
LSan was recently refactored to call GetMaxUserVirtualAddress for
diagnostic purposes. This leads to failures for some of our downstream
tests which only run with lsan. This occurs because
GetMaxUserVirtualAddress depends on setting up shadow via a call to
__sanitizer_shadow_bounds, but shadow bounds aren't set for standalone
lsan because it doesn't use shadow. This updates the function to invoke
the same syscall used by __sanitizer_shadow_bounds calls for getting the
memory limit. Ideally this function would only be called once since we
only need to get the bounds once.

More context in https://fxbug.dev/437346226.
2025-08-20 18:06:19 -07:00
Craig Topper
8cb6bfe05a [RISCV] Reduce ManualCodeGen for RVV intrinsics with rounding mode. NFC
Operate directly on the existing Ops vector instead of copying to
a new vector. This is similar to what the autogenerated codegen
does for other intrinsics.
2025-08-20 17:53:46 -07:00
Matt Arsenault
744cd8a9c6
AMDGPU: Add some baseline test for mfma rewrite with subregister copies (#153018)
Currently only cases rooted at a full copy of an MFMA result are
handled.
Prepare to relax that by testing more intricate subregister usage.

Currently only full copies are handled, add some tests to help work
towards handling subregisters.
2025-08-21 00:39:39 +00:00
Matt Arsenault
156f3fce54
AMDGPU: Handle rewriting VGPR MFMAs with immediate src2 (#153016) 2025-08-21 09:09:24 +09:00
Matt Arsenault
3a0fa12752
DAG: Handle half spanning extract_subvector in type legalization (#154101)
Previously it would just assert if the extract needed elements from
both halves. Extract the individual elements from both halves and
create a new vector, as the simplest implementation. This could
try to do better and create a partial extract or shuffle (or
maybe that's best left for the combiner to figure out later).

Fixes secondary issue noticed as part of #153808
2025-08-21 00:05:12 +00:00
Elvis Wang
d611a9ca15
[LV][VPlan] Reduce register usage of VPEVLBasedIVPHIRecipe. (#154482)
`VPEVLBasedIVPHIRecipe` will lower to VPInstruction scalar phi and
generate scalar phi. This recipe will only occupy a scalar register just
like other phi recipes.

This patch fix the register usage for `VPEVLBasedIVPHIRecipe` from
vector
to scalar which is close to generated vector IR.

https://godbolt.org/z/6Mzd6W6ha shows that no register spills when
choosing `<vscale x 16>`.

Note that this test is basically copied from AArch64.
2025-08-21 07:39:01 +08:00
Shih-Po Hung
cf0e86118d
[VPlan] Handle canonical VPWidenIntOrFpInduction in branch-condition simplification (#153539)
SimplifyBranchConditionForVFAndUF only recognized canonical IVs and a
few PHI
recipes in the loop header. With more IV-step optimizations,
the canonical widen-canonical-iv can be replaced by a canonical
VPWidenIntOrFpInduction,
which the pass did not handle, causing regressions (missed
simplifications).

This patch replaces canonical VPWidenIntOrFpInduction with a StepVector
in the vector preheader
since the vector loop region only executes once.
2025-08-21 07:34:54 +08:00
Kazu Hirata
9aae8ef329
[Scalar] Use SmallPtrSet directly instead of SmallSet (NFC) (#154473)
I'm trying to remove the redirection in SmallSet.h:

template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

to make it clear that we are using SmallPtrSet.  There are only
handful places that rely on this redirection.

This patch replaces SmallSet to SmallPtrSet where the element type is
a pointer.
2025-08-20 16:30:39 -07:00
Kazu Hirata
7be06dbd43
[lldb] Use SmallPtrSet directly instead of SmallSet (NFC) (#154472)
I'm trying to remove the redirection in SmallSet.h:

template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

to make it clear that we are using SmallPtrSet.  There are only
handful places that rely on this redirection.

This patch replaces SmallSet to SmallPtrSet where the element type is
a pointer.
2025-08-20 16:30:31 -07:00
Kazu Hirata
8a5b6b302e
[flang] Use SmallPtrSet directly instead of SmallSet (NFC) (#154471)
I'm trying to remove the redirection in SmallSet.h:

template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

to make it clear that we are using SmallPtrSet.  There are only
handful places that rely on this redirection.

This patch replaces SmallSet to SmallPtrSet where the element type is
a pointer.
2025-08-20 16:30:24 -07:00
Min-Yih Hsu
db0eceaa8b
[AMDGPU] Fix uncaught changes made by AMDGPUPreloadKernelArgumentsPass (#154645)
#153975 added a new test,
`test/CodeGen/AMDGPU/disable-preload-kernargs.ll`, that triggers an
assertion under `LLVM_ENABLE_EXPENSIVE_CHECKS` complaining about not
invalidating analyses even when the Pass made changes. It was caused by
the fact that the Pass only invalidates the analyses when number of
explicit arguments is greater than zero, while it is possible that some
functions will be removed even when there isn't any explicit argument,
hence the missed invalidation.
2025-08-20 16:23:23 -07:00
Matt Arsenault
ff5f396dac
AMDGPU: Handle rewriting non-tied MFMA to AGPR form (#153015)
If src2 and dst aren't the same register, to fold a copy
to AGPR into the instruction we also need to reassign src2
to an available AGPR. All the other uses of src2 also need
to be compatible with the AGPR replacement in order to avoid
inserting other copies somewhere else.

Perform this transform, after verifying all other uses are
compatible with AGPR, and have an available AGPR available at
all points (which effectively means rewriting a full chain of
mfmas and load/store at once).
2025-08-21 08:16:56 +09:00
Renaud Kauffmann
3856bb6bbf
[flang] [acc] Adding allocation to the recipe of scalar allocatables (#154643)
Currently the privatization recipe of a scalar allocatable is as follow:

```
 acc.private.recipe @privatization_ref_box_heap_i32 : !fir.ref<!fir.box<!fir.heap<i32>>> init {
  ^bb0(%arg0: !fir.ref<!fir.box<!fir.heap<i32>>>):
    %0 = fir.alloca !fir.box<!fir.heap<i32>>
    %1:2 = hlfir.declare %0 {uniq_name = "acc.private.init"} : (!fir.ref<!fir.box<!fir.heap<i32>>>) -> (!fir.ref<!fir.box<!fir.heap<i32>>>, !fir.ref<!fir.box<!fir.heap<i32>>>)
    acc.yield %1#0 : !fir.ref<!fir.box<!fir.heap<i32>>>
  }
```

This change adds the allocation for the scalar.
2025-08-20 16:04:57 -07:00
Mehdi Amini
62b29d9f76
[MLIR] Adopt LDBG() debug macro in BytecodeWriter.cpp (NFC) (#154642) 2025-08-20 22:45:39 +00:00
Mehdi Amini
908eebcb93
[MLIR] Adopt LDBG() macro in PDL ByteCodeExecutor (NFC) (#154641) 2025-08-20 22:40:52 +00:00
Ely Ronnen
8b64cd8be2
[lldb-dap] Add module symbol table viewer to VS Code extension #140626 (#153836)
- VS Code extension:
- Add module symbol table viewer using
[Tabulator](https://tabulator.info/) for sorting and formatting rows.
  - Add context menu action to the modules tree.
 - lldb-dap
   -  Add `DAPGetModuleSymbolsRequest` to get symbols from a module.
 
Fixes #140626

[Screencast From 2025-08-15
19-12-33.webm](https://github.com/user-attachments/assets/75e2f229-ac82-487c-812e-3ea33a575b70)
2025-08-21 00:31:48 +02:00
Joseph Huber
27fc9671f9 Revert "[libc] Enable wide-read memory operations by default on Linux (#154602)"
This reverts commit c80d1483c6d787edf62ff9e86b1e97af5eb5abf9.
2025-08-20 17:27:13 -05:00
Craig Topper
2cb7c46bf0 [RISCV] Add missing 'OrP' to comment in RISCVInstrInfoZb.td. NFC 2025-08-20 15:27:03 -07:00
Joseph Huber
c80d1483c6
[libc] Enable wide-read memory operations by default on Linux (#154602)
Summary:
This patch changes the linux build to use the wide reads on the memory
operations by default. These memory functions will now potentially read
outside of the bounds explicitly allowed by the current function. While
technically undefined behavior in the standard, plenty of C library
implementations do this. it will not cause a segmentation fault on linux
as long as you do not cross a page boundary, and because we are only
*reading* memory it should not have atomic effects.
2025-08-20 17:17:12 -05:00
Craig Topper
ac8f0bb070 [RISCV] Reduce ManualCodeGen for segment load/store intrinsics. NFC
Operate directly on the existing Ops vector instead of copying to
a new vector. This is similar to what the autogenerated codegen
does for other intrinsics.

This reduced the clang binary size by ~96kb on my local Release+Asserts
build.
2025-08-20 15:02:24 -07:00
Sergei Barannikov
46343ca374
[TableGen][DecoderEmitter] Add DecoderMethod to InstructionEncoding (NFC) (#154477)
We used to abuse Operands list to store instruction encoding's
DecoderMethod there. Let's store it in the InstructionEncoding class
instead, where it belongs.
2025-08-20 21:59:59 +00:00
Mehdi Amini
dbbd3f0d07
[MLIR] Adopt LDBG() macro in Affine/Analysis/Utils.cpp (NFC) (#154626) 2025-08-20 21:56:03 +00:00
Alan Zhao
904b4f5a27
[clang][timers][modules] Fix a timer being started when it's running (#154231)
`ASTReader::FinishedDeserializing()` calls
`adjustDeductedFunctionResultType(...)` [0], which in turn calls
`FunctionDecl::getMostRecentDecl()`[1]. In modules builds,
`getMostRecentDecl()` may reach out to the `ASTReader` and start
deserializing again. Starting deserialization starts `ReadTimer`;
however, `FinishedDeserializing()` doesn't call `stopTimer()` until
after it's call to `adjustDeductedFunctionResultType(...)` [2]. As a
result, we hit an assert checking that we don't start an already started
timer [3]. To fix this, we simply don't start the timer if it's already
running.

Unfortunately I don't have a test case for this yet as modules builds
are notoriously difficult to reduce.

[0]:
4d2288d318/clang/lib/Serialization/ASTReader.cpp (L11053)
[1]:
4d2288d318/clang/lib/AST/ASTContext.cpp (L3804)
[2]:
4d2288d318/clang/lib/Serialization/ASTReader.cpp (L11065-L11066)
[3]:
4d2288d318/llvm/lib/Support/Timer.cpp (L150)
2025-08-20 21:53:43 +00:00
Kazu Hirata
55551da200
[lldb] Add missing case statements for SubstBuiltinTemplatePack (#154606)
This patch fixes:

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4148:11:
error: enumeration value 'SubstBuiltinTemplatePack' not handled in
switch [-Werror,-Wswitch]
4148 |   switch (qual_type->getTypeClass()) {
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4852:11:
error: enumeration value 'SubstBuiltinTemplatePack' not handled in
switch [-Werror,-Wswitch]
4852 |   switch (qual_type->getTypeClass()) {
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:5153:11:
error: enumeration value 'SubstBuiltinTemplatePack' not handled in
switch [-Werror,-Wswitch]
5153 |   switch (qual_type->getTypeClass()) {
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~
2025-08-20 14:53:28 -07:00
Gang Chen
575fad2892
[AMDGPU] Upstream the Support for array of named barriers (#154604) 2025-08-20 14:53:03 -07:00
Mehdi Amini
d20a74e631
[MLIR] Adopt LDBG() macro in BasicPtxBuilderInterface.cpp (NFC) (#154625) 2025-08-20 21:51:17 +00:00
Mehdi Amini
4be19e27b5
[MLIR] Adopt LDBG() debug macros in Affine LoopAnalysis.cpp (NFC) (#154621) 2025-08-20 21:45:42 +00:00
Steven Wu
deab049b5c
[CAS] Add ActionCache to LLVMCAS Library (#114097)
ActionCache is used to store a mapping from CASID to CASID. The current
implementation of the ActionCache can only be used to associate the
key/value from the same hash context.

ActionCache has two operations: `put` to store the key/value and `get`
to
lookup the key/value mapping. ActionCache uses the same TrieRawHashMap
data structure to store the mapping, where is CASID of the key is the
hash to index the map.

While CASIDs for key/value are often associcate with actual CAS
ObjectStore, it doesn't provide the guarantee of the existence of such
object in any ObjectStore.
2025-08-20 14:42:44 -07:00
Ramkumar Ramachandra
0db57ab586
[VPlan] Improve code using onlyScalarValuesUsed (NFC) (#154564) 2025-08-20 22:38:00 +01:00
Julian Lettner
484d0408f9
[lldb] Fix source line annotations for libsanitizers traces (#154247)
When providing allocation and deallocation traces,
the ASan compiler-rt runtime already provides call
addresses (`TracePCType::Calls`).

On Darwin, system sanitizers (libsanitizers)
provides return address.  It also discards a few
non-user frames at the top of the stack, because
these internal libmalloc/libsanitizers stack
frames do not provide any value when diagnosing
memory errors.

Introduce and add handling for
`TracePCType::ReturnsNoZerothFrame` to cover this
case and enable libsanitizers traces line-level
testing.

rdar://157596927

---
Commit 1 is a mechanical refactoring to introduce
and adopt `TracePCType` enum to replace
`pcs_are_call_addresses` bool.  It preserve the
current behavior:
```
pcs_are_call_addresses:
  false  ->  TracePCType::Returns (default)
  true   ->  TracePCType::Calls
``` 

Best reviewed commit by commit.
2025-08-20 14:33:27 -07:00
Florian Hahn
7d33743324
[LV] Add tests for narrowing interleave groups with scalable vectors. 2025-08-20 22:31:24 +01:00
Andy Kaylor
59b33242af
[CIR][NFC] Fix warning in MemOrder lowering (#154609)
This fixes a warning about having a default case in a fully covered enum
switch statement.
2025-08-20 14:30:22 -07:00
Mehdi Amini
6445a75c98
[MLIR] Update MLIRContext to use the LDBG() style debug macro (NFC) (#154619) 2025-08-20 21:30:11 +00:00
Mehdi Amini
ffbc8da8b5
[MLIR] Migrate LICM utils to the LDBG() macro style logging (NFC) (#154615) 2025-08-20 21:29:50 +00:00
Mehdi Amini
780750bbf9
[MLIR] Adopt LDBG() debug macro in ConvertToLLVMPass (NFC) (#154616) 2025-08-20 21:29:35 +00:00
YongKang Zhu
5c4f506cca
[BOLT] Validate extra entry point by querying data marker symbols (#154611)
Look up marker symbols and decide whether candidate is really
extra entry point in `adjustFunctionBoundaries()`.
2025-08-20 14:18:56 -07:00
Mehdi Amini
5683baea6d
[MLIR] Adopt LDBG() debug macro in bufferization (NFC) (#154614) 2025-08-20 21:14:02 +00:00
Isaac Nudelman
c6fa115b2d
[clang][analyzer] Relax assertion for non-default address spaces in the cstring checker (#153498)
Prevent an assertion failure in the cstring checker when library
functions like memcpy are defined with non-default address spaces.

Adds a test for this case.
2025-08-20 16:07:54 -05:00
David Majnemer
0a7eabcc56 Reapply "[APFloat] Fix getExactInverse for DoubleAPFloat"
The previous implementation of getExactInverse used the following check
to identify powers of two:

  // Check that the number is a power of two by making sure that only the
  // integer bit is set in the significand.
  if (significandLSB() != semantics->precision - 1)
    return false;

This condition verifies that the only set bit in the significand is the
integer bit, which is correct for normal numbers. However, this logic is
not correct for subnormal values.

APFloat represents subnormal numbers by shifting the significand right
while holding the exponent at its minimum value. For a power of two in
the subnormal range, its single set bit will therefore be at a position
lower than precision - 1. The original check would consequently fail,
causing the function to determine that these numbers do not have an
exact multiplicative inverse.

The new logic calculated this correctly but it seems that
test/CodeGen/Thumb2/mve-vcvt-fixed-to-float.ll expected the old
behavior.

Seeing as how getExactInverse does not have tests or documentation, we
conservatively maintain (and document) this behavior.

This reverts commit 47e62e846beb267aad50eb9195dfd855e160483e.
2025-08-20 14:02:36 -07:00
Rolf Morel
cbfa265e98
[MLIR][LLVMIR][DLTI] Add LLVM::TargetAttrInterface and #llvm.target attr (#145899)
Adds the `#llvm.target<triple = $TRIPLE, chip = $CHIP, features =
$FEATURES>` attribute and along with a `-llvm-target-to-data-layout`
pass to derive a MLIR data layout from the LLVM data layout string
(using the existing `DataLayoutImporter`). The attribute implements the
relevant DLTI-interfaces, to expose the `triple`, `chip` (AKA `cpu`) and
`features` on `#llvm.target` and the full `DataLayoutSpecInterface`. The
pass combines the generated `#dlti.dl_spec` with an existing `dl_spec`
in case one is already present, e.g. a `dl_spec` which is there to
specify size of the `index` type.

Adds a `TargetAttrInterface` which can be implemented by all attributes
representing LLVM targets.

Similar to the Draft PR https://github.com/llvm/llvm-project/pull/78073.

RFC on which this PR is based:
https://discourse.llvm.org/t/mandatory-data-layout-in-the-llvm-dialect/85875
2025-08-20 22:00:30 +01:00
Shafik Yaghmour
2a66ce5edb
[Clang][NFC] Clarify some SourceManager related code (#153527)
Static analysis flagged the columns - 1 code, it was correct but the
assumption was not obvious. I document the assumption w/ assertions.

While digging through related code I found getColumnNumber that looks
wrong at first inspection and adding parentheses makes it clearer.
2025-08-20 13:57:37 -07:00
Philip Reames
e6b4a21849
[IR] Add utilities for manipulating length of MemIntrinsic [nfc] (#153856)
Goal is simply to reduce direct usage of getLength and setLength so that
if we end up moving memset.pattern (whose length is in elements) there
are fewer places to audit.
2025-08-20 13:50:11 -07:00
Valentin Clement (バレンタイン クレメン)
a4e8ec9de9
[flang][cuda][NFC] Add getDataAttr helper (#154586) 2025-08-20 13:46:29 -07:00
Dan Salvato
45e2c50256
[M68k] Fix reverse BTST condition causing opposite failure/success logic (#153086)
Given the test case:

```llvm
define fastcc i16 @testbtst(i16 %a) nounwind {
  entry:
    switch i16 %a, label %no [
      i16 11, label %yes
      i16 10, label %yes
      i16 9, label %yes
      i16 4, label %yes
      i16 3, label %yes
      i16 2, label %yes
    ]

  yes:
    ret i16 1

  no:
    ret i16 0
}
```

We currently get this result:

```asm
testbtst:                               ; @testbtst
; %bb.0:                                ; %entry
	move.l	%d0, %d1
	and.l	#65535, %d1
	sub.l	#11, %d1
	bhi	.LBB0_3
; %bb.1:                                ; %entry
	and.l	#65535, %d0
	move.l	#3612, %d1
	btst	%d0, %d1
	bne	.LBB0_3        ; <------- Erroneous condition
; %bb.2:                                ; %yes
	moveq	#1, %d0
	rts
.LBB0_3:                                ; %no
	moveq	#0, %d0
	rts
```

The cause of this is a line that explicitly reverses the `btst`
condition code. But on M68k, `btst` sets condition codes the same as
`and` with a bitmask, meaning `EQ` indicates failure (bit is zero) and
not success, so the condition does not need to be reversed.

In my testing, I've only been able to get switch statements to lower to
`btst`, so I wasn't able to explicitly test other options for lowering.
But (if possible to trigger) I believe they have the same logical error.
For example, in `LowerAndToBTST()`, a comment specifies that it's
lowering a case where the `and` result is compared against zero, which
means the corresponding `btst` condition should also not be reversed.

This patch simply flips the ternary expression in
`getBitTestCondition()` to match the ISD condition code with the same
M68k code, instead of the opposite.
2025-08-20 13:45:01 -07:00
Florian Hahn
4e6c88be7c
[TTI] Remove Args argument from getOperandsScalarizationOverhead (NFC). (#154126)
Remove the ArrayRef<const Value*> Args operand from
getOperandsScalarizationOverhead and require that the callers
de-duplicate arguments and filter constant operands.

Removing the Value * based Args argument enables callers where no Value
* operands are available to use the function in a follow-up: computing
the scalarization cost directly for a VPlan recipe.

It also allows more accurate cost-estimates in the future: for example,
when vectorizing a loop, we could also skip operands that are live-ins,
as those also do not require scalarization.

PR: https://github.com/llvm/llvm-project/pull/154126
2025-08-20 21:09:08 +01:00
David Green
4875553f4c [AArch64][GlobalISel] Port unmerge KnownBits tests to print<gisel-value-tracking>. NFC
This takes the known-bits tests added in #112172 and ports them over to be a
new print<gisel-value-tracking> test.
2025-08-20 20:57:14 +01:00
David Green
bd94aabfb6
[AArch64][GlobalISel] Remove Selection code for s/uitofp. NFC (#154488)
These are already handled by tablegen patterns.
2025-08-20 20:52:42 +01:00
Florian Hahn
b0d0e04693
[LV] Add test where we choose VF * IC is larger than trip count. 2025-08-20 20:40:49 +01:00
Matheus Izvekov
e1dbe093c4
[clang] build UnresolvedUsingType for constructor initializers (#154592)
When building the base type for constructor initializer, the case of an
UnresolvedUsingType was not being handled.

For the non-dependent case, we are also skipping adding the UsingType,
but this is just missing information in the AST. A FIXME for this is
added.

This fixes a regression introduced in #147835, which was never released,
so there are no release notes.

Fixes #154436
2025-08-20 16:24:41 -03:00
Gang Chen
60dbde69cd
[AMDGPU] report named barrier cnt part2 (#154588) 2025-08-20 12:00:45 -07:00
Tom Honermann
8ed9c6101f
[NFC] Remove unneeded forward declaration of diagnoseUncapturableValueReferenceOrBinding() (#154591)
The only (remaining) use of this forward declaration was removed in
commit 127bf44385424891eb04cff8e52d3f157fc2cb7c.
2025-08-20 14:57:53 -04:00
Kevin McAfee
691ccf263a
[NVPTX] Implement computeKnownBitsForTargetNode for LoadV (#154165)
Remove AND combines as they are no longer needed after this.
2025-08-20 18:57:15 +00:00
Leandro Lacerda
8d7b50e572
[Offload][Conformance] Add RandomGenerator for large input spaces (#154252)
This patch implements the `RandomGenerator`, a new input generator that
enables conformance testing for functions with large input spaces (e.g.,
double-precision math functions).

**Architectural Refactoring**

To support different generation strategies in a clean and extensible
way, the existing `ExhaustiveGenerator` was refactored into a new class
hierarchy:
* A new abstract base class, `RangeBasedGenerator`, was introduced using
the Curiously Recurring Template Pattern (CRTP). It contains the common
logic for generators that operate on a sequence of ranges.
* `ExhaustiveGenerator` now inherits from this base class, simplifying
its implementation.

**New Components**
* The new `RandomGenerator` class also inherits from
`RangeBasedGenerator`. It implements a strategy that randomly samples a
specified number of points from the total input space.
* Random number generation is handled by a new, self-contained
`RandomState` class (a `xorshift64*` PRNG seeded with `splitmix64`) to
ensure deterministic and reproducible random streams for testing.

**Example Usage**

As a first use case and demonstration of this new capability, this patch
also adds the first double-precision conformance test for the `log`
function. This test uses the new `RandomGenerator` to validate the
implementations from the `llvm-libm`, `cuda-math`, and `hip-math`
providers.
2025-08-20 13:37:01 -05:00
Joseph Huber
9888f0c3c4
[Clang] Add builtins for masked vector loads / stores (#154464)
Summary:
Clang has support for boolean vectors, these builtins expose the LLVM
instruction of the same name. This differs from a manual load and select
by potentially suppressing traps from deactivated lanes.

Fixes: https://github.com/llvm/llvm-project/issues/107753
2025-08-20 13:33:32 -05:00
Joseph Huber
2f6b747997
[Clang] Add queryable feature 'ext_vector_type_boolean' for SIMD masks (#154227)
Summary:
We added boolean vectors in clang 15 and wish to extend them further in
clang-22. However, there's no way to query for their support as they are
separate to the normal extended vector type. This adds a feature so we
can check for it as a feature directly.
2025-08-20 13:33:02 -05:00
Alexandre Ganea
410a1341b5 [clang][bytecode] Silence unused variable warning 2025-08-20 14:10:05 -04:00
Finn Plummer
15babbaf5d
[DirectX] Add boilerplate integration of objcopy for DXContainerObjectFile (#153079)
This pr implements the boiler plate required to use `llvm-objcopy` for
`DXContainer` object files.

It defines a minimal structure `object` to represent the `DXContainer`
header and the following parts.
This structure is a simple representation of the object data to allow
for simple modifications at the granularity of each part. It follows
similarily to how the respective `object`s are defined for `ELF`,
`wasm`, `XCOFF`, etc.

This is the first step to implement
https://github.com/llvm/llvm-project/issues/150275 and
https://github.com/llvm/llvm-project/issues/150277 as compiler actions
that invoke `llvm-objcopy` for functionality.
2025-08-20 10:58:42 -07:00
Michał Górny
d76bb2bb89
[mlir] Fix missing mlir-capi-global-constructors-test on standalone build (#154576)
Add `mlir-capi-global-constructors-test` to `MLIR_TEST_DEPENDS` when
`MLIR_ENABLE_EXECUTION_ENGINE` is enabled, to ensure that it is also
built during standalone builds, and therefore fix test failure due to
the executable being missing.

I don't understand the purpose of `LLVM_ENABLE_PIC AND TARGET
${LLVM_NATIVE_ARCH}` block, but the condition is not true in standalone
builds.

Fixes 7610b1372955da55e3dc4e2eb1440f0304a56ac8.
2025-08-20 19:50:07 +02:00
Krzysztof Parzyszek
9f1679190e
[flang][OpenMP] Update GetOmpObjectList, move to parser utils (#154389)
`GetOmpObjectList` takes a clause, and returns the pointer to the
contained OmpObjectList, or nullptr if the clause does not contain one.
Some clauses with object list were not recognized: handle all clauses,
and move the implementation to flang/Parser/openmp-utils.cpp.
2025-08-20 12:41:26 -05:00
Yitzhak Mandelbaum
2be52f309e
[clang][dataflow] Fix uninitialized memory bug. (#154575)
Commit #3ecfc03 introduced a bug involving an uninitialized field in
`exportLogicalContext`. This patch initializes the field properly.
2025-08-20 13:36:42 -04:00
Akash Banerjee
d69ccded4f
[MLIR] Add cpow support in ComplexToROCDLLibraryCalls (#153183)
This PR adds support for complex power operations (`cpow`) in the
`ComplexToROCDLLibraryCalls` conversion pass, specifically targeting
AMDGPU architectures. The implementation optimises complex
exponentiation by using mathematical identities and special-case
handling for small integer powers.

- Force lowering to `complex.pow` operations for the `amdgcn-amd-amdhsa`
target instead of using library calls
- Convert `complex.pow(z, w)` to `complex.exp(w * complex.log(z))` using
mathematical identity
2025-08-20 17:18:30 +00:00
Kazu Hirata
65de318d18 [Sema] Fix a warning
This patch fixes:

  clang/lib/Sema/SemaTemplateVariadic.cpp:1069:22: error: variable
  'TST' set but not used [-Werror,-Wunused-but-set-variable]
2025-08-20 09:56:27 -07:00
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
schittir
fdfcebb38d
[clang][SYCL] Add sycl_external attribute and restrict emitting device code (#140282)
This patch is part of the upstreaming effort for supporting SYCL
language front end.
It makes the following changes:
1. Adds sycl_external attribute for functions with external linkage,
which is intended for use to implement the SYCL_EXTERNAL macro as
specified by the SYCL 2020 specification
2. Adds checks to avoid emitting device code when sycl_external and
sycl_kernel_entry_point attributes are not enabled
3. Fixes test failures caused by the above changes

This patch is missing diagnostics for the following diagnostics listed
in the SYCL 2020 specification's section 5.10.1, which will be addressed
in a subsequent PR:
Functions that are declared using SYCL_EXTERNAL have the following
additional restrictions beyond those imposed on other device functions:
1. If the SYCL backend does not support the generic address space then
the function cannot use raw pointers as parameter or return types.
Explicit pointer classes must be used instead;
2. The function cannot call group::parallel_for_work_item;
3. The function cannot be called from a parallel_for_work_group scope.

In addition to that, the subsequent PR will also implement diagnostics
for inline functions including virtual functions defined as inline.

---------

Co-authored-by: Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>
2025-08-20 12:37:37 -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
Craig Topper
2b7b8bdc16
[X86] Accept the canonical form of a sign bit test in MatchVectorAllEqualTest. (#154421)
This function tries to look for (seteq (and (reduce_or), mask), 0). If
the mask is a sign bit, InstCombine will have turned it into (setgt
(reduce_or), -1). We should handle that case too.

I'm looking into adding the same canonicalization to SimplifySetCC and
this change is needed to prevent test regressions.
2025-08-20 09:09:55 -07:00
Craig Topper
562e021103
[RISCV] Minor refactor of RISCVMoveMerge::mergePairedInsns. (#154467)
Fold the ARegInFirstPair into the later if/else with the same condition.
Use std::swap so we don't need to repeat operands in the opposite order.
2025-08-20 09:07:58 -07:00
Matthias Springer
6a285cc8e6
[mlir][IR] Fix Block::without_terminator for blocks without terminator (#154498)
Blocks without a terminator are not handled correctly by
`Block::without_terminator`: the last operation is excluded, even when
it is not a terminator. With this commit, only terminators are excluded.
If the last operation is unregistered, it is included for safety.
2025-08-20 18:02:24 +02:00
Kazu Hirata
f487c0e63c [AST] Fix warnings
This patch fixes:

  clang/lib/AST/ByteCode/InterpBuiltin.cpp:1827:21: error: unused
  variable 'ASTCtx' [-Werror,-Wunused-variable]

  clang/lib/AST/ByteCode/InterpBuiltin.cpp:2724:18: error: unused
  variable 'Arg2Type' [-Werror,-Wunused-variable]

  clang/lib/AST/ByteCode/InterpBuiltin.cpp:2725:18: error: unused
  variable 'Arg3Type' [-Werror,-Wunused-variable]

  clang/lib/AST/ByteCode/InterpBuiltin.cpp:2748:18: error: unused
  variable 'ElemT' [-Werror,-Wunused-variable]
2025-08-20 08:58:59 -07:00
Yanzuo Liu
a6da68ed36
[Clang][ASTMatchers] Make hasConditionVariableStatement support for loop, while loop and switch statements (#154298)
Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-08-20 23:57:30 +08:00
Krzysztof Parzyszek
15cb06109d
[Frontend][OpenMP] Allow multiple occurrences of DYN_GROUPPRIVATE (#154549)
It was mistakenly placed in "allowOnceClauses" on the constructs that
allow it.
2025-08-20 10:56:30 -05:00
Samira Bakon
ffe21f1cd7
[clang][dataflow] Transfer more cast expressions. (#153066)
Transfer all casts by kind as we currently do implicit casts. This
obviates the need for specific handling of static casts.

Also transfer CK_BaseToDerived and CK_DerivedToBase and add tests for
these and missing tests for already-handled cast types.

Ensure that CK_BaseToDerived casts result in modeling of the fields of the derived class.
2025-08-20 11:40:06 -04:00
Mirko Brkušanin
80f3b376b3
[AMDGPU][GlobalISel] Combine for breaking s64 and/or into two s32 insts (#151731)
When either one of the operands is all ones in high or low parts,
splitting these opens up other opportunities for combines. One of two
new instructions will either be removed or become a simple copy.
2025-08-20 17:32:29 +02:00
Steven Wu
2cfba9678d
[FileSystem] Allow exclusive file lock (#114098)
Add parameter to file lock API to allow exclusive file lock. Both Unix
and Windows support lock the file exclusively for write for one process
and LLVM OnDiskCAS uses exclusive file lock to coordinate CAS creation.
2025-08-20 08:32:18 -07:00
Matthias Springer
0499d3a8cf
[mlir][Interfaces] Add hasUnknownEffects helper function (#154523)
I have seen misuse of the `hasEffect` API in downstream projects: users
sometimes think that `hasEffect == false` indicates that the operation
does not have a certain memory effect. That's not necessarily the case.
When the op does not implement the `MemoryEffectsOpInterface`, it is
unknown whether it has the specified effect. "false" can also mean
"maybe".

This commit clarifies the semantics in the documentation. Also adds
`hasUnknownEffects` and `mightHaveEffect` convenience functions. Also
simplifies a few call sites.
2025-08-20 15:24:53 +00:00
Louis Dionne
2e2349e4e9
[libc++] Add internal checks for some basic_streambuf invariants (#144602)
These invariants are always expected to hold, however it's not always
clear that they do. Adding explicit checks for these invariants inside
non-trivial functions of basic_streambuf makes that clear.
2025-08-20 11:09:39 -04:00
Florian Hahn
35be64a416
[VPlan] Factor out logic to common compute costs to helper (NFCI). (#153361)
A number of recipes compute costs for the same opcodes for scalars or
vectors, depending on the recipe.

Move the common logic out to a helper in VPRecipeWithIRFlags, that is
then used by VPReplicateRecipe, VPWidenRecipe and VPInstruction.

This makes it easier to cover all relevant opcodes, without duplication.

PR: https://github.com/llvm/llvm-project/pull/153361
2025-08-20 16:05:20 +01:00
Jordan Rupprecht
f1458ec623
[bazel] Port #153504: add llvm-offload-wrapper (#154553) 2025-08-20 15:01:46 +00:00
Timothy Choi
d282452e4c
[libc++] Avoid string reallocation in std::filesystem::path::lexically_relative (#152964)
Improves runtime by around 20 to 40%. (1.3x to 1.7x)

```
Benchmark                                                           Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------
BM_LexicallyRelative/small_path/2                                -0.2111         -0.2082           229           181           228           180
BM_LexicallyRelative/small_path/4                                -0.2579         -0.2550           455           338           452           337
BM_LexicallyRelative/small_path/8                                -0.2643         -0.2616           844           621           838           619
BM_LexicallyRelative/small_path/16                               -0.2582         -0.2556          1562          1158          1551          1155
BM_LexicallyRelative/small_path/32                               -0.2518         -0.2496          3023          2262          3004          2254
BM_LexicallyRelative/small_path/64                               -0.2806         -0.2775          6344          4564          6295          4549
BM_LexicallyRelative/small_path/128                              -0.2165         -0.2137         11762          9216         11683          9186
BM_LexicallyRelative/small_path/256                              -0.2672         -0.2645         24499         17953         24324         17891
BM_LexicallyRelative/large_path/2                                -0.3268         -0.3236           426           287           422           285
BM_LexicallyRelative/large_path/4                                -0.3274         -0.3248           734           494           729           492
BM_LexicallyRelative/large_path/8                                -0.3586         -0.3560          1409           904          1399           901
BM_LexicallyRelative/large_path/16                               -0.3978         -0.3951          2764          1665          2743          1659
BM_LexicallyRelative/large_path/32                               -0.3934         -0.3908          5323          3229          5283          3218
BM_LexicallyRelative/large_path/64                               -0.3629         -0.3605         10340          6587         10265          6564
BM_LexicallyRelative/large_path/128                              -0.3450         -0.3423         19379         12694         19233         12649
BM_LexicallyRelative/large_path/256                              -0.3097         -0.3054         36293         25052         35943         24965
```

---------

Co-authored-by: Nikolas Klauser <nikolasklauser@berlin.de>
2025-08-20 16:58:21 +02:00
erichkeane
30fcf69845 [OpenACC] Fixup rules for reduction clause variable refererence type
The standard is ambiguous, but we can only support
arrays/array-sections/etc of the composite type, so make sure we enforce
the rule that way. This will better support  how we need to do lowering.
2025-08-20 07:55:16 -07:00
Janek van Oirschot
40e1510146
[AMDGPU][NFC] Enable gfx942 for more tests (#154363)
Enable gfx942 for tests that are affected by the an AMDGPU bitcast
constant combine (#154115)

Expecting to see more tests affected in aforementioned PR after rebase
on top of this PR
2025-08-20 15:46:26 +01:00
Brox Chen
c50ed05cad
[AMDGPU][True16][CodeGen] use vgpr16 for zext patterns (reopen #153894) (#154211)
recreate this patch from
https://github.com/llvm/llvm-project/pull/153894

It seems ISel sliently ignore the `i64 = zext i16` with a chained
`reg_sequence` pattern and thus this is causing a selection failure in
hip test. Recreate a new patch with an alternative pattern, and added a
ll test global-extload-gfx11plus.ll
2025-08-20 10:26:49 -04:00
halbi2
2f237670b1
[Clang] [Sema] Enable nodiscard warnings for function pointers (#154250)
A call through a function pointer has no associated FunctionDecl, but it
still might have a nodiscard return type. Ensure there is a codepath to
emit the nodiscard warning in this case.

Fixes #142453
2025-08-20 14:14:35 +00:00
Anutosh Bhat
ea634fef56
[clang-repl] Fix InstantiateTemplate & Value test while building against emscripten (#154513)
Building with assertions flag (-sAssertions=2) gives me these 

```
[ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_3.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_3.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueWithAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment)
[ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_3.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_3.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '__clang_Interpreter_SetValueNoAlloc'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment)
[ RUN ] InterpreterTest.InstantiateTemplate Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_23.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_23.wasm RuntimeError: Aborted(Assertion failed: undefined symbol '_ZnwmPv26__clang_Interpreter_NewTag'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment)
[ RUN ] InterpreterTest.Value Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_36.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_36.wasm
[ RUN ] InterpreterTest.Value Aborted(Assertion failed: undefined symbol '_Z9getGlobalv'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Error in loading dynamic library incr_module_36.wasm: RuntimeError: Aborted(Assertion failed: undefined symbol '_Z9setGlobali'. perhaps a side module was not linked in? if this global was expected to arrive from a system library, try to build the MAIN_MODULE with EMCC_FORCE_STDLIBS=1 in the environment) Could not load dynamic lib: incr_module_36.wasm
```

**So we have some symbols missing here that are needed by the side
modules being created here.**

First 2 are needed by both tests 
Last 3 are needed for these lines accordingly in the Value test.


dc23869f98/clang/unittests/Interpreter/InterpreterTest.cpp (L355)

dc23869f98/clang/unittests/Interpreter/InterpreterTest.cpp (L364)

dc23869f98/clang/unittests/Interpreter/InterpreterTest.cpp (L365)

Everything should work as expected after this 
```
[----------] 9 tests from InterpreterTest
[ RUN      ] InterpreterTest.Sanity
[       OK ] InterpreterTest.Sanity (18 ms)
[ RUN      ] InterpreterTest.IncrementalInputTopLevelDecls
[       OK ] InterpreterTest.IncrementalInputTopLevelDecls (45 ms)
[ RUN      ] InterpreterTest.Errors
[       OK ] InterpreterTest.Errors (29 ms)
[ RUN      ] InterpreterTest.DeclsAndStatements
[       OK ] InterpreterTest.DeclsAndStatements (34 ms)
[ RUN      ] InterpreterTest.UndoCommand
/Users/anutosh491/work/llvm-project/clang/unittests/Interpreter/InterpreterTest.cpp:156: Skipped
Test fails for Emscipten builds

[  SKIPPED ] InterpreterTest.UndoCommand (0 ms)
[ RUN      ] InterpreterTest.FindMangledNameSymbol
[       OK ] InterpreterTest.FindMangledNameSymbol (85 ms)
[ RUN      ] InterpreterTest.InstantiateTemplate
[       OK ] InterpreterTest.InstantiateTemplate (127 ms)
[ RUN      ] InterpreterTest.Value
[       OK ] InterpreterTest.Value (608 ms)
[ RUN      ] InterpreterTest.TranslationUnit_CanonicalDecl
[       OK ] InterpreterTest.TranslationUnit_CanonicalDecl (64 ms)
[----------] 9 tests from InterpreterTest (1014 ms total)
```

This is similar to how we need to take care of some symbols while
building side modules during running cppinterop's test suite !
2025-08-20 14:14:19 +00:00
Mehdi Amini
6cedf6e604
[MLIR] Add missing handling for LLVM_LIT_TOOLS_DIR in mlir lit config (NFC) (#154542)
This is helping some windows users, here is the doc:

**LLVM_LIT_TOOLS_DIR**:PATH
The path to GnuWin32 tools for tests. Valid on Windows host. Defaults to
the empty string, in which case lit will look for tools needed for tests
(e.g. ``grep``, ``sort``, etc.) in your ``%PATH%``. If GnuWin32 is not
in your
``%PATH%``, then you can set this variable to the GnuWin32 directory so
that
  lit can find tools needed for tests in that directory.
2025-08-20 16:05:44 +02:00
David Sherwood
e172110d12
[LV] Don't calculate scalar costs for scalable VFs in setVectorizedCallDecision (#152713)
In setVectorizedCallDecision we attempt to calculate the scalar costs
for vectorisation calls, even for scalable VFs where we already know the
answer is Invalid. We can avoid doing unnecessary work by skipping this
completely for scalable vectors.
2025-08-20 15:00:31 +01:00
Matt Arsenault
694a488708
AMDGPU: Add pseudoinstruction for 64-bit agpr or vgpr constants (#154499)
64-bit version of 7425af4b7aaa31da10bd1bc7996d3bb212c79d88. We
still need to lower to 32-bit v_accagpr_write_b32s, so this has
a unique value restriction that requires both halves of the constant
to be 32-bit inline immediates. This only introduces the new
pseudo definitions, but doesn't try to use them yet.
2025-08-20 22:54:37 +09:00
Chaitanya Koparkar
f649605bcf
[clang] Enable constexpr handling for __builtin_elementwise_fma (#152919)
Fixes https://github.com/llvm/llvm-project/issues/152455.
2025-08-20 14:51:40 +01:00
Sirui Mu
318b0dda7c
[CIR] Add atomic load and store operations (#153814)
This patch adds support for atomic loads and stores. Specifically, it
adds support for the following intrinsic calls:

- `__atomic_load` and `__atomic_store`;
- `__c11_atomic_load` and `__c11_atomic_store`.
2025-08-20 21:49:04 +08:00
Ryotaro Kasuga
2330fd2f73
[LoopPeel] Add new option to peeling loops to convert PHI into IV (#121104)
LoopPeel currently considers PHI nodes that become loop invariants
through peeling. However, in some cases, peeling transforms PHI nodes
into induction variables (IVs), potentially enabling further
optimizations such as loop vectorization. For example:

```c
// TSVC s292
int im = N-1;
for (int i=0; i<N; i++) {
  a[i] = b[i] + b[im];
  im = i;
}
```

In this case, peeling one iteration converts `im` into an IV, allowing
it to be handled by the loop vectorizer.

This patch adds a new feature to peel loops when to convert PHIs into
IVs. At the moment this feature is disabled by default.

Enabling it allows to vectorize the above example. I have measured on
neoverse-v2 and observed a speedup of more than 60% (options: `-O3
-ffast-math -mcpu=neoverse-v2 -mllvm -enable-peeling-for-iv`).

This PR is taken over from #94900
Related #81851
2025-08-20 13:44:56 +00:00
Mehdi Amini
8b2028ced6
Update log_level for LLVM_DEBUG and associated macros (#154525)
During the review of #150855 we switched from 0 to 1 for the default log
level used, but this macro wasn't updated.
2025-08-20 13:31:13 +00:00
Nikita Popov
99119a5a81 [OpenMPIRBuilder] Add missing LLVM_ABI annotations 2025-08-20 15:19:08 +02:00
Nikita Popov
822496db7f [SampleContextTracker] Add missing LLVM_ABI annotations 2025-08-20 15:19:08 +02:00
Nikita Popov
7eb5031e2c [GlobalDCE] Add missing LLVM_ABI annotation 2025-08-20 15:19:08 +02:00
Nikita Popov
6a99ad2975 [Debug] Add missing LLVM_ABI annotations 2025-08-20 15:19:08 +02:00
Harrison Hao
23a5a7bef3
[AMDGPU] Support merging 16-bit and 8-bit TBUFFER load/store instruction (#145078)
SILoadStoreOptimizer can now recognise consecutive 16-bit and 8-bit
`TBUFFER_LOAD`/`TBUFFER_STORE` instructions that each write

* a single component (`X`), or
* two components (`XY`),

and fold them into the wider native variants:

```
X + X          -->  XY
X + X + X + X  -->  XYZW
XY + XY        -->  XYZW
X + X + X      -->  XYZ
XY + X         -->  XYZ
```

The optimisation cuts the number of TBUFFER instructions, shrinking code
size and improving memory throughput.
2025-08-20 21:16:25 +08:00
Zhaoxuan Jiang
2738828c0e
[Reland] [CGData] Lazy loading support for stable function map (#154491)
This is an attempt to reland #151660 by including a missing STL header
found by a buildbot failure.

The stable function map could be huge for a large application. Fully
loading it is slow and consumes a significant amount of memory, which is
unnecessary and drastically slows down compilation especially for
non-LTO and distributed-ThinLTO setups. This patch introduces an opt-in
lazy loading support for the stable function map. The detailed changes
are:

- `StableFunctionMap`
- The map now stores entries in an `EntryStorage` struct, which includes
offsets for serialized entries and a `std::once_flag` for thread-safe
lazy loading.
- The underlying map type is changed from `DenseMap` to
`std::unordered_map` for compatibility with `std::once_flag`.
- `contains()`, `size()` and `at()` are implemented to only load
requested entries on demand.

- Lazy Loading Mechanism
- When reading indexed codegen data, if the newly-introduced
`-indexed-codegen-data-lazy-loading` flag is set, the stable function
map is not fully deserialized up front. The binary format for the stable
function map now includes offsets and sizes to support lazy loading.
- The safety of lazy loading is guarded by the once flag per function
hash. This guarantees that even in a multi-threaded environment, the
deserialization for a given function hash will happen exactly once. The
first thread to request it performs the load, and subsequent threads
will wait for it to complete before using the data. For single-threaded
builds, the overhead is negligible (a single check on the once flag).
For multi-threaded scenarios, users can omit the flag to retain the
previous eager-loading behavior.
2025-08-20 06:15:04 -07:00
Charles Zablit
c56bb124e3
[lldb] make lit use the same PYTHONHOME for building and running the API tests (#154396)
When testing LLDB, we want to make sure to use the same Python as the
one we used to build it.

We already did this in https://github.com/llvm/llvm-project/pull/143183
for the Unit and Shell tests. This patch does the same thing for the API
tests as well.
2025-08-20 14:10:50 +01:00
Benjamin Maxwell
478b4b012f
[AArch64][SME] Rework VG CFI information for streaming-mode changes (#152283)
This patch reworks how VG is handled around streaming mode changes.

Previously, for functions with streaming mode changes, we would:

- Save the incoming VG in the prologue
- Emit `.cfi_offset vg, <offset>` and `.cfi_restore vg` around streaming
  mode changes

Additionally, for locally streaming functions, we would:

- Also save the streaming VG in the prologue
- Emit `.cfi_offset vg, <incoming VG offset>` in the prologue
- Emit `.cfi_offset vg, <streaming VG offset>` and `.cfi_restore vg`
  around streaming mode changes

In both cases, this ends up doing more than necessary and would be hard
for an unwinder to parse, as using `.cfi_offset` in this way does not
follow the semantics of the underlying DWARF CFI opcodes.

So the new scheme in this patch is to:

In functions with streaming mode changes (inc locally streaming)

- Save the incoming VG in the prologue
- Emit `.cfi_offset vg, <offset>` in the prologue (not at streaming mode
  changes)
- Emit `.cfi_restore vg` after the saved VG has been deallocated 
- This will be in the function epilogue, where VG is always the same as
  the entry VG
- Explicitly reference the incoming VG expressions for SVE callee-saves
in functions with streaming mode changes
- Ensure the CFA is not described in terms of VG in functions with
  streaming mode changes

A more in-depth discussion of this scheme is available in:
https://gist.github.com/MacDue/b7a5c45d131d2440858165bfc903e97b

But the TLDR is that following this scheme, SME unwinding can be
implemented with minimal changes to existing unwinders. All unwinders
need to do is initialize VG to `CNTD` at the start of unwinding, then
everything else is handled by standard opcodes (which don't need changes
to handle VG).
2025-08-20 14:06:12 +01:00
Hank
c075fb8c37
[MLIR] Fix duplicated attribute nodes in MLIR bytecode deserialization (#151267)
Fixes #150163 

MLIR bytecode does not preserve alias definitions, so each attribute
encountered during deserialization is treated as a new one. This can
generate duplicate `DISubprogram` nodes during deserialization.

The patch adds a `StringMap` cache that records attributes and fetches
them when encountered again.
2025-08-20 13:03:26 +00:00
Qihan Cai
5f0515debd
[RISCV] Support Remaining P Extension Instructions for RV32/64 (#150379)
This patch implements pages 15-17 from
jhauser.us/RISCV/ext-P/RVP-instrEncodings-015.pdf

Documentation:
jhauser.us/RISCV/ext-P/RVP-baseInstrs-014.pdf
jhauser.us/RISCV/ext-P/RVP-instrEncodings-015.pdf
2025-08-20 22:54:07 +10:00
Joseph Huber
5a929a4249
[Clang] Support using boolean vectors in ternary operators (#154145)
Summary:
It's extremely common to conditionally blend two vectors. Previously
this was done with mask registers, which is what the normal ternary code
generation does when used on a vector. However, since Clang 15 we have
supported boolean vector types in the compiler. These are useful in
general for checking the mask registers, but are currently limited
because they do not map to an LLVM-IR select instruction.

This patch simply relaxes these checks, which are technically forbidden
by
the OpenCL standard. However, general vector support should be able to
handle these. We already support this for Arm SVE types, so this should
be make more consistent with the clang vector type.
2025-08-20 07:49:26 -05:00
Michał Górny
29067ac6e1
[OpenMP][OMPD] Fix GDB plugin to work correctly when installed (#153956)
Fix the `sys.path` logic in the GDB plugin to insert the intended
self-path in the first position rather than appending it to the end. The
latter implied that if `sys.path` (naturally) contained the GDB's
`gdb-plugin` directory, `import ompd` would return the top-level
`ompd/__init__.py` module rather than the `ompd/ompd.py` submodule, as
intended by adding the `ompd/` directory to `sys.path`.

This is intended to be a minimal change necessary to fix the issue.
Alternatively, the code could be modified to import `ompd.ompd` and stop
modifying `sys.path` entirely. However, I do not know why this option
was chosen in the first place, so I can't tell if this won't break
something.

Fixes #153954

Signed-off-by: Michał Górny <mgorny@gentoo.org>
2025-08-20 14:36:50 +02:00
Ross Brunton
c8986d1ecb
[Offload] Guard olMemAlloc/Free with a mutex (#153786)
Both these functions update an `AllocInfoMap` structure in the context,
however they did not use any locks, causing random failures in threaded
code. Now they use a mutex.
2025-08-20 13:23:57 +01:00
Simeon David Schaub
4c295216e4
[SPIR-V] fix return type for OpAtomicCompareExchange (#154297)
fixes #152863

Tests were written with some help from Copilot

---------

Co-authored-by: Victor Lomuller <victor@codeplay.com>
2025-08-20 13:19:45 +01:00
David Green
c856e8def4 [ARM] Update cmps.ll, control-flow.ll and divrem.ll to use -cost-kind=all. NFC 2025-08-20 12:59:32 +01:00
Matt Arsenault
c876d53378
DAG: Avoid creating illegal extract_subvector in legalizer (#154100)
Fixes #153808
2025-08-20 20:55:05 +09:00
Jordan Rupprecht
876fdc9e29
[bazel] Port #154452: WasmSSA dialect importer (#154516) 2025-08-20 06:51:44 -05:00
Sergei Barannikov
19ac1ff56e
[TableGen][DecoderEmitter] Factor populateFixedLenEncoding (NFC) (#154511)
Also drop the debug code under `#if 0` and a seemingly outdated comment.
2025-08-20 11:34:59 +00:00
Morris Hafner
b01f05977c
[CIR] Add support for string literal lvalues in ConstantLValueEmitter (#154514) 2025-08-20 13:30:21 +02:00
Fraser Cormack
8b128388b5
[clang] Introduce elementwise ctlz/cttz builtins (#131995)
These builtins are modeled on the clzg/ctzg builtins, which accept an
optional second argument. This second argument is returned if the first
argument is 0. These builtins unconditionally exhibit zero-is-undef
behaviour, regardless of target preference for the other ctz/clz
builtins. The builtins have constexpr support.

Fixes #154113
2025-08-20 12:18:28 +01:00
Simon Pilgrim
d770567a51
[X86] SimplifyDemandedVectorEltsForTargetNode - don't split X86ISD::CVTTP2UI nodes without AVX512VL (#154504)
Unlike CVTTP2SI, CVTTP2UI is only available on AVX512 targets, so we
don't fallback to the AVX1 variant when we split a 512-bit vector, so we
can only use the 128/256-bit variants if we have AVX512VL.

Fixes #154492
2025-08-20 12:18:10 +01:00
Florian Hahn
dc23869f98
[LV] Handle vector trip count being zero in preparePlanForEpiVectorLoop.
After a485e0e, we may not set the vector trip count in
preparePlanForEpilogueVectorLoop if it is zero. We should not choose a
VF * UF that makes the main vector loop dead (i.e. vector trip count is
zero), but there are some cases where this can happen currently.

In those cases, set EPI.VectorTripCount to zero.
2025-08-20 11:54:22 +01:00
Morris Hafner
0989ff5de8
[CIR] Add constant attribute to GlobalOp (#154359)
This patch adds the constant attribute to cir.global, the appropriate
lowering to LLVM constant and updates the tests.

---------

Co-authored-by: Andy Kaylor <akaylor@nvidia.com>
2025-08-20 12:53:00 +02:00
Morris Hafner
3b9664840b
[CIR] Implement__builtin_va_arg (#153834)
Part of https://github.com/llvm/llvm-project/issues/153286.
Depends on https://github.com/llvm/llvm-project/pull/153819.

This patch adds support for __builtin_va_arg by adding the cir.va.arg
operator. Unlike the incubator it doesn't depend on any target specific
lowering (yet) but maps to llvm.va_arg.
2025-08-20 12:52:11 +02:00
Charles Zablit
93189ec514
Revert "[lldb][windows] use Windows APIs to print to the console (#149493)" (#154423)
This reverts commit f55dc0824ebcf546b1d34a5102021c15101e4d3b in order to
fix the issue reported
[here](https://github.com/llvm/llvm-project/pull/149493#issuecomment-3201146559).
2025-08-20 11:45:34 +01:00
Morris Hafner
088555cf6b
[CIR] Add support for base classes in type conversion safety check (#154385)
This patch enables the record layout computation of types that are
derived more than once.
2025-08-20 12:44:26 +02:00
DanilaZhebryakov
0a3ee7de9c
[PowerPC] fix bug affecting float to int32 conversion on LE PowerPC (#150194)
When moving fcti results from float registers to normal registers
through memory, even though MPI was adjusted to account for endianness,
FIPtr was always adjusted for big-endian, which caused loads of wrong
half of a value in little-endian mode.
2025-08-20 12:37:14 +02:00
Nikita Popov
fea7e6934a
[PowerPC] Remove custom original type tracking (NFCI) (#154090)
The OrigTy is passed to CC lowering nowadays, so use it directly instead
of custom pre-analysis.
2025-08-20 12:36:23 +02:00
Charles Zablit
af5f16ba91
[lldb][windows] remove duplicate implementation of UTF8ToUTF16 (#154424)
`std::wstring AnsiToUtf16(const std::string &ansi)` is a
reimplementation of `llvm::sys::windows::UTF8ToUTF16`. This patch
removes `AnsiToUtf16` and its usages entirely.
2025-08-20 11:30:51 +01:00
Marco Elver
e2a077fed9
Thread Safety Analysis: Graduate ACQUIRED_BEFORE() and ACQUIRED_AFTER() from beta features (#152853)
Both these attributes were introduced in ab1dc2d54db5 ("Thread Safety
Analysis: add support for before/after annotations on mutexes") back in
2015 as "beta" features.

Anecdotally, we've been using `-Wthread-safety-beta` for years without
problems.

Furthermore, this feature requires the user to explicitly use these
attributes in the first place.

After 10 years, let's graduate the feature to the stable feature set,
and reserve `-Wthread-safety-beta` for new upcoming features.
2025-08-20 12:17:52 +02:00
Paul Walker
d6a688fb3d
[LLVM][CodeGen][SME] hasB16b16() is not sufficient to prove BFADD availability. (#154143)
The FEAT_SVE_B16B16 arithmetic instructions are only available to
streaming mode functions when SME2 is available.
2025-08-20 11:12:43 +01:00
SivanShani-Arm
460e9a8837
[LLVM][AArch64] Build attributes: Support switching to a defined subsection by name only (#154159)
The AArch64 build attribute specification now allows switching to an
already-defined subsection using its name alone, without repeating the
optionality and type parameters.

This patch updates the parser to support that behavior.

Spec reference: https://github.com/ARM-software/abi-aa/pull/230/files
2025-08-20 10:50:48 +01:00
Nikita Popov
5ae749b77d
[FunctionAttr] Invalidate callers with mismatching signature (#154289)
If FunctionAttrs infers additional attributes on a function, it also
invalidates analysis on callers of that function. The way it does this
right now limits this to calls with matching signature. However, the
function attributes will also be used when the signatures do not match.
Use getCalledOperand() to avoid a signature check.

This is not a correctness fix, just improves analysis quality. I noticed
this due to
https://github.com/llvm/llvm-project/pull/144497#issuecomment-3199330709,
where LICM ends up with a stale MemoryDef that could be a MemoryUse
(which is a bug in LICM, but still non-optimal).
2025-08-20 11:38:31 +02:00
Nikita Popov
5dbf73f54d
[Lanai] Use ArgFlags to distinguish fixed parameters (#154278)
Whether the argument is fixed is now available via ArgFlags, so make use
of it. The previous implementation was quite problematic, because it
stored the number of fixed arguments in a global variable, which is not
thread safe.
2025-08-20 11:38:02 +02:00
jyli0116
9df7ca1f0f
[GlobalISel] Legalize Saturated Truncate instructions and intrinsics (#154340)
Adds legalization support for `G_TRUNC_SSAT_S`, `G_TRUNC_SSAT_S`,
`G_TRUNC_USAT_U` instructions for GlobalISel.
2025-08-20 10:37:22 +01:00
Younan Zhang
5f9630b388
[Clang] Reapply "Only remove lambda scope after computing evaluation context" (#154458)
The immediate evaluation context needs the lambda scope info to
propagate some flags, however that LSI was removed in
ActOnFinishFunctionBody which happened before rebuilding a lambda
expression.

The last attempt destroyed LSI at the end of the block scope, after
which we still need it in DiagnoseShadowingLambdaDecls.

This also converts the wrapper function to default arguments as a
drive-by fix, as well as does some cleanup.

Fixes https://github.com/llvm/llvm-project/issues/145776
2025-08-20 17:30:33 +08:00
Link
46e77ebf71
[RISCV][NFC] Ensure files end with newline. (#154457)
Add trailing newlines to the following files to comply with POSIX
standards:
- llvm/lib/Target/RISCV/RISCVInstrInfoXSpacemiT.td
- llvm/test/MC/RISCV/xsmtvdot-invalid.s
- llvm/test/MC/RISCV/xsmtvdot-valid.s

Closes #151706
2025-08-20 17:18:16 +08:00
Orlando Cazalet-Hyams
6c9352530a
[RemoveDIs][NFC] Clean up BasicBlockUtils now intrinsics are gone (#154326)
A couple of minor readability changes now that we're not supporting both
intrinsics and records.
2025-08-20 10:03:44 +01:00
Jim Lin
174135863f [OMPIRBuilder] Use CreateNUWMul instead of passing flags to CreateMul. NFC 2025-08-20 17:00:17 +08:00
Jie Fu
80bc38bc92 [RISCV] Silent a warning (NFC)
/llvm-project/clang/lib/CodeGen/Targets/RISCV.cpp:865:9:
 error: unused variable 'FixedSrcTy' [-Werror,-Wunused-variable]
  auto *FixedSrcTy = cast<llvm::FixedVectorType>(SrcTy);
        ^
1 error generated.
2025-08-20 16:59:12 +08:00
Simon Pilgrim
035f40e8d5 [RISCV] incorrect-extract-subvector-combine.ll - remove quotes around -mattr argument. NFC.
The unnecessary quotes prevents DOS scripts from executing the RUN line.
2025-08-20 09:57:45 +01:00
Luc Forget
95fbc18a70
[MLIR][Wasm] Extending Wasm binary to WasmSSA dialect importer (#154452)
This is a cherry pick of #154053 with a fix for bad handling of
endianess when loading float and double litteral from the binary.

---------

Co-authored-by: Ferdinand Lemaire <ferdinand.lemaire@woven-planet.global>
Co-authored-by: Jessica Paquette <jessica.paquette@woven-planet.global>
Co-authored-by: Luc Forget <luc.forget@woven.toyota>
2025-08-20 10:55:55 +02:00
Kerry McLaughlin
c34cba0413
[AArch64][SME] Lower aarch64.sme.cnts* to vscale when in streaming mode (#154305)
In streaming mode, both the @llvm.aarch64.sme.cnts and @llvm.aarch64.sve.cnt
intrinsics are equivalent. For SVE, cnt* is lowered in instCombineIntrinsic
to @llvm.sme.vscale(). This patch lowers the SME intrinsic similarly when
in streaming-mode.
2025-08-20 09:48:36 +01:00
Guillaume Chatelet
4dd9e99284
[libc] Fix constexpr add_with_carry/sub_with_borrow (#154282)
The previous version of the code would prevent the use of the compiler
builtins.
2025-08-20 10:41:51 +02:00
Brandon Wu
52a2e68fda
[clang][RISCV] Fix crash on VLS calling convention (#145489)
This patch handle struct of fixed vector and struct of array of fixed
vector correctly for VLS calling convention in EmitFunctionProlog,
EmitFunctionEpilog and EmitCall.

stack on: https://github.com/llvm/llvm-project/pull/147173
2025-08-20 16:39:02 +08:00
Timm Baeder
e16ced3ef4
[clang][bytecode] Diagnose one-past-end reads from global arrays (#154484)
Fixes #154312
2025-08-20 10:34:44 +02:00
Amr Hesham
018c5ba161
[CIR] Implement MemberExpr with VarDecl for ComplexType (#154307)
This change adds support for MemberExpr with VarDecl ComplexType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-20 10:33:08 +02:00
Nikolas Klauser
2dc0a5f3cd
[libc++][NFC] Use early returns in a few basic_string functions (#137299)
Using early returns tends to make the code easier to read, without any
changes to the generated code.
2025-08-20 10:16:13 +02:00
Matt Arsenault
0fa6fdfbb8
AMDGPU: Correct inst size for av_mov_b32_imm_pseudo (#154459)
In the AGPR case this will be an 8 byte instruction,
which is part of why this case is a pain to deal with in the
first place.
2025-08-20 17:01:48 +09:00
Benjamin Maxwell
eb2af3a5be
[ComplexDeinterleaving] Use BumpPtrAllocator for CompositeNodes (NFC) (#153217)
I was looking over this pass and noticed it was using shared pointers
for CompositeNodes. However, all nodes are owned by the deinterleaving
graph and are not released until the graph is destroyed. This means a
bump allocator and raw pointers can be used, which have a simpler
ownership model and less overhead than shared pointers.

The changes in this PR are to:
- Add a `SpecificBumpPtrAllocator<CompositeNode>` to the
`ComplexDeinterleavingGraph`
- This allocates new nodes and will deallocate them when the graph is
destroyed
  - Replace `NodePtr` and `RawNodePtr` with  `CompositeNode *`
2025-08-20 08:59:31 +01:00
David Green
e3cf967cdf [AArch64] Regenerate and update itofp.ll and fptoi.ll
This updates the fp<->int tests to include some store(fptoi) and itofp(load)
test cases. It also cuts down on the number of large vector cases which are not
testing anything new.
2025-08-20 08:43:10 +01:00
Lang Hames
70e41a2ab1
[orc-rt] Add orc_rt::span, a pre-c++20 std::span substitute (#154478)
This patch introduces an orc_rt::span class template that the ORC
runtime can use until we're able to move to c++20.
2025-08-20 17:28:02 +10:00
Timm Baeder
a9de444aa1
[clang][bytecode][NFC] Use an anonymous union in Pointer (#154405)
So we can save ourselves writing PointeeStorage all the time.
2025-08-20 09:23:19 +02:00
petergrind3
27f32831b9
[lanai] Add back the ability to set the memory model with --mcmodel. (#150575)
This ability got removed at some point but is still needed to select specific modes for Lanai backend. Add back with simple frontend smoke test.
2025-08-20 09:05:23 +02:00
Jean-Didier PAILLEUX
e4334afca0
[flang] Add support of THIS_IMAGE and NUM_IMAGES with PRIF (#154081)
In relation to the approval and merge of the
https://github.com/llvm/llvm-project/pull/76088 specification about
multi-image features in Flang.
Here is a PR on adding support for `THIS_IMAGE` and `NUM_IMAGES` in
conformance with the PRIF specification.
For `THIS_IMAGE`, the lowering to the subroutine containing the coarray
argument is not present in this PR, and will be in a future one.
2025-08-20 08:11:42 +02:00
Craig Topper
a872c4c785
[RISCV] Add SMT_ prefix to XSMTVDot instructions. NFC (#154475)
This helps avoid future name conflicts.
2025-08-19 22:54:55 -07:00
Kazu Hirata
9411347e8c
[clang] Proofread StandardCPlusPlusModules.rst (#154474) 2025-08-19 22:45:19 -07:00
Kazu Hirata
fab0860685
[AMDGPU] Remove an unnecessary cast (NFC) (#154470)
getAddressableLocalMemorySize() already returns unsigned.
2025-08-19 22:45:12 -07:00
Rajat Bajpai
fad3272286
[NVPTX] Add support for "blocksareclusters" kernel attr (#152265)
This change introduces a new kernel attribute that allows thread blocks to be mapped to clusters.

In addition, it also adds support of `+ptx90` PTX ISA support.
2025-08-20 11:09:39 +05:30
Mythreya Kuricheti
d0cde323c3
[clang][CodeComplete] Do not suggest unqualified members in explicit-object member functions (#153760)
Fixes https://github.com/llvm/llvm-project/issues/141291
2025-08-20 01:24:04 -04:00
Timm Baeder
32ba045bea
[clang][bytecode] Fix comparing pointers to union members (#154342)
If one of them is a one-past-end pointer.
2025-08-20 07:09:20 +02:00
Lang Hames
c6fbd12226
[orc-rt] Fix unit tests. (#154469)
orc-rt/test/unit/lit.site.cfg.py.in was pointing to the lit.cfg.py file for the
regression tests, causing the `check-orc-rt-unit` target to re-run the
regression tests rather than running the unit tests.
2025-08-20 14:51:13 +10:00
dyung
18e6cfda96
Update test added in #154418 to work when the default is C++20. (#154463) 2025-08-19 21:39:20 -07:00
Sergei Barannikov
9ae0bd2c9f
[TableGen][DecoderEmitter] Move Operands to InstructionEncoding (NFCI) (#154456)
This is where they belong, no need to maintain a separate map keyed by
encoding ID.
`populateInstruction()` has been made a member of `InstructionEncoding`
and is now called from the constructor.
2025-08-20 07:10:34 +03:00
Craig Topper
d145dc10b6
[RISCV] Reduce code duplication in RISCVMoveMerge::findMatchingInst. NFCI (#154451) 2025-08-19 21:08:57 -07:00
Chuanqi Xu
2db239acd1 [C++20] [Modules] Improve the import-and-include pattern
The import and include problem is a long-standing issue with the use of
C++20 modules. This patch tried to improve this by skipping parsing
class and functions if their declaration is already defined in modules.

The scale of the patch itself is small as the patch reuses previous
optimization. Maybe we can skip parsing other declarations in the
future. But the patch itself should be good.
2025-08-20 11:47:00 +08:00
Jim Lin
78e3ab306f [RISCV] Update some tests to use a common check prefix. NFC.
To make it easier to see that the codegen is the same across different options.
2025-08-20 11:29:57 +08:00
Phoebe Wang
99a1d5f7fa
[X86][APX] Remove CF feature from APXF and Diamond Rapids (#153751)
Due to it results in more losses than gains.
2025-08-20 03:07:56 +00:00
Fangrui Song
c940c242fc
tsan: Refine conditions to intercept pthread_cond_t functions
On glibc x86-64, functions like pthread_cond_init exist in two versions:
2.2 (older pthread_cond_t) and 2.3.2 (newer pthread_cond_t). In glibc
versions prior to 2.36, using an unversioned interceptor
(`dlsym(RTLD_NEXT, "pthread_cond_init")`) retrieves the older 2.2
symbol, which is not desired
(https://sourceware.org/bugzilla/show_bug.cgi?id=14932).

For newer architectures, such as aarch64 (introduced in glibc 2.17) and
riscv64 (introduced in glibc 2.27), a versioned interceptor is
unnecessary.

Pull Request: https://github.com/llvm/llvm-project/pull/154268
2025-08-19 20:07:23 -07:00
Chuanqi Xu
1fb2331e82 [NFC] [C++20] [Modules] Add a test to show the ability to skip bodies for import first and include later
For the common pattern:

```C++
module;
export module a;
...
```

```C++
// a.cpp
import a;
```

In this case, we're already able to skip parsing the body of some
declarations in a.cpp. Add a test to show the ability.
2025-08-20 10:14:01 +08:00
Owen Anderson
4f683b10b5
[RISCV] When resolving extension implications, handle the default I/E case after implications are resolved. (#154353)
This is needed to handle the scenario of an extension that implies
FeatureStdExtE, as is the case for the
downstream FeatureVendorXCheriot used for Cheriot support.
2025-08-20 09:59:23 +08:00
Sergei Barannikov
8666ffdd15 [TableGen][DecoderEmitter] Rename some variables (NFC)
And change references to pointers, to make the future diff smaller.
2025-08-20 04:55:07 +03:00
tangaac
bf6d52a2dd
[LoongArch] Pre-commit for vecreduce_add. (#154302) 2025-08-20 09:12:47 +08:00
Shilei Tian
7905d5e364
[AMDGPU] Add support for store to constant address space (#153835)
Since we don't stores to the constant address space as IR verifier
errors, we need to support their lowering.

Fixes SWDEV-499366.
2025-08-19 21:04:35 -04:00
Luo, Yuanke
ba6bb6929e
[RegAlloc] Fix register's live range for early-clobber (#152895)
When rematerialize a virtual register the register may be early
clobbered.
However rematerializeAt(...) just return the slot index of Slot_Register
which cause mis-calculating live range for the register

---------

Co-authored-by: Yuanke Luo <ykluo@birentech.com>
2025-08-20 09:02:59 +08:00
Matt Arsenault
276c1d8114
DAG: Add assert to getNode for EXTRACT_SUBVECTOR indexes (#154099)
Verify it's a multiple of the result vector element count
instead of asserting this in random combines.

The testcase in #153808 fails in the wrong point. Add an
assert to getNode so the invalid extract asserts at construction
instead of use.
2025-08-20 09:55:43 +09:00
Tomahawkd
c97322d048
[compiler-rt][hwasan] Add fiber switch for HwASan (#153822)
Currently HwASan has no fiber switch interface for coroutines. This PR
adds fiber switch interfaces similar to ASan which helps to pass sp
check correctly on unwinding.

The only difference is HwASan does not need a fake stack since tags can
do the same thing (e.g., detect UAR). Interfaces are made identical with
ASan's.

Also adds unit test which is similar to ASan with minor adjustments:

1. change `__asan_handle_no_return` to `__hwasan_handle_vfork`
2. remove huge stack test since `__hwasan_handle_vfork` has no stack
size limitation.
3. use uninstrumented globals to simulate allocation since hwasan do not
support tagged pointer while using `longjmp`

The testcase is tested on both x86 with alias mode enabled and aarch64.
2025-08-19 17:48:44 -07:00
Matt Arsenault
1f0af171cd
AMDGPU: Fix using illegal extract_subvector indexes (#154098) 2025-08-20 00:35:09 +00:00
Oliver Hunt
19c4e86f3e
[clang][PAC][darwin] Set correct default ptrauth features for arm64e-darwin (#153722)
This PR makes sure that when targeting arm64e on darwin platforms the
correct flags are set for the userspace platform ABI.
2025-08-19 17:31:14 -07:00
Phoebe Wang
4ae3c77066
[TTI][X86][APX] Calculate registers number according to FP or not (#154257) 2025-08-20 08:26:50 +08:00
Sergei Barannikov
6462223853 [TableGen] Make ParseOperandName method const (NFC)
Also change its name to start with a lowercase letter and update
the doxygen comment to conform to the coding standard.
2025-08-20 03:21:15 +03:00
Gang Chen
ef68d1587d
[AMDGPU] upstream barrier count reporting part1 (#154409) 2025-08-19 16:42:31 -07:00
AZero13
f94290cbff
[ValueTracking][GlobalISel] UCMP and SCMP cannot create undef or poison (#154404)
They cannot make poison or undef, same for IR. They can only make -1, 0,
or 1

Alive 2: https://alive2.llvm.org/ce/z/--Jd78
2025-08-20 08:41:27 +09:00
David CARLIER
c9f037622f
[compiler-rt][memprof] adding free_sized/free_aligned_sized intercept… (#154011)
…ions.
2025-08-20 00:27:08 +01:00
Sergei Barannikov
803edce6f7
[TableGen][DecoderEmitter] Analyze encodings once (#154309)
Follow-up to #154288.

With HwModes involved, we used to analyze the same encoding multiple
times (unless `-suppress-per-hwmode-duplicates=O2` is specified). This
affected the build time and made the statistics inaccurate.

From the point of view of the generated code, this is an NFC.
2025-08-19 23:17:12 +00:00
Jonas Devlieghere
7cd61793ed
[lldb] Improve error handling in ObjectFileWasm (#154433)
Improve error handling in ObjectFileWasm by using helpers that wrap
their result in an llvm::Expected. The helper to read a Wasm string now
return an Expected<std::string> and I created a helper to parse 32-bit
ULEBs that returns an Expected<uint32_t>.
2025-08-19 16:00:31 -07:00
Valentin Clement (バレンタイン クレメン)
f64b5c9c6f
[flang][cuda] Fix hasDataAttr signature in header file (#154435)
Fix for #154422
2025-08-19 22:49:57 +00:00
Andres-Salamanca
577ee97d4e
[CIR] Fix access to bitfields inside a union (#154398)
This PR fixes the access to bitfields inside a union.
Previously, we were using a `getMemberOp` to access the field, but
because it is a union, `getMemberOp` would always use index `0`.

For example, given:
```c
typedef union {
  int x;
  int y : 4;
  int z : 8;
} demo;
```
```mlir
!rec_demo = !cir.record<union "demo" {!s32i, !u8i, !u8i}>
```

In the case of:

```c
d.y = 2;
```

It would generate:

```mlir
cir.get_member %0[0] {name = "y"} : !cir.ptr<!rec_demo> -> !cir.ptr<!s32i>
```

with a return type of `!s32i`, when it should be `!u8i`.
the get_member verifier would detect that the return type does not match
the `y` member.
To fix this, we now use `bitcast` to get the start of the union.
2025-08-19 17:43:13 -05:00
Sirraide
7f20c6c29e
[Clang] [Sema] Always rebuild this if captured by value in a lambda with a dependent explicit object parameter (#154276)
We have a flag that tracks whether a `CXXThisExpr` refers to a `*this`
capture in a lambda with a dependent explicit object parameter; this is
to mark it and member accesses involving it as dependent because there
is no other way to track that (DREs have a similar flag); when
instantiating the lambda, we need to always rebuild the `CXXThisExpr` to
potentially clear that flag if the explicit object parameter is no
longer dependent.

Fixes #154054.
2025-08-20 00:37:48 +02:00
Craig Topper
58c41b7491 [ExpandVectorPredication] Use IRBuilder::CreateNUWMul instead of passing flags to CreateMul. NFC 2025-08-19 15:31:15 -07:00
Sergei Barannikov
07a6323c32
[TableGen][DecoderEmitter] Turn EncodingAndInst into a class (NFC) (#154230)
The class will get more methods in follow-up patches.
2025-08-20 01:29:26 +03:00
Matheus Izvekov
227e88b943
[clang-tidy] fix misc-unconventional-assign-operator entity match (#154430)
Makes sure UnconventionalAssignOperatorCheck checks if the types
reference the same entity, not the exact declaration.

This adds a new matcher to support this check.

This fixes a regression introduced by #147835. Since this regression was
never released, there are no release notes.

Fixes #153770
2025-08-19 19:28:41 -03:00
Sterling-Augustine
317920063b
Add vector-based strlen implementation for x86_64 and aarch64 (#152389)
These replace the default LIBC_CONF_STRING_UNSAFE_WIDE_READ
implementation
on x86_64 and aarch64.

These are substantially faster than both the character-by-character
implementation and the original unsafe_wide_read implementation. Some
below
I have been unable to performance-test the aarch64 version, but I
suspect
speedups similar to avx2.

```
Function: strlen
Variant:
                                    char	       wide              	ull	        sse2	                 avx2           	avx512
=============================================================================================================================================================
   length=1, alignment=1:        13.18	       20.47 (-55.24%)	       20.21 (-53.27%)	       32.50 (-146.54%)	       26.05 (-97.61%)	       18.03 (-36.74%)
   length=1, alignment=0:        12.80	       34.92 (-172.89%)	       20.01 (-56.39%)	       17.52 (-36.86%)	       17.78 (-38.92%)	       18.04 (-40.94%)
   length=2, alignment=2:         9.91	       19.02 (-91.95%)	       12.64 (-27.52%)	       11.06 (-11.59%)	        9.48 (  4.38%)	        9.48 (  4.34%)
   length=2, alignment=0:         9.56	       26.88 (-181.24%)	       12.64 (-32.31%)	       11.06 (-15.73%)	       11.06 (-15.72%)	       11.83 (-23.80%)
   length=3, alignment=3:         8.31	       10.45 (-25.84%)	        8.28 (  0.32%)	        8.28 (  0.36%)	        6.21 ( 25.28%)	        6.21 ( 25.24%)
   length=3, alignment=0:         8.39	       14.53 (-73.20%)	        8.28 (  1.33%)	        7.24 ( 13.69%)	        7.56 (  9.94%)	        7.25 ( 13.65%)
   length=4, alignment=4:         9.84	       21.76 (-121.24%)	       15.55 (-58.11%)	        6.57 ( 33.18%)	        5.02 ( 48.98%)	        6.00 ( 39.00%)
   length=4, alignment=0:         8.64	       13.70 (-58.51%)	        7.28 ( 15.73%)	        6.37 ( 26.31%)	        6.36 ( 26.36%)	        6.36 ( 26.36%)
   length=5, alignment=5:        11.85	       23.81 (-100.97%)	       12.17 ( -2.67%)	        5.68 ( 52.09%)	        4.87 ( 58.94%)	        6.48 ( 45.33%)
   length=5, alignment=0:        11.82	       13.64 (-15.42%)	        7.27 ( 38.45%)	        6.36 ( 46.15%)	        6.37 ( 46.11%)	        6.36 ( 46.14%)
   length=6, alignment=6:        10.50	       19.37 (-84.56%)	       13.64 (-29.93%)	        6.54 ( 37.71%)	        6.89 ( 34.35%)	        9.45 ( 10.01%)
   length=6, alignment=0:        14.96	       14.05 (  6.04%)	        6.49 ( 56.62%)	        5.68 ( 62.04%)	        5.68 ( 62.04%)	       13.15 ( 12.05%)
   length=7, alignment=7:        10.97	       18.02 (-64.35%)	       14.59 (-33.06%)	        6.36 ( 41.96%)	        5.46 ( 50.25%)	        5.46 ( 50.25%)
   length=7, alignment=0:        10.96	       15.76 (-43.77%)	       15.37 (-40.15%)	        6.96 ( 36.51%)	        5.68 ( 48.22%)	        7.04 ( 35.83%)
   length=4, alignment=0:         8.66	       13.69 (-58.02%)	        7.28 ( 16.00%)	        6.37 ( 26.44%)	        6.37 ( 26.52%)	        6.61 ( 23.74%)
   length=4, alignment=7:         8.87	       17.35 (-95.73%)	       12.18 (-37.39%)	        5.68 ( 35.94%)	        4.87 ( 45.11%)	        6.00 ( 32.36%)
   length=4, alignment=2:         8.67	       10.05 (-15.91%)	        7.28 ( 16.01%)	        7.37 ( 15.02%)	        5.46 ( 37.02%)	        5.47 ( 36.89%)
   length=2, alignment=2:         5.64	       10.01 (-77.64%)	        7.29 (-29.34%)	        6.37 (-13.04%)	        5.46 (  3.19%)	        5.46 (  3.19%)
   length=8, alignment=0:        12.78	       16.52 (-29.33%)	       18.27 (-43.00%)	       11.82 (  7.47%)	        9.83 ( 23.03%)	       11.46 ( 10.27%)
   length=8, alignment=7:        14.24	       17.30 (-21.49%)	       12.16 ( 14.59%)	        5.68 ( 60.14%)	        4.87 ( 65.83%)	        6.23 ( 56.28%)
   length=8, alignment=3:        12.34	       26.15 (-111.98%)	       12.20 (  1.14%)	        6.50 ( 47.34%)	        4.87 ( 60.54%)	        6.18 ( 49.94%)
   length=5, alignment=3:        10.95	       19.74 (-80.30%)	       12.17 (-11.11%)	        5.68 ( 48.16%)	        4.87 ( 55.56%)	        5.96 ( 45.55%)
   length=16, alignment=0:        20.33	       29.29 (-44.08%)	       36.18 (-77.97%)	        5.68 ( 72.06%)	        5.68 ( 72.08%)	       10.60 ( 47.86%)
   length=16, alignment=7:        19.29	       17.52 (  9.16%)	       12.98 ( 32.73%)	        7.05 ( 63.47%)	        4.87 ( 74.75%)	        6.23 ( 67.71%)
   length=16, alignment=4:        20.54	       25.18 (-22.56%)	       15.42 ( 24.92%)	        7.31 ( 64.43%)	        4.87 ( 76.29%)	        5.98 ( 70.88%)
   length=10, alignment=4:        14.59	       21.26 (-45.71%)	       12.17 ( 16.58%)	        5.68 ( 61.07%)	        4.87 ( 66.65%)	        6.00 ( 58.91%)
   length=32, alignment=0:        35.46	       22.00 ( 37.95%)	       16.22 ( 54.26%)	        7.32 ( 79.35%)	        5.68 ( 83.98%)	        7.01 ( 80.22%)
   length=32, alignment=7:        35.23	       24.14 ( 31.48%)	       16.22 ( 53.96%)	        7.30 ( 79.28%)	        8.76 ( 75.12%)	        6.14 ( 82.58%)
   length=32, alignment=5:        35.16	       28.56 ( 18.76%)	       16.22 ( 53.87%)	        7.30 ( 79.23%)	        6.77 ( 80.75%)	        9.82 ( 72.07%)
   length=21, alignment=5:        26.47	       27.66 ( -4.49%)	       15.04 ( 43.17%)	        6.90 ( 73.95%)	        4.87 ( 81.60%)	        6.04 ( 77.18%)
   length=64, alignment=0:        66.45	       25.16 ( 62.14%)	       22.70 ( 65.83%)	       12.99 ( 80.44%)	        7.47 ( 88.77%)	        8.70 ( 86.90%)
   length=64, alignment=7:        64.75	       27.78 ( 57.10%)	       22.72 ( 64.91%)	       10.85 ( 83.25%)	        7.46 ( 88.48%)	        8.68 ( 86.60%)
   length=64, alignment=6:        67.26	       28.58 ( 57.51%)	       22.70 ( 66.24%)	       11.26 ( 83.25%)	        9.46 ( 85.94%)	       13.90 ( 79.33%)
   length=42, alignment=6:        73.42	       27.97 ( 61.91%)	       19.46 ( 73.49%)	        8.92 ( 87.84%)	        6.49 ( 91.16%)	        6.00 ( 91.83%)
  length=128, alignment=0:       172.07	       39.18 ( 77.23%)	       35.68 ( 79.26%)	       13.02 ( 92.43%)	       12.98 ( 92.46%)	        9.76 ( 94.33%)
  length=128, alignment=7:       163.98	       43.79 ( 73.30%)	       36.03 ( 78.03%)	       15.68 ( 90.44%)	       11.35 ( 93.08%)	       10.51 ( 93.59%)
  length=128, alignment=7:       185.86	       40.27 ( 78.33%)	       36.04 ( 80.61%)	       13.78 ( 92.58%)	       11.35 ( 93.89%)	       10.49 ( 94.36%)
   length=85, alignment=7:       121.61	       55.66 ( 54.23%)	       32.34 ( 73.40%)	       13.88 ( 88.59%)	        7.30 ( 94.00%)	        8.72 ( 92.83%)
  length=256, alignment=0:       295.54	       66.48 ( 77.50%)	       61.63 ( 79.15%)	       19.54 ( 93.39%)	       12.97 ( 95.61%)	       12.45 ( 95.79%)
  length=256, alignment=7:       308.06	       78.92 ( 74.38%)	       61.63 ( 80.00%)	       22.90 ( 92.57%)	       12.97 ( 95.79%)	       13.23 ( 95.71%)
  length=256, alignment=8:       295.32	       65.83 ( 77.71%)	       61.62 ( 79.13%)	       23.19 ( 92.15%)	       12.97 ( 95.61%)	       13.50 ( 95.43%)
  length=170, alignment=8:       234.39	       48.79 ( 79.18%)	       43.79 ( 81.32%)	       16.22 ( 93.08%)	       13.97 ( 94.04%)	       10.48 ( 95.53%)
  length=512, alignment=0:       563.75	      116.89 ( 79.27%)	      114.99 ( 79.60%)	       62.71 ( 88.88%)	       19.58 ( 96.53%)	       17.76 ( 96.85%)
  length=512, alignment=7:       580.53	      120.91 ( 79.17%)	      114.47 ( 80.28%)	       37.75 ( 93.50%)	       19.55 ( 96.63%)	       18.68 ( 96.78%)
  length=512, alignment=9:       584.05	      128.35 ( 78.02%)	      114.74 ( 80.35%)	       39.09 ( 93.31%)	       19.76 ( 96.62%)	       18.71 ( 96.80%)
  length=341, alignment=9:       405.84	       90.87 ( 77.61%)	       78.79 ( 80.59%)	       28.77 ( 92.91%)	       14.60 ( 96.40%)	       14.15 ( 96.51%)
 length=1024, alignment=0:      1143.61	      247.03 ( 78.40%)	      243.70 ( 78.69%)	       75.59 ( 93.39%)	       67.02 ( 94.14%)	       28.99 ( 97.46%)
 length=1024, alignment=7:      1124.55	      267.87 ( 76.18%)	      259.16 ( 76.95%)	       64.96 ( 94.22%)	       33.05 ( 97.06%)	       30.91 ( 97.25%)
length=1024, alignment=10:      1459.58	      257.79 ( 82.34%)	      239.91 ( 83.56%)	       65.00 ( 95.55%)	       33.10 ( 97.73%)	       30.33 ( 97.92%)
 length=682, alignment=10:       732.89	      163.67 ( 77.67%)	      170.54 ( 76.73%)	       46.48 ( 93.66%)	       24.32 ( 96.68%)	       21.44 ( 97.07%)
 length=2048, alignment=0:      2141.96	      451.61 ( 78.92%)	      448.00 ( 79.08%)	      133.24 ( 93.78%)	       61.22 ( 97.14%)	       80.08 ( 96.26%)
 length=2048, alignment=7:      2145.05	      458.26 ( 78.64%)	      449.99 ( 79.02%)	      140.19 ( 93.46%)	       60.26 ( 97.19%)	       51.71 ( 97.59%)
length=2048, alignment=11:      2162.61	      463.37 ( 78.57%)	      448.07 ( 79.28%)	      140.29 ( 93.51%)	       59.51 ( 97.25%)	       51.59 ( 97.61%)
length=1365, alignment=11:      1439.74	      322.86 ( 77.58%)	      310.84 ( 78.41%)	      116.08 ( 91.94%)	       42.43 ( 97.05%)	       36.15 ( 97.49%)
 length=4096, alignment=0:      4278.68	      871.60 ( 79.63%)	      865.25 ( 79.78%)	      252.50 ( 94.10%)	      161.17 ( 96.23%)	       94.97 ( 97.78%)
 length=4096, alignment=7:      4253.01	      871.62 ( 79.51%)	      864.21 ( 79.68%)	      243.90 ( 94.27%)	      171.17 ( 95.98%)	       95.14 ( 97.76%)
length=4096, alignment=12:      4252.18	      879.66 ( 79.31%)	      863.68 ( 79.69%)	      244.26 ( 94.26%)	      185.36 ( 95.64%)	       93.61 ( 97.80%)
length=2730, alignment=12:      2868.22	      597.65 ( 79.16%)	      586.22 ( 79.56%)	      175.09 ( 93.90%)	      120.35 ( 95.80%)	      101.35 ( 96.47%)
    length=0, alignment=0:         4.87	        8.11 (-66.73%)	        6.49 (-33.34%)	        5.80 (-19.26%)	        5.68 (-16.67%)	        6.86 (-40.91%)
   length=32, alignment=0:        33.82	       22.36 ( 33.89%)	       17.03 ( 49.66%)	        7.30 ( 78.42%)	        5.68 ( 83.22%)	        7.50 ( 77.83%)
   length=64, alignment=0:        66.20	       26.76 ( 59.58%)	       23.22 ( 64.93%)	       12.99 ( 80.37%)	        7.34 ( 88.92%)	        8.44 ( 87.25%)
   length=96, alignment=0:       130.26	       31.62 ( 75.72%)	       30.00 ( 76.97%)	       11.39 ( 91.26%)	       10.54 ( 91.91%)	        8.68 ( 93.34%)
  length=128, alignment=0:       164.66	       39.05 ( 76.29%)	       35.68 ( 78.33%)	       13.07 ( 92.07%)	       12.97 ( 92.12%)	        9.59 ( 94.18%)
  length=160, alignment=0:       196.63	       45.18 ( 77.02%)	       42.16 ( 78.56%)	       14.65 ( 92.55%)	       10.87 ( 94.47%)	        9.31 ( 95.27%)
  length=192, alignment=0:       225.50	       52.71 ( 76.63%)	       49.61 ( 78.00%)	       16.22 ( 92.81%)	       11.36 ( 94.96%)	       11.08 ( 95.09%)
  length=224, alignment=0:       261.08	       57.57 ( 77.95%)	       55.82 ( 78.62%)	       17.84 ( 93.17%)	       12.16 ( 95.34%)	       11.51 ( 95.59%)
  length=256, alignment=0:       295.13	       65.56 ( 77.79%)	       62.59 ( 78.79%)	       19.46 ( 93.41%)	       13.12 ( 95.56%)	       12.33 ( 95.82%)
  length=288, alignment=0:       325.69	       72.16 ( 77.84%)	       69.20 ( 78.75%)	       21.08 ( 93.53%)	       13.94 ( 95.72%)	       12.32 ( 96.22%)
  length=320, alignment=0:       364.18	       78.78 ( 78.37%)	       75.69 ( 79.21%)	       22.71 ( 93.77%)	       14.70 ( 95.96%)	       14.46 ( 96.03%)
  length=352, alignment=0:       391.40	       84.87 ( 78.32%)	       82.15 ( 79.01%)	       24.50 ( 93.74%)	       15.62 ( 96.01%)	       14.27 ( 96.35%)
  length=384, alignment=0:       428.50	       91.43 ( 78.66%)	       88.70 ( 79.30%)	       26.16 ( 93.90%)	       17.29 ( 95.97%)	       15.04 ( 96.49%)
  length=416, alignment=0:       457.30	       98.23 ( 78.52%)	       95.02 ( 79.22%)	       27.81 ( 93.92%)	       17.22 ( 96.23%)	       15.05 ( 96.71%)
  length=448, alignment=0:       488.38	      104.52 ( 78.60%)	      101.87 ( 79.14%)	       31.22 ( 93.61%)	       18.07 ( 96.30%)	       16.89 ( 96.54%)
  length=480, alignment=0:       526.44	      109.61 ( 79.18%)	      108.11 ( 79.46%)	       31.11 ( 94.09%)	       18.88 ( 96.41%)	       17.10 ( 96.75%)
  length=512, alignment=0:       556.50	      117.29 ( 78.92%)	      113.78 ( 79.56%)	       62.57 ( 88.76%)	       19.88 ( 96.43%)	       17.80 ( 96.80%)
  length=576, alignment=0:       622.17	      152.93 ( 75.42%)	      127.58 ( 79.49%)	       39.34 ( 93.68%)	       21.31 ( 96.58%)	       19.99 ( 96.79%)
  length=640, alignment=0:       691.01	      142.56 ( 79.37%)	      161.78 ( 76.59%)	       39.20 ( 94.33%)	       22.98 ( 96.67%)	       20.13 ( 97.09%)
  length=704, alignment=0:       756.90	      156.31 ( 79.35%)	      176.19 ( 76.72%)	       45.03 ( 94.05%)	       24.82 ( 96.72%)	       22.33 ( 97.05%)
  length=768, alignment=0:       826.23	      193.17 ( 76.62%)	      188.41 ( 77.20%)	       50.81 ( 93.85%)	       27.46 ( 96.68%)	       23.25 ( 97.19%)
  length=832, alignment=0:       890.17	      204.81 ( 76.99%)	      201.61 ( 77.35%)	       53.77 ( 93.96%)	       27.73 ( 96.88%)	       25.06 ( 97.18%)
  length=896, alignment=0:       959.52	      217.89 ( 77.29%)	      213.86 ( 77.71%)	       57.99 ( 93.96%)	       29.53 ( 96.92%)	       26.29 ( 97.26%)
  length=960, alignment=0:      1024.52	      231.06 ( 77.45%)	      227.05 ( 77.84%)	       60.36 ( 94.11%)	       32.29 ( 96.85%)	       27.94 ( 97.27%)
 length=1024, alignment=0:      1086.71	      244.17 ( 77.53%)	      239.87 ( 77.93%)	       64.72 ( 94.04%)	       72.38 ( 93.34%)	       28.72 ( 97.36%)
 length=1152, alignment=0:      1231.48	      270.22 ( 78.06%)	      266.47 ( 78.36%)	       73.38 ( 94.04%)	       40.24 ( 96.73%)	       32.42 ( 97.37%)
 length=1280, alignment=0:      1349.29	      295.45 ( 78.10%)	      292.69 ( 78.31%)	      111.80 ( 91.71%)	       42.44 ( 96.85%)	       34.59 ( 97.44%)
 length=1408, alignment=0:      1487.13	      322.57 ( 78.31%)	      318.18 ( 78.60%)	       84.47 ( 94.32%)	       44.35 ( 97.02%)	       37.31 ( 97.49%)
 length=1536, alignment=0:      1623.52	      347.98 ( 78.57%)	      344.24 ( 78.80%)	      108.31 ( 93.33%)	       49.82 ( 96.93%)	       39.94 ( 97.54%)
 length=1664, alignment=0:      1748.88	      373.80 ( 78.63%)	      370.03 ( 78.84%)	      118.76 ( 93.21%)	       52.89 ( 96.98%)	       42.93 ( 97.55%)
 length=1792, alignment=0:      1886.22	      399.59 ( 78.82%)	      397.39 ( 78.93%)	      127.32 ( 93.25%)	       53.64 ( 97.16%)	       45.39 ( 97.59%)
 length=1920, alignment=0:      2018.37	      425.98 ( 78.89%)	      422.31 ( 79.08%)	      126.70 ( 93.72%)	       57.08 ( 97.17%)	       48.12 ( 97.62%)
 length=2048, alignment=0:      2167.09	      451.70 ( 79.16%)	      447.70 ( 79.34%)	      141.68 ( 93.46%)	       61.63 ( 97.16%)	       79.06 ( 96.35%)
 length=2304, alignment=0:      2422.03	      503.63 ( 79.21%)	      502.23 ( 79.26%)	      149.62 ( 93.82%)	       73.10 ( 96.98%)	       56.97 ( 97.65%)
 length=2560, alignment=0:      2678.68	      556.84 ( 79.21%)	      553.24 ( 79.35%)	      161.06 ( 93.99%)	      127.74 ( 95.23%)	       58.81 ( 97.80%)
 length=2816, alignment=0:      2941.95	      608.70 ( 79.31%)	      604.03 ( 79.47%)	      171.85 ( 94.16%)	       87.11 ( 97.04%)	       67.08 ( 97.72%)
 length=3072, alignment=0:      3229.89	      660.14 ( 79.56%)	      659.19 ( 79.59%)	      183.85 ( 94.31%)	      140.25 ( 95.66%)	       73.01 ( 97.74%)
 length=3328, alignment=0:      3496.08	      713.05 ( 79.60%)	      710.00 ( 79.69%)	      209.72 ( 94.00%)	      138.78 ( 96.03%)	       77.81 ( 97.77%)
 length=3584, alignment=0:      3756.52	      766.19 ( 79.60%)	      763.94 ( 79.66%)	      214.16 ( 94.30%)	      146.36 ( 96.10%)	       83.43 ( 97.78%)
 length=3840, alignment=0:      4017.15	      817.43 ( 79.65%)	      819.77 ( 79.59%)	      242.07 ( 93.97%)	      164.56 ( 95.90%)	       89.72 ( 97.77%)
 length=4096, alignment=0:      4281.59	      867.87 ( 79.73%)	      864.71 ( 79.80%)	      243.33 ( 94.32%)	      173.11 ( 95.96%)	       95.65 ( 97.77%)
 length=4608, alignment=0:      4810.30	      977.80 ( 79.67%)	      985.03 ( 79.52%)	      271.13 ( 94.36%)	      190.62 ( 96.04%)	      107.82 ( 97.76%)
 length=5120, alignment=0:      5380.16	     1075.77 ( 80.00%)	     1071.80 ( 80.08%)	      294.27 ( 94.53%)	      206.04 ( 96.17%)	      141.90 ( 97.36%)
 length=5632, alignment=0:      5925.70	     1195.61 ( 79.82%)	     1193.68 ( 79.86%)	      323.42 ( 94.54%)	      223.55 ( 96.23%)	      125.28 ( 97.89%)
 length=6144, alignment=0:      6402.20	     1285.52 ( 79.92%)	     1281.04 ( 79.99%)	      342.68 ( 94.65%)	      234.84 ( 96.33%)	      167.01 ( 97.39%)
 length=6656, alignment=0:      6997.01	     1387.32 ( 80.17%)	     1384.21 ( 80.22%)	      365.93 ( 94.77%)	      269.89 ( 96.14%)	      176.40 ( 97.48%)
 length=7168, alignment=0:      7454.76	     1492.10 ( 79.98%)	     1488.45 ( 80.03%)	      391.92 ( 94.74%)	      280.81 ( 96.23%)	      187.73 ( 97.48%)
 length=7680, alignment=0:      8163.34	     1608.43 ( 80.30%)	     1615.98 ( 80.20%)	      460.03 ( 94.36%)	      299.86 ( 96.33%)	      201.40 ( 97.53%)
```
2025-08-19 15:18:04 -07:00
Andre Kuhlenschmidt
d4673febb4
[flang][openacc] fix unguarded dereference of type pointer (#153606)
The added test used to cause a segfault, now it doesn't.
2025-08-19 15:10:09 -07:00
Maksim Panchenko
0d9b9d1eef
[BOLT] Keep X86 HLT instruction as a terminator in user mode (#154402)
This is a follow-up to #150963. X86 HLT instruction may appear in the
user-level code, in which case we should treat it as a terminator.
Handle it as a non-terminator in the Linux kernel mode.
2025-08-19 14:41:13 -07:00
Matheus Izvekov
ec6389d0c0
[clang] fix runtime check for NNS transform (#154418) 2025-08-19 18:32:17 -03:00
Valentin Clement (バレンタイン クレメン)
af8a149546
[flang][cuda] Add utility function cuf::hasDataAttr (#154422) 2025-08-19 14:25:32 -07:00
barsolo2000
402109e1c4
[LLDB] added getName method in SBModule (#150331)
added getName method in SBModule.h and .cpp in order to get the name of
the module from m_object_name.

---------

Co-authored-by: Bar Soloveychik <barsolo@fb.com>
2025-08-19 14:24:10 -07:00
Harshil Solanki
6127e46ff8
[clang-tidy][docs] Add documentation for Clang-Tidy Automation (#153166)
Resolves #90772

---------

Co-authored-by: Baranov Victor <bar.victor.2002@gmail.com>
2025-08-19 23:28:26 +03:00
Shilei Tian
b170f17861
[AMDGPU] Add support for safe bfloat16 fdiv on targets with bf16 trans instructions (#154373)
Recent changes introduced custom lowering for bf16 fdiv on targets that
support bf16 trans instructions, but only covered the unsafe version.
This PR extends that support to the safe variant.

For the safe version, the op is lowered by converting to float,
performing the div in float, and converting the result back to bf16.
This matches the behavior on targets that don't support bf16 trans
instructions.

Fixes SWDEV-550381.
2025-08-19 16:03:45 -04:00
Arthur Eubanks
b35b6297fd [gn build] Build win asan libraries against MutliThreadedDLL
win asan only supports /MD. Without this, the asan runtime cannot intercept functions.
2025-08-19 19:48:32 +00:00
Ian Wood
961b052e98
[mlir][tensor][NFC] Refactor common methods for bubbling extract_slice op (#153675)
Exposes the `tensor.extract_slice` reshaping logic in
`BubbleUpExpandShapeThroughExtractSlice` and
`BubbleUpCollapseShapeThroughExtractSlice` through two corresponding
utility functions. These compute the offsets/sizes/strides of an extract
slice after either collapsing or expanding.

This should also make it easier to implement the two other bubbling
cases: (1) the `collapse_shape` is a consumer or (2) the `expand_shape`
is a consumer.

---------

Signed-off-by: Ian Wood <ianwood@u.northwestern.edu>
2025-08-19 19:31:30 +00:00
Yifei Xu
6609d5fb0c
Update BUILD.bazel 2025-08-19 14:29:58 -05:00
Alex MacLean
d494eb0fa3
[NVPTX] Skip numbering unreferenced virtual registers (readability) (#154391)
When assigning numbers to registers, skip any with neither uses nor
defs. This is will not have any impact at all on the final SASS but it
makes for slightly more readable PTX. This change should also ensure
that future minor changes are less likely to cause noisy diffs in
register numbering.
2025-08-19 12:27:46 -07:00
Kazu Hirata
13faa15ee1
[lldb] Replace SmallSet with SmallPtrSet (NFC) (#154366)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 10 instances that rely on this "redirection". Since the
redirection doesn't improve readability, this patch replaces SmallSet
with SmallPtrSet for pointer element types.

I'm planning to remove the redirection eventually.
2025-08-19 12:20:43 -07:00
Andy Kaylor
6747139bc2
[CIR] Use zero-initializer for partial array fills (#154161)
If an array initializer list leaves eight or more elements that require
zero fill, we had been generating an individual zero element for every
one of them. This change instead follows the behavior of classic
codegen, which creates a constant structure with the specified elements
followed by a zero-initializer for the trailing zeros.
2025-08-19 12:14:05 -07:00
David Tellenbach
0542355147
[AArch64] Fix zero-register copying with zero-cycle moves (#154362)
Fix incorrect super-register lookup when copying from $wzr on subtargets
that lack zero-cycle zeroing but support 64-bit zero-cycle moves.

When copying from $wzr, we used the wrong register class to lookup the
super-register, causing

    $w0 = COPY $wzr

to get expanded as

    $x0 = ORRXrr $xzr, undef $noreg, implicit $wzr,

rather than the correct

    $x0 = ORRXrr $xzr, undef $xzr, implicit $wzr.
2025-08-19 21:07:16 +02:00
Florian Hahn
23ea79de61
[LV] Add more tests for costs of predicated udivs and calls.
Adds missing test coverage for the cost model. Also reduce the size of
check lines a bit, by using a common prefix and filtering out after
scalar.ph.
2025-08-19 20:04:31 +01:00
Baranov Victor
ed26993976
[clang-tidy] Improve "-quiet" option by suppressing "xxx warnings generated" (#154012)
Before this change, `-quiet` mode in clang-tidy generated meaningless
messages `xxx warnings generated` in output:
```cpp
// main.cpp
#include <iostream>

int main() {
  std::cout << 42;
}
```
```console
> clang-tidy -checks='-*,readability-magic-numbers' -quiet main.cpp

82 warnings generated.
main.cpp:4:16: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
    4 |   std::cout << 42;
      |                ^
```

As you can see, `82 warnings generated.` does not say much `quiet` mode,
this patch removes this message completely:

```console
> ./build/bin/clang-tidy -p build -checks='-*,readability-magic-numbers' -quiet main.cpp

main.cpp:4:16: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
    4 |   std::cout << 42;
      |                ^
```

In contrast, when running without `quiet`, It gives some meaningful
information because we know how many messages were suppressed thus
calculating total messages count:
```console
> clang-tidy -checks='-*,readability-magic-numbers' main.cpp

82 warnings generated.
main.cpp:4:16: warning: 42 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
    4 |   std::cout << 42;
      |                ^
Suppressed 81 warnings (81 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```

Fixes #47042
2025-08-19 21:47:51 +03:00
Tomer Shafir
ffddf33beb
[AArch64] Remove wrong processor feature (#151289)
`fmov dX, dY` is not a preferred instruction.

Previously introduced by:
https://github.com/llvm/llvm-project/pull/144152
2025-08-19 21:20:09 +03:00
Jonas Devlieghere
8bd9897815
[lldb] Create sections for Wasm segments (#153634)
This is a continuation of #153494. In a WebAssembly file, the "name"
section contains names for the segments in the data section
(WASM_NAMES_DATA_SEGMENT). We already parse these as symbols, and with
this PR, we now also create sub-sections for each of the segments.
2025-08-19 11:07:49 -07:00
Andy Kaylor
0f34360915
[CIR] Fix var_arg.c test (again) (#154393)
We had competing fixes for this that weren't compatible. This should
pass now.
2025-08-19 11:04:56 -07:00
Thurston Dang
4e9dbb519b
[compiler-rt] Fix-forward "[compiler-rt] Fix frame numbering for unparsable frames. #148278" (#154397)
Reason: buildbot failure
(https://lab.llvm.org/buildbot/#/builders/51/builds/21874/steps/9/logs/stdio)

Fix by restricting test to x86-64
2025-08-19 10:50:11 -07:00
Jonas Devlieghere
4cecbeed4f
[lldb] Support error variations in TestProcessCrashInfo.py (#154202)
The error message emitted by libmalloc changed in macOS 26. Update the
test to support both.
2025-08-19 10:49:23 -07:00
Matheus Izvekov
fdcc1b3588
[clang] NFC: fix and add some comments missing from #147835 (#154395) 2025-08-19 14:47:11 -03:00
Benjamin Maxwell
86e23af6be
[AArch64][SME] Temporarily mark test as XFAIL (#154384)
Marking this as XFAIL until
https://github.com/llvm/llvm-project/pull/154325 lands
2025-08-19 17:33:08 +00:00
Matheus Izvekov
5485c7021a
[clang] fix redecl chain assumption when checking linkage consistency (#153996)
In C++, it can be assumed the same linkage will be computed for all
redeclarations of an entity, and we have assertions to check this.

However, the linkage for a declaration can be requested in the middle of
deserealization, and at this point the redecl chain is not well formed,
as computation of the most recent declaration is deferred.

This patch makes that assertion work even in such conditions.

This fixes a regression introduced in
https://github.com/llvm/llvm-project/pull/147835, which was never
released, so there are no release notes for this.

Fixes #153933
2025-08-19 14:32:08 -03:00
Oleksandr T.
29fa5b72e9
Revert "[Clang] improve -Wstring-concatenation to warn on every missing comma in initializer lists" (#154369)
Revert llvm/llvm-project#154018 changes due to excessive _false
positives_. The warning caused multiple benign reports in large
codebases (e.g. _Linux kernel_, _Fuchsia_, _tcpdump_). Since many of
these concatenations are intentional and follow project style rules, the
diagnostic introduced more false positives than value. This will be
revisited as a potential `clang-tidy` check instead.
2025-08-19 20:30:16 +03:00
Michael Jones
d2b2d6ff10
[libc] Fix missing close at the end of file test (#154392)
The test added by #150802 was missing a close at the end.
2025-08-19 10:26:05 -07:00
Michael Buch
3f3bc4853e
[clang][test][DebugInfo] Move debug-info tests from CodeGen to DebugInfo directory (#154311)
This patch works towards consolidating all Clang debug-info into the
`clang/test/DebugInfo` directory
(https://discourse.llvm.org/t/clang-test-location-of-clang-debug-info-tests/87958).

Here we move only the `clang/test/CodeGen` tests.

The list of files i came up with is:
1. searched for anything with `*debug-info*` in the filename
2. searched for occurrences of `debug-info-kind` in the tests

I created a couple of subdirectories in `clang/test/DebugInfo` where I
thought it made sense (mostly when the tests were target-specific).

There's a couple of tests in `clang/test/CodeGen` that still set
`-debug-info-kind`. They probably don't need to do that, but I'm not
changing that as part of this PR.
2025-08-19 18:25:13 +01:00
Jesse Schwartzentruber
b1306da6ac
[compiler-rt] Fix frame numbering for unparsable frames. (#148278)
This can happen when JIT code is run, and we can't symbolize those
frames, but they should remain numbered in the stack. An example
spidermonkey trace:

```
    #0 0x564ac90fb80f  (/builds/worker/dist/bin/js+0x240e80f) (BuildId: 5d053c76aad4cfbd08259f8832e7ac78bbeeab58)
    #1 0x564ac9223a64  (/builds/worker/dist/bin/js+0x2536a64) (BuildId: 5d053c76aad4cfbd08259f8832e7ac78bbeeab58)
    #2 0x564ac922316f  (/builds/worker/dist/bin/js+0x253616f) (BuildId: 5d053c76aad4cfbd08259f8832e7ac78bbeeab58)
    #3 0x564ac9eac032  (/builds/worker/dist/bin/js+0x31bf032) (BuildId: 5d053c76aad4cfbd08259f8832e7ac78bbeeab58)
    #4 0x0dec477ca22e  (<unknown module>)
```

Without this change, the following symbolization is output:

```
    #0 0x55a6d72f980f in MOZ_CrashSequence /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:248:3
    #1 0x55a6d72f980f in Crash(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:4223:5
    #2 0x55a6d7421a64 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:501:13
    #3 0x55a6d742116f in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:597:12
    #4 0x55a6d80aa032 in js::jit::DoCallFallback(JSContext*, js::jit::BaselineFrame*, js::jit::ICFallbackStub*, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/jit/BaselineIC.cpp:1705:10
    #4 0x2c803bd8f22e  (<unknown module>)
```

The last frame has a duplicate number. With this change the numbering is
correct:

```
    #0 0x5620c58ec80f in MOZ_CrashSequence /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:248:3
    #1 0x5620c58ec80f in Crash(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/js/src/shell/js.cpp:4223:5
    #2 0x5620c5a14a64 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:501:13
    #3 0x5620c5a1416f in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:597:12
    #4 0x5620c669d032 in js::jit::DoCallFallback(JSContext*, js::jit::BaselineFrame*, js::jit::ICFallbackStub*, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/jit/BaselineIC.cpp:1705:10
    #5 0x349f24c7022e  (<unknown module>)
```
2025-08-19 10:13:41 -07:00
codefaber
fd7f69bfe7
[libc] Fix copy/paste error in file.cpp (#150802)
Fix using wrong variable due to copy/paste error.

---------

Co-authored-by: codefaber <codefaber>
2025-08-19 10:05:38 -07:00
Younan Zhang
0732693d81
Revert "[Clang] Only remove lambda scope after computing evaluation context" (#154382)
Revert due to breakage as reported in
https://github.com/llvm/llvm-project/pull/154106#discussion_r2285824084

Reverts llvm/llvm-project#154106
2025-08-20 00:56:56 +08:00
Aaron Ballman
ae434cdd0b
[C] Fix issue with -Wimplicit-void-ptr-cast (#154351)
The changes from https://github.com/llvm/llvm-project/pull/136855 missed
a change with atomic assignment constraints. This fixes a bug where we'd
accidentally drop a non-atomic-to-atomic conversion step.

Fixes #154157

co-authored-by: @ahatanak
2025-08-19 12:55:03 -04:00
Renato Golin
5cc8c92268
[NFC][MLIR] Document better linalg morphism (#154313) 2025-08-19 17:51:03 +01:00
Krishna Pandey
550dbec03a
[libc][math][c++23] Add {,u}fromfp{,x}bf16 math functions (#153992)
This PR adds the following basic math functions for BFloat16 type along
with the tests:
- fromfpbf16
- fromfpxbf16
- ufromfpbf16
- ufromfpxbf16

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
2025-08-19 22:19:03 +05:30
Sam Clegg
28f2fb24e1
Revert "[lld][WebAssembly] Do not relocate ABSOLUTE symbols" (#154371)
Reverts llvm/llvm-project#153763

This caused a bunch of failures on the emscripten waterfall,
specifically most of the lsan tests started failing.
2025-08-19 09:46:10 -07:00
Min-Yih Hsu
f82054eaa2
[RISCV] Handle more cases when combining (vfmv.s.f (extract_subvector X, 0)) (#154175)
Previously, we fold `(vfmv.s.f (extract_subvector X, 0))` into X when
X's type is the same as `vfmv.s.f`'s result type. This patch generalizes
it by folding it into insert_subvector when X is narrower and
extract_subvector when X is wider.

Co-authored-by: Craig Topper <craig.topper@sifive.com>
2025-08-19 09:43:55 -07:00
Frederik Harwath
f1e56ac032
Revert "[Clang] Take libstdc++ into account during GCC detection" (#154368)
Reverts llvm/llvm-project#145056
2025-08-19 16:35:58 +00:00
Helena Kotas
e04fedadba
[HLSL] Tests for local resource arrays (#153257)
Add tests for local arrays of resources.

Closes #145425
2025-08-19 09:22:27 -07:00
Joseph Huber
e2777af84b [LLVM] Add missing dependency for offload-wrapper tool 2025-08-19 11:19:35 -05:00
Drew Kersnar
069ad2353c
[NVPTXLowerArgs] Add align attribute to return value of addrspace.wrap intrinsic (#153889)
If alignment inference happens after NVPTXLowerArgs these addrspace wrap
intrinsics can prevent computeKnownBits from deriving alignment of
loads/stores from parameters. To solve this, we can insert an alignment
annotation on the generated intrinsic so that computeKnownBits does not
need to traverse through it to find the alignment.
2025-08-19 11:13:57 -05:00
Kazu Hirata
67ca5dad16
[polly] Replace SmallSet with SmallPtrSet (NFC) (#154367)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 10 instances that rely on this "redirection". Since the
redirection doesn't improve readability, this patch replaces SmallSet
with SmallPtrSet for pointer element types.

I'm planning to remove the redirection eventually.
2025-08-19 09:09:11 -07:00
Kazu Hirata
ccd5ddab9b
[clang-tools-extra] Replace SmallSet with SmallPtrSet (NFC) (#154365)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 10 instances that rely on this "redirection", with more
than half of them under clang-tools-extra/.  Since the redirection
doesn't improve readability, this patch replaces SmallSet with
SmallPtrSet for pointer element types.

I'm planning to remove the redirection eventually.
2025-08-19 09:09:03 -07:00
Joseph Huber
4c9b7ff04c
[LLVM] Introduce 'llvm-offload-wrapper' tool (#153504)
Summary:
This is a standalone tool that does the wrapper stage of the
`clang-linker-wrapper`. We want this to be an external tool because
currently there's no easy way to split apart what the
clang-linker-wrapper is doing under the hood. With this tool, users can
manually extract files with `clang-offload-packager`, feed them through
`clang --target=<triple>` and then use this tool to generate a `.bc`
file they can give to the linker. The goal here is to make reproducing
the linker wrapper steps easier.
2025-08-19 11:05:48 -05:00
Connector Switch
a0eb9958eb
[flang] optimize asind precision (#154350)
Part of https://github.com/llvm/llvm-project/issues/150452.
2025-08-19 23:54:09 +08:00
Michael Klemm
a5f1ddd115
[Flang][OpenMP] Fix issue with named constants in SHARED and FIRSTPRIVATE clauses (#154335)
The seemingly was a regression that prevented the usage of named
constant (w/ PARAMETER attribute) in SHARED and FIRSTPRIVATE clauses.
This PR corrects that.
2025-08-19 17:52:27 +02:00
John Harrison
538bd83b37
[lldb] Refactoring JSONTransport into an abstract RPC Message Handler and transport layer. (#153121)
This abstracts the base Transport handler to have a MessageHandler
component and allows us to generalize both JSON-RPC 2.0 for MCP (or an
LSP) and DAP format.

This should allow us to create clearly defined clients and servers for
protocols, both for testing and for RPC between the lldb instances and
an lldb-mcp multiplexer.

This basic model is inspiried by the clangd/Transport.h file and the
mlir/lsp-server-support/Transport.h that are both used for LSP servers
within the llvm project.

Additionally, this helps with testing by subclassing `Transport` to
allow us to simplify sending/receiving messages without needing to use a
toJSON/fromJSON and a pair of pipes, see `TestTransport` in
DAP/TestBase.h.
2025-08-19 08:46:25 -07:00
Michael Liao
1d1b60c6d5 [CIR] Fix codegen test after b44e47a68f9b49a6283b1beaab3af55fa39e8907 2025-08-19 11:38:47 -04:00
Slava Zakharin
6f489fb5e5
Reapply "[flang] Lower EOSHIFT into hlfir.eoshift." (#153907) (#154241)
This reverts commit 5178aeff7b96e86b066f8407b9d9732ec660dd2e.

In addition:
  * Scalar constant UNSIGNED BOUNDARY is explicitly casted
    to the result type so that the generated hlfir.eoshift
    operation is valid. The lowering produces signless constants
    by default. It might be a bigger issue in lowering, so I just
    want to "fix" it for EOSHIFT in this patch.
  * Since we have to create unsigned integer constant during
    HLFIR inlining, I added code in createIntegerConstant
    to make it possible.
2025-08-19 08:36:14 -07:00
Slava Zakharin
c79a88ee0a
[flang] Convert hlfir.designate with comp and contiguous result. (#154232)
Array sections like this have not been using the knowledge that
the result is contiguous:
```
type t
  integer :: f
end type
type(t) :: a(:)
a%f = 0
```

Peter Klausler is working on a change that will result in the
corresponding
hlfir.designate having a component and a non-box result.
This patch fixes the issues found in HLFIR-to-FIR conversion.
2025-08-19 08:35:40 -07:00
Shubham Sandeep Rastogi
5abad32538 Revert "[lldb] Fix error : unknown error while starting lldb's C/C++ repl (#153560)"
This reverts commit 00ffd8b8aa4e8cd3a2fee654d55995918886e874.

The change breaks lldb greendragon tests

Namely, TestClangREPL.py
2025-08-19 08:34:29 -07:00
Sirui Mu
10d193bf5e
[CIR][NFC] Fix regression by #153819 (#154346)
This patch fixes a regression introduced by #153819. The evaluation
order of the arguments to `emitVAStart` is unspecified, but the test
requires the arguments to be evaluated in left-to-right order.

It's a bit strange that the pre-merge checks did not catch this. The
tests failed on my local machine, which runs Fedora 42 with gcc 15.2.1 .
2025-08-19 23:32:02 +08:00
Dave Lee
6e3c7b8244
[lldb] Make step/s alias for new _regexp-step (#153984)
Introduces `_regexp-step`, a step command which additionally allows for
stepping into a target function. This change updates `step` and `s` to
be aliases for `_regexp-step`.

The existing `sif` alias ("Step Into Function") is not well known
amongst users. This change updates `step` and `s` to also work like
`sif`, taking an optional function name.

This is implemented to not break uses of `step` or `s` with a flag, for
example running `step -r func_to_avoid` works as expected.
2025-08-19 08:29:25 -07:00
Peter Klausler
0037c2083f
[flang][runtime] Fix CUDA build (#154357)
Address problems with CUDA build of flang-new runtime after a recent
patch to an external open file API.
2025-08-19 08:24:06 -07:00
Steven Wu
30c5c48d87
[CAS][Tests] Fix unit tests that hangs on two cores (#154151) 2025-08-19 08:21:34 -07:00
Krzysztof Parzyszek
8255d240a9
[flang][OpenMP] Avoid crash with MAP w/o modifiers, version >= 6.0 (#154352)
The current code will crash on the MAP clause with OpenMP version >= 6.0
when the clause does not explicitly list any modifiers. The proper fix
is to update the handling of assumed-size arrays for OpenMP 6.0+, but in
the short term keep the behavior from 5.2, just avoid the crash.
2025-08-19 10:18:51 -05:00
Craig Topper
9240061800
[RegAllocFast] Don't align stack slots if the stack can't be realigned (#153682)
This is the fast regalloc equivalent of
773771ba382b1fbcf6acccc0046bfe731541a599.
2025-08-19 08:17:26 -07:00
jyli0116
586858015e
[GlobalISel][AArch64] Add saturated truncate tests. NFC (#154329)
Added GlobalISel tests for saturated truncate.
2025-08-19 16:11:11 +01: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
Frederik Harwath
50a3368f22
[Clang] Take libstdc++ into account during GCC detection (#145056)
The Generic_GCC::GCCInstallationDetector class picks the GCC
installation directory with the largest version number. Since the
location of the libstdc++ include directories is tied to the GCC
version, this can break C++ compilation if the libstdc++ headers for
this particular GCC version are not available. Linux distributions tend
to package the libstdc++ headers separately from GCC. This frequently
leads to situations in which a newer version of GCC gets installed as a
dependency of another package without installing the corresponding
libstdc++ package. Clang then fails to compile C++ code because it
cannot find the libstdc++ headers. Since libstdc++ headers are in fact
installed on the system, the GCC installation continues to work, the
user may not be aware of the details of the GCC detection, and the
compiler does not recognize the situation and emit a warning, this
behavior can be hard to understand - as witnessed by many related bug
reports over the years.

The goal of this work is to change the GCC detection to prefer GCC
installations that contain libstdc++ include directories over those
which do not. This should happen regardless of the input language since
picking different GCC installations for a build that mixes C and C++
might lead to incompatibilities.
Any change to the GCC installation detection will probably have a
negative impact on some users. For instance, for a C user who relies on
using the GCC installation with the largest version number, it might
become necessary to use the --gcc-install-dir option to ensure that this
GCC version is selected.
This seems like an acceptable trade-off given that the situation for
users who do not have any special demands on the particular GCC
installation directory would be improved significantly.
 
This patch does not yet change the automatic GCC installation directory
choice. Instead, it does introduce a warning that informs the user about
the future change if the chosen GCC installation directory differs from
the one that would be chosen if the libstdc++ headers are taken into
account.

See also this related Discourse discussion:
https://discourse.llvm.org/t/rfc-take-libstdc-into-account-during-gcc-detection/86992.
2025-08-19 16:55:45 +02:00
Simon Pilgrim
355b747acd
[Headers][X86] Enable constexpr handling for pmulhw/pmulhuw avx512 mask/maskz intrinsics (#154341)
Followup to #152524 / #152540 - allow the predicated variants to be used in constexpr as well
2025-08-19 15:55:16 +01:00
Ross Brunton
2c11a83691
[Offload] Add olCalculateOptimalOccupancy (#142950)
This is equivalent to `cuOccupancyMaxPotentialBlockSize`. It is
currently
only implemented on Cuda; AMDGPU and Host return unsupported.

---------

Co-authored-by: Callum Fare <callum@codeplay.com>
2025-08-19 15:16:47 +01:00
Kazu Hirata
2c4f0e7ac6
[mlir] Replace SmallSet with SmallPtrSet (NFC) (#154265)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 30 instances that rely on this "redirection".  Since the
redirection doesn't improve readability, this patch replaces SmallSet
with SmallPtrSet for pointer element types.

I'm planning to remove the redirection eventually.
2025-08-19 07:11:47 -07:00
Kazu Hirata
136b541304
[clang] Replace SmallSet with SmallPtrSet (NFC) (#154262)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 30 instances that rely on this "redirection", with about
half of them under clang/.  Since the redirection doesn't improve
readability, this patch replaces SmallSet with SmallPtrSet for pointer
element types.

I'm planning to remove the redirection eventually.
2025-08-19 07:11:39 -07:00
Timm Baeder
965b7c2bfc
[clang][bytecode] Implement ia32_pmul* builtins (#154315) 2025-08-19 16:05:20 +02:00
Matt Arsenault
ed0e531044
AMDGPU: Use Register type for isStackAccess (#154320) 2025-08-19 23:00:45 +09:00
Younan Zhang
2b32ad1316
[Clang] Only remove lambda scope after computing evaluation context (#154106)
The immediate evaluation context needs the lambda scope info to
propagate some flags, however that LSI was removed in
ActOnFinishFunctionBody which happened before rebuilding a lambda
expression.

This also converts the wrapper function to default arguments as a
drive-by fix.

Fixes https://github.com/llvm/llvm-project/issues/145776
2025-08-19 21:59:23 +08:00
Charles Zablit
f55dc0824e
[lldb][windows] use Windows APIs to print to the console (#149493)
This patch uses the Windows APIs to print to the Windows Console,
through `llvm::raw_fd_ostream`.

This fixes a rendering issue where the characters defined in
`DiagnosticsRendering.cpp` (`"╰"` for instance) are not rendered
properly on Windows out of the box, because the default codepage is not
`utf-8`.

This solution is based on [this patch
downstream](https://github.com/swiftlang/swift/pull/40632/files#diff-e948e4bd7a601e3ca82d596058ccb39326459a4751470eec4d393adeaf516977R37-R38).

rdar://156064500
2025-08-19 14:52:29 +01:00
Simon Pilgrim
1359f72a03
[X86] canCreateUndefOrPoisonForTargetNode - add X86ISD::MOVMSK (#154321)
MOVMSK nodes don't create undef/poison when extracting the signbits from the source operand
2025-08-19 14:40:42 +01:00
Krzysztof Parzyszek
42350f428d
[flang][OpenMP] Parse GROUPPRIVATE directive (#153807)
No semantic checks or lowering yet.
2025-08-19 08:32:43 -05:00
Krzysztof Parzyszek
292faf6133
[Frontend][OpenMP] Add definition of groupprivate directive (#153799)
This is the common point for clang and flang implementations.
2025-08-19 08:27:29 -05:00
Alexandre Ganea
13391ce183
On Windows, in the release build script, fix detecting if clang-cl is in PATH (#149597)
The checks for detecting if `clang-cl` and `lld-link` are in `%PATH`
were wrong.

This fixes the comment in
https://github.com/llvm/llvm-project/pull/135446#discussion_r2215511129
2025-08-19 13:13:51 +00:00
Erich Keane
dab8c88f15
[OpenACC] Implement 'firstprivate' clause copy lowering (#154150)
This patch is the last of the 'firstprivate' clause lowering patches. It
takes the already generated 'copy' init from Sema and uses it to
generate the IR for the copy section of the recipe.

However, one thing that this patch had to do, was come up with a way to
hijack the decl registration in CIRGenFunction. Because these decls are
being created in a 'different' place, we need to remove the things we've
added. We could alternatively generate these 'differently', but it seems
worth a little extra effort here to avoid having to re-implement
variable initialization.
2025-08-19 06:02:10 -07:00
Aiden Grossman
01f2d70222
[X86] Remove unused variable from Atom Scheduling Model (#154191)
Related to #154180.
2025-08-19 06:00:18 -07:00
Orlando Cazalet-Hyams
da45b6c71d
[RemoveDIs][NFC] Remove dbg intrinsic version of calculateFragmentIntersect (#153378) 2025-08-19 13:44:25 +01:00
Yang Bai
b4c31dc98d
[mlir][Vector] add vector.insert canonicalization pattern to convert a chain of insertions to vector.from_elements (#142944)
## Description

This change introduces a new canonicalization pattern for the MLIR
Vector dialect that optimizes chains of insertions. The optimization
identifies when a vector is **completely** initialized through a series
of vector.insert operations and replaces the entire chain with a
single `vector.from_elements` operation.

Please be aware that the new pattern **doesn't** work for poison vectors
where only **some** elements are set, as MLIR doesn't support partial
poison vectors for now.

**New Pattern: InsertChainFullyInitialized**

* Detects chains of vector.insert operations.
* Validates that all insertions are at static positions, and all
intermediate insertions have only one use.
* Ensures the entire vector is **completely** initialized.
* Replaces the entire chain with a
single vector.from_elementts operation.

**Refactored Helper Function**

* Extracted `calculateInsertPosition` from
`foldDenseElementsAttrDestInsertOp` to avoid code duplication.

## Example

```
// Before:
%v1 = vector.insert %c10, %v0[0] : i64 into vector<2xi64>
%v2 = vector.insert %c20, %v1[1] : i64 into vector<2xi64>

// After:
%v2 = vector.from_elements %c10, %c20 : vector<2xi64>
```

It also works for multidimensional vectors.

```
// Before:
%v1 = vector.insert %cv0, %v0[0] : vector<3xi64> into vector<2x3xi64>
%v2 = vector.insert %cv1, %v1[1] : vector<3xi64> into vector<2x3xi64>

// After:
%0:3 = vector.to_elements %arg1 : vector<3xi64>
%1:3 = vector.to_elements %arg2 : vector<3xi64>
%v2 = vector.from_elements %0#0, %0#1, %0#2, %1#0, %1#1, %1#2 : vector<2x3xi64>
```

---------

Co-authored-by: Yang Bai <yangb@nvidia.com>
Co-authored-by: Andrzej Warzyński <andrzej.warzynski@gmail.com>
2025-08-19 13:43:31 +01:00
Krzysztof Parzyszek
c65c0e87fc
[flang][OpenMP] Break up CheckThreadprivateOrDeclareTargetVar, NFC (#153809)
Extract the visitors into separate functions to make the code more
readable. Join each message string into a single line.
2025-08-19 07:36:25 -05:00
Jie Fu
81f1b46cc6 [AArch64] Silent an unused-variable warning (NFC)
/llvm-project/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp:1042:11:
 error: unused variable 'TRI' [-Werror,-Wunused-variable]
    auto *TRI = MBB.getParent()->getSubtarget().getRegisterInfo();
          ^
1 error generated.
2025-08-19 20:32:33 +08:00
Simon Pilgrim
62d6c10b24 [X86] Add test showing the failure to fold FREEZE(MOVMSK(X)) -> MOVMSK(FREEZE(X)) 2025-08-19 13:25:36 +01:00
Leandro Lupori
ddb36a8102
[flang] Preserve dynamic length of characters in ALLOCATE (#152564)
Fixes #151895
2025-08-19 09:25:08 -03:00
Florian Hahn
1217c8226b
[LoopIdiom] Add test for simplifying SCEV during expansion with flags. 2025-08-19 13:22:45 +01:00
Utkarsh Saxena
92a91f71ee
[LifetimeSafety] Improve Origin information in debug output (#153951)
The previous debug output only showed numeric IDs for origins, making it
difficult to understand what each origin represented. This change makes
the debug output more informative by showing what kind of entity each
origin refers to (declaration or expression) and additional details like
declaration names or expression class names. This improved output makes
it easier to debug and understand the lifetime safety analysis.
2025-08-19 12:06:10 +00:00
Mehdi Amini
dc82b2cc70
Revert "[MLIR][WASM] Extending the Wasm binary to WasmSSA dialect importer" (#154314)
Reverts llvm/llvm-project#154053

Seems like an endianness sensitivity failing a big-endian bot.
2025-08-19 14:05:09 +02:00
Rafal Bielski
9c9d9e4cb6
[Offload] Define additional device info properties (#152533)
Add the following properties in Offload device info:
* VENDOR_ID
* NUM_COMPUTE_UNITS
* [SINGLE|DOUBLE|HALF]_FP_CONFIG
* NATIVE_VECTOR_WIDTH_[CHAR|SHORT|INT|LONG|FLOAT|DOUBLE|HALF]
* MAX_CLOCK_FREQUENCY
* MEMORY_CLOCK_RATE
* ADDRESS_BITS
* MAX_MEM_ALLOC_SIZE
* GLOBAL_MEM_SIZE

Add a bitfield option to enumerators, allowing the values to be
bit-shifted instead of incremented. Generate the per-type enums using
`foreach` to reduce code duplication.

Use macros in unit test definitions to reduce code duplication.
2025-08-19 13:02:01 +01:00
Simon Pilgrim
fcb36ca8cc
[DAG] visitTRUNCATE - merge the trunc(abd) and trunc(avg) handling which are almost identical (#154301)
CC @houngkoungting
2025-08-19 12:59:39 +01:00
Luc Forget
df57bb8c49
[MLIR][WASM] Extending the Wasm binary to WasmSSA dialect importer (#154053)
This is the continuation of  #152131 

This PR adds support for parsing the global initializer and function
body, and support for decoding scalar numerical instructions and
variable related instructions.

---------

Co-authored-by: Ferdinand Lemaire <ferdinand.lemaire@woven-planet.global>
Co-authored-by: Jessica Paquette <jessica.paquette@woven-planet.global>
Co-authored-by: Luc Forget <luc.forget@woven.toyota>
2025-08-19 13:42:47 +02:00
Timm Baeder
2f011ea37a
[clang][bytecode][NFC] Remove unused Program::relocs (#154308) 2025-08-19 13:29:56 +02:00
Dan Blackwell
2e9494ff96
[ASan] Re-enable duplicate_os_log_reports test and include cstdlib for malloc (#153195)
rdar://62141527
2025-08-19 12:12:48 +01:00
David Green
22b4021f01 [AArch64][GlobalISel] Add additional vecreduce.fadd and fadd 0.0 tests. NFC 2025-08-19 11:52:50 +01:00
Stephen Tozer
5cedb01487 [Debugify] Fix compile error in tracking coverage build
Forward-fixes a compile error in bc216b057d (#150212) in specific build
configurations, due to a missing const_cast.
2025-08-19 11:18:42 +01:00
Nuno Lopes
d0029b87d8
remove UB from test [NFC] 2025-08-19 11:18:27 +01:00
yronglin
57bf5dd7a0
[libc++][tuple.apply] Implement P2255R2 make_from_tuple part. (#152867)
Implement  P2255R2 tuple.apply part wording for `std::make_from_tuple`.
```
Mandates: If tuple_size_v<remove_reference_t<Tuple>> is 1, then reference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))> is false.
```

Fixes #154274

---------

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-08-19 18:14:13 +08:00
Kareem Ergawy
0e93dbc6b1
[flang] do concurrent: Enable delayed localization by default (#154303)
Enables delayed localization by default for `do concurrent`. Tested both
gfortran and Fujitsu test suites.

All tests pass for gfortran tests. For Fujitsu, enabled delayed
localization passes more tests:

Delayed localization disabled:
Testing Time: 7251.76s
  Passed            : 88520
  Failed            :   162
  Executable Missing:   408

Delayed localization enabled:
Testing Time: 7216.73s
  Passed            : 88522
  Failed            :   160
  Executable Missing:   408
2025-08-19 12:07:17 +02:00
Benjamin Maxwell
7170a81241
[AArch64][SME] Rename EdgeBundles to Bundles (NFC) (#154295)
It seems some buildbots do not like the shadowing. See:
https://lab.llvm.org/buildbot/#/builders/137/builds/23838
2025-08-19 10:58:19 +01:00
Lang Hames
615f8393c9
[orc-rt] Remove unused LLVM_RT_TOOLS_BINARY_DIR cmake variable. (#154254)
This was accidentally left in ee7a6a45bdb.
2025-08-19 19:56:27 +10:00
Timm Baeder
ab8b4f6629
[clang][bytecode][NFC] Replace std::optional<unsigned> with UnsignedO… (#154286)
…rNone
2025-08-19 11:37:32 +02:00
David Green
a7df02f83c
[InstCombine] Make strlen optimization more resilient to different gep types. (#153623)
This makes the optimization in optimizeStringLength for strlen(gep
@glob, %x) -> sub endof@glob, %x a little more resilient, and maybe a
bit more correct for geps with non-array types.
2025-08-19 10:37:17 +01:00
Vinay Deshmukh
d286f2ef55
[libc++] Make std::__tree_node member private to prepare for UB removal (#154225)
Prepare for:
https://github.com/llvm/llvm-project/pull/153908#discussion_r2281756219
2025-08-19 11:27:56 +02:00
tangaac
ccbcebcfd3
[LoongArch] Fix implicit PesudoXVINSGR2VR error (#152432)
According to the instructions manual, when `vr0` is changed, high 128
bit of `xr0` is undefined.
Use `vinsgr2vr.b/h` to insert an `i8/i16` to low 128bit of a 256 vector
may cause undefined behavior when high 128bit is used in later
instructions.
2025-08-19 17:22:00 +08:00
Aditi Medhane
948abf1bf5
[PowerPC] Add BCDCOPYSIGN and BCDSETSIGN Instruction Support (#144874)
Support the following BCD format conversion builtins for PowerPC.

- `__builtin_bcdcopysign` – Conversion that returns the decimal value of
the first parameter combined with the sign code of the second parameter.
`
- `__builtin_bcdsetsign` – Conversion that sets the sign code of the
input parameter in packed decimal format.

> Note: This built-in function is valid only when all following
conditions are met:
> -qarch is set to utilize POWER9 technology.
> The bcd.h file is included.

## Prototypes

```c
vector unsigned char __builtin_bcdcopysign(vector unsigned char, vector unsigned char);
vector unsigned char __builtin_bcdsetsign(vector unsigned char, unsigned char);
```

## Usage Details

`__builtin_bcdsetsign`: Returns the packed decimal value of the first
parameter combined with the sign code.
The sign code is set according to the following rules:
- If the packed decimal value of the first parameter is positive, the
following rules apply:
     - If the second parameter is 0, the sign code is set to 0xC.
     - If the second parameter is 1, the sign code is set to 0xF.
- If the packed decimal value of the first parameter is negative, the
sign code is set to 0xD.
> notes:
>     The second parameter can only be 0 or 1.
> You can determine whether a packed decimal value is positive or
negative as follows:
> - Packed decimal values with sign codes **0xA, 0xC, 0xE, or 0xF** are
interpreted as positive.
> - Packed decimal values with sign codes **0xB or 0xD** are interpreted
as negative.

---------

Co-authored-by: Aditi-Medhane <aditi.medhane@ibm.com>
2025-08-19 14:47:27 +05:30
Temperz87
9cadc4e153
[DAG] SelectionDAG::canCreateUndefOrPoison - add ISD::SCMP/UCMP handling + tests (#154127)
This pr aims to resolve #152144 
In SelectionDAG::canCreateUndefOrPoison the ISD::SCMP/UCMP cases are
added to always return false as they cannot generate poison or undef
The `freeze-binary.ll` file is now testing the SCMP/UCMP cases

---------

Co-authored-by: Temperz87 <= temperz871@gmail.com>
Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-19 10:06:14 +01:00
Timm Baeder
a1039c1b84
[clang][bytecode] Fix initializing float elements from #embed (#154285)
Fixes #152885
2025-08-19 11:04:21 +02:00
Sergei Barannikov
56ce40bc73
[TableGen][DecoderEmitter] Stop duplicating encodings (NFC) (#154288)
When HwModes are involved, we can duplicate an instruction encoding that
does not belong to any HwMode multiple times. We can do better by
mapping HwMode to a list of encoding IDs it contains. (That is,
duplicate IDs instead of encodings.)

The encodings that were duplicated are still processed multiple times
(e.g., we call an expensive populateInstruction() on each instance).
This is going to be fixed in subsequent patches.
2025-08-19 09:02:22 +00:00
Benjamin Maxwell
eb764040bc
[AArch64][SME] Implement the SME ABI (ZA state management) in Machine IR (#149062)
## Short Summary

This patch adds a new pass `aarch64-machine-sme-abi` to handle the ABI
for ZA state (e.g., lazy saves and agnostic ZA functions). This is
currently not enabled by default (but aims to be by LLVM 22). The goal
is for this new pass to more optimally place ZA saves/restores and to
work with exception handling.

## Long Description

This patch reimplements management of ZA state for functions with
private and shared ZA state. Agnostic ZA functions will be handled in a
later patch. For now, this is under the flag `-aarch64-new-sme-abi`,
however, we intend for this to replace the current SelectionDAG
implementation once complete.

The approach taken here is to mark instructions as needing ZA to be in a
specific ("ACTIVE" or "LOCAL_SAVED"). Machine instructions implicitly
defining or using ZA registers (such as $zt0 or $zab0) require the
"ACTIVE" state. Function calls may need the "LOCAL_SAVED" or "ACTIVE"
state depending on the callee (having shared or private ZA).

We already add ZA register uses/definitions to machine instructions, so
no extra work is needed to mark these.

Calls need to be marked by glueing Arch64ISD::INOUT_ZA_USE or
Arch64ISD::REQUIRES_ZA_SAVE to the CALLSEQ_START.

These markers are then used by the MachineSMEABIPass to find
instructions where there is a transition between required ZA states.
These are the points we need to insert code to set up or restore a ZA
save (or initialize ZA).

To handle control flow between blocks (which may have different ZA state
requirements), we bundle the incoming and outgoing edges of blocks.
Bundles are formed by assigning each block an incoming and outgoing
bundle (initially, all blocks have their own two bundles). Bundles are
then combined by joining the outgoing bundle of a block with the
incoming bundle of all successors.

These bundles are then assigned a ZA state based on the blocks that
participate in the bundle. Blocks whose incoming edges are in a bundle
"vote" for a ZA state that matches the state required at the first
instruction in the block, and likewise, blocks whose outgoing edges are
in a bundle vote for the ZA state that matches the last instruction in
the block. The ZA state with the most votes is used, which aims to
minimize the number of state transitions.
2025-08-19 10:00:28 +01:00
Nikita Popov
4ab87ffd1e
[SCCP] Enable PredicateInfo for non-interprocedural SCCP (#153003)
SCCP can use PredicateInfo to constrain ranges based on assume and
branch conditions. Currently, this is only enabled during IPSCCP.

This enables it for SCCP as well, which runs after functions have
already been simplified, while IPSCCP runs pre-inline. To a large
degree, CVP already handles range-based optimizations, but SCCP is more
reliable for the cases it can handle. In particular, SCCP works reliably
inside loops, which is something that CVP struggles with due to LVI
cycles.

I have made various optimizations to make PredicateInfo more efficient,
but unfortunately this still has significant compile-time cost (around
0.1-0.2%).
2025-08-19 10:59:38 +02:00
Timm Baeder
fb8ee3adb6
[clang][bytecode] Move pointers from extern globals to new decls (#154273) 2025-08-19 10:54:33 +02:00
Michael Buch
d9d5090b03
[CI] Run LLDB tests on Clang changes in pre-merge CI (#154154)
This attempts https://github.com/llvm/llvm-project/issues/132795 again.
Last time we tried this we didn't have enough infra capacity, so had to
revert. According to recent communication from the Infrastructure Area
Team, we should now have enough capacity to re-enable the LLDB tests.
2025-08-19 09:44:08 +01:00
Baranov Victor
ef3ce0dcb2
[Github] Remove redundant 'START_REV', 'END_REV' env variables (NFC) (#154218)
After https://github.com/llvm/llvm-project/pull/133023, `START_REV` and
`END_REV` env variables became redundant.
2025-08-19 11:41:37 +03:00
Amr Hesham
5581e34bd9
[CIR] Implement MemberExpr support for ComplexType (#154027)
This change adds support for the MemberExpr ComplexType

Issue: https://github.com/llvm/llvm-project/issues/141365
2025-08-19 10:32:22 +02:00
David Sherwood
13d8ba7dea
[LV][TTI] Calculate cost of extracting last index in a scalable vector (#144086)
There are a couple of places in the loop vectoriser where we
want to calculate the cost of extracting the last lane in a
vector. However, we wrongly assume that asking for the cost
of extracting lane (VF.getKnownMinValue() - 1) is an accurate
representation of the cost of extracting the last lane. For
SVE at least, this is non-trivial as it requires the use of
whilelo and lastb instructions.

To solve this problem I have added a new
getReverseVectorInstrCost interface where the index is used
in reverse from the end of the vector. Suppose a vector has
a given ElementCount EC, the extracted/inserted lane would be
EC - 1 - Index. For scalable vectors this index is unknown at
compile time. I've added a AArch64 hook that better represents
the cost, and also a RISCV hook that maintains compatibility
with the behaviour prior to this PR.

I've also taken the liberty of adding support in vplan for
calculating the cost of VPInstruction::ExtractLastElement.
2025-08-19 09:31:37 +01:00
William Huynh
0c622d72fc
[libc] Add _Returns_twice to C++ code (#153602)
Fixes issue with `<csetjmp>` which requires `_Returns_twice` but in C++
mode
2025-08-19 09:28:23 +01:00
Timm Baeder
da05208bfb
[clang][bytecode] Create temporary before discarding CXXConstructExpr (#154280)
Fixes #154110
2025-08-19 10:27:26 +02:00
Nikita Popov
5753ee2434 [LICM] Avoid assertion failure on stale MemoryDef
It can happen that the call is originally created as a MemoryDef,
and then later transforms show it is actually read-only and could
be a MemoryUse -- however, this is not guaranteed to be reflected
in MSSA.
2025-08-19 10:25:45 +02:00
Luke Lau
cabf6433c6
[VPlan] EVL transform VPVectorEndPointerRecipe alongisde load/store recipes. NFC (#152542)
This is the first step in untangling the variable step transform and
header mask optimizations as described in #152541.

Currently we replace all VF users globally in the plan, including
VPVectorEndPointerRecipe. However this leaves reversed loads and stores
in an incorrect state until they are adjusted in optimizeMaskToEVL.

This moves the VPVectorEndPointerRecipe transform so that it is updated
in lockstep with the actual load/store recipe.

One thought that crossed my mind was that VPInterleaveRecipe could also
use VPVectorEndPointerRecipe, in which case we would have also been
computing the wrong address because we don't transform it to an EVL
recipe which accounts for the reversed address.
2025-08-19 08:16:48 +00:00
Morris Hafner
b5e5794534
[CIR] Implement Statement Expressions (#153677)
Depends on #153625

This patch adds support for statement expressions. It also changes
emitCompoundStmt and emitCompoundStmtWithoutScope to accept an Address
that the optional result is written to. This allows the creation of the
alloca ahead of the creation of the scope which saves us from hoisting
the alloca to its parent scope.
2025-08-19 10:11:15 +02:00
Simon Pilgrim
9adc4f9720
[X86] Enable MMX unpcklo/unpckhi intrinsics in constexpr (#154149)
Matches behaviour in SSE/AVX/AVX512 intrinsics - was missed in #153028
2025-08-19 09:08:39 +01:00
Timm Baeder
ddcd3fdcfd
[clang][bytecode][NFC] use both-note in literals test (#154277)
And harmonize the RUN lines.
2025-08-19 10:02:23 +02:00
Nikita Popov
e6d9542b77
[X86][Inline] Check correct function for target feature check (#152515)
The check for ABI differences for inlined calls involves the caller, the
callee and the nested callee. Before inlining, the ABI is determined by
the target features of the callee. After inlining it is determined by
the caller. The features of the nested callee should never actually
matter.
2025-08-19 09:44:00 +02:00
Nikita Popov
86ac834df5
[RISCV] Use OrigTy from InputArg/OutputArg (NFCI) (#154095)
The InputArg/OutputArg now contains the OrigTy, so directly use that
instead of trying to recover it.

CC_RISCV is now *nearly* a normal CC assignment function. However, it
still differs by having an IsRet flag.
2025-08-19 09:28:24 +02:00
Nikita Popov
9d37e80d3c
[SystemZ] Remove custom CCState pre-analysis (#154091)
The calling convention lowering now has access to OrigTy, so use that to
detect short vectors.
2025-08-19 09:28:09 +02:00
Nikita Popov
a4f85515c2
[Hexagon] Remove custom vararg tracking (NFCI) (#154089)
This information is now directly available, use the generic
CCIfArgVarArg.
2025-08-19 09:27:11 +02:00
Nikita Popov
b2fae5b3c7
[Mips] Remove custom "original type" handling (#154082)
Replace Mips custom logic for retaining information about original types
in calling convention lowering by directly querying the OrigTy that is
now available.

There is one change in behavior here: If the return type is a struct
containing fp128 plus additional members, the result is now different,
as we no longer special case to a single fp128 member. I believe this is
fine, because this is a fake ABI anyway: Such cases should actually use
sret, and as such are a frontend responsibility, and Clang will indeed
emit these as sret, not as a return value struct. So this only impacts
manually written IR tests.
2025-08-19 09:26:38 +02:00
Morris Hafner
b44e47a68f
[CIR] Upstream __builtin_va_start and __builtin_va_end (#153819)
Part of #153286
2025-08-19 09:16:11 +02:00
Timm Baeder
eb7a1d91b2
[clang][bytecode] Support pmul X86 builtins (#154275) 2025-08-19 09:10:50 +02:00
Sergei Barannikov
cded128009
[TableGen][DecoderEmitter] Extract encoding parsing into a method (NFC) (#154271)
Call it from the constructor so that we can make `run` method `const`.
Turn a couple of related functions into methods as well.
2025-08-19 06:35:59 +00:00
Sudharsan Veeravalli
c00b04a7e0
[RISCV] Generate QC_INSB/QC_INSBI instructions from OR of AND Imm (#154023)
Generate QC_INSB/QC_INSBI from `or (and X, MaskImm), OrImm` iff the
value being inserted only sets known zero bits. This is based on a
similar DAG to DAG transform done in `AArch64`.
2025-08-19 11:14:14 +05:30
Pierre van Houtryve
6f7c77fe90
[AMDGPU] Check noalias.addrspace in mayAccessScratchThroughFlat (#151319)
PR #149247 made the MD accessible by the backend so we can now leverage
it in the memory model. The first use case here is detecting if a flat op
can access scratch memory.
Benefits both the MemoryLegalizer and InsertWaitCnt.
2025-08-19 07:42:59 +02:00
Benjamin Maxwell
bb3066d42b
[LAA] Move scalable vector check into getStrideFromAddRec() (#154013)
This moves the check closer to the `.getFixedValue()` call and fixes
#153797 (which is a regression from #126971).
2025-08-19 06:40:07 +01:00
Kazu Hirata
18123cc91d
[llvm] Proofread Legalizer.rst (#154266) 2025-08-18 22:40:00 -07:00
Kazu Hirata
5fdc7478a6
[AArch64] Replace SmallSet with SmallPtrSet (NFC) (#154264)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 30 instances that rely on this "redirection". Since the
redirection doesn't improve readability, this patch replaces SmallSet
with SmallPtrSet for pointer element types.

I'm planning to remove the redirection eventually.
2025-08-18 22:39:53 -07:00
Kazu Hirata
4831d92005
[lld] Replace SmallSet with SmallPtrSet (NFC) (#154263)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 30 instances that rely on this "redirection".  Since the
redirection doesn't improve readability, this patch replaces SmallSet
with SmallPtrSet for pointer element types.

I'm planning to remove the redirection eventually.
2025-08-18 22:39:45 -07:00
Kazu Hirata
d82617d2e8
[ADT] Refactor SmallPtrSetImplBase::swap (NFC) (#154261)
SmallPtrSetImplBase::swap needs to deal with four cases depending on
whether LHS is small and whether RHS is small.  Now, the code to swap
small LHS and large RHS is symmetric with the code to swap large LHS
and small RHS.

This patch rearranges code so that we first take care of the case
where both LHS and RHS are small.  Then we compute references
SmallSide and LargeSide and actually swap the two instances.

This refactoing saves about 11 lines of code.  Note that
SmallDenseMap::swap also uses a similar trick.
2025-08-18 22:39:38 -07:00
Sergei Barannikov
6c3a0ab51a [TableGen][DecoderEmitter] Shorten a few variable names (NFC)
These "Numbered"-prefixed names were rather confusing than helpful.
2025-08-19 08:05:02 +03:00
YAMAMOTO Takashi
9247be8ca0
[lld][WebAssembly] Do not relocate ABSOLUTE symbols (#153763)
Fixes https://github.com/llvm/llvm-project/issues/153759
2025-08-18 21:56:48 -07:00
Timm Baeder
25c137e43b
[clang][bytecode] Save a per-block dynamic allocation ID (#154094)
This fixes an old todo item about wrong allocation counting and some
diagnostic differences.
2025-08-19 06:52:21 +02:00
Sergei Barannikov
f84ce1e1d0 [TableGen][DecoderEmitter] Extract a couple of loop invariants (NFC) 2025-08-19 07:47:15 +03:00
Craig Topper
da19383ae7
[RISCV] Fold (X & -4096) == 0 -> (X >> 12) == 0 (#154233)
This is a more general form of the recently added isel pattern
(seteq (i64 (and GPR:$rs1, 0x8000000000000000)), 0)
  -> (XORI (i64 (SRLI GPR:$rs1, 63)), 1)

We can use a shift right for any AND mask that is a negated power
of 2. But for every other constant we need to use seqz instead of
xori. I don't think there is a benefit to xori over seqz as neither
are compressible.

We already do this transform from target independent code when the setcc
constant is a non-zero subset of the AND mask that is not a legal icmp
immediate.

I don't believe any of these patterns comparing MSBs to 0 are
canonical according to InstCombine. The canonical form is (X < 4096).
I'm curious if these appear during SelectionDAG and if so, how.

My goal here was just to remove the special case isel patterns.
2025-08-18 21:24:35 -07:00
Craig Topper
2817873082
[RISCV] Fold (sext_inreg (setcc), i1) -> (sub 0, (setcc). (#154206)
This helps the 3 vendor extensions that make sext_inreg i1 legal.

I'm delaying this until after LegalizeDAG since we normally have
sext_inreg i1 up until LegalizeDAG turns it into and+neg.

I also delayed the recently added (sext_inreg (xor (setcc), -1), i1)
combine. Though the xor isn't likely to appear before LegalizeDAG anyway.
2025-08-18 21:24:03 -07:00
Anutosh Bhat
00ffd8b8aa
[lldb] Fix error : unknown error while starting lldb's C/C++ repl (#153560)
Fixes https://github.com/llvm/llvm-project/issues/153157

The proposed solution has been discussed here
(https://github.com/llvm/llvm-project/issues/153157#issue-3313379242)

This is what we would be seeing now 

```
base) anutosh491@Anutoshs-MacBook-Air bin % ./lldb /Users/anutosh491/work/xeus-cpp/a.out
(lldb) target create "/Users/anutosh491/work/xeus-cpp/a.out"
Current executable set to '/Users/anutosh491/work/xeus-cpp/a.out' (arm64).
(lldb) b main
Breakpoint 1: where = a.out`main, address = 0x0000000100003f90
(lldb) r
Process 71227 launched: '/Users/anutosh491/work/xeus-cpp/a.out' (arm64)
Process 71227 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003f90 a.out`main
a.out`main:
->  0x100003f90 <+0>:  sub    sp, sp, #0x10
    0x100003f94 <+4>:  str    wzr, [sp, #0xc]
    0x100003f98 <+8>:  str    w0, [sp, #0x8]
    0x100003f9c <+12>: str    x1, [sp]
(lldb) expression --repl -l c -- 
  1> 1 + 1
(int) $0 = 2
  2> 2 + 2
(int) $1 = 4
```

```
base) anutosh491@Anutoshs-MacBook-Air bin % ./lldb /Users/anutosh491/work/xeus-cpp/a.out
(lldb) target create "/Users/anutosh491/work/xeus-cpp/a.out"
Current executable set to '/Users/anutosh491/work/xeus-cpp/a.out' (arm64).
(lldb) b main
Breakpoint 1: where = a.out`main, address = 0x0000000100003f90
(lldb) r
Process 71355 launched: '/Users/anutosh491/work/xeus-cpp/a.out' (arm64)
Process 71355 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003f90 a.out`main
a.out`main:
->  0x100003f90 <+0>:  sub    sp, sp, #0x10
    0x100003f94 <+4>:  str    wzr, [sp, #0xc]
    0x100003f98 <+8>:  str    w0, [sp, #0x8]
    0x100003f9c <+12>: str    x1, [sp]
(lldb) expression --repl -l c -- 3 + 3
Warning: trailing input is ignored in --repl mode
  1> 1 + 1
(int) $0 = 2
```
2025-08-19 09:51:20 +05:30
Luke Lau
144736b07e
[VPlan] Don't fold live ins with both scalar and vector operands (#154067)
If we end up with a extract_element VPInstruction where both operands
are live-ins, we will try to fold the live-ins even though the first
operand is a vector whilst the live-in is scalar.

This fixes it by just returning the vector live-in instead of calling
the folder, and removes the handling for insertelement where we aren't
able to do the fold. From some quick testing we previously never hit
this fold anyway, and were probably just missing test coverage.

Fixes #154045
2025-08-19 04:10:53 +00:00
Md Asghar Ahmad Shahid
c24c23d9ab
[NFC][mlir][vector] Handle potential static cast assertion. (#152957)
In FoldArithToVectorOuterProduct pattern, static cast to vector type
causes assertion when a scalar type was encountered. It seems the author
meant to have a dyn_cast instead.

This NFC patch handles it by using dyn_cast.
2025-08-19 09:27:20 +05:30
Henrik G. Olsson
e1ff432eb6
Reland "[Utils] Add new --update-tests flag to llvm-lit" (#153821)
This reverts commit
e495231238
to reland
the --update-tests feature, originally landed in
https://github.com/llvm/llvm-project/pull/108425.
2025-08-18 20:24:27 -07:00
Sergei Barannikov
c8c2218c00
[TableGen][DecoderEmitter] Synthesize decoder table name in emitTable (#154255)
Previously, HW mode name was appended to decoder namespace name when
enumerating encodings, and then emitTable appended the bit width to it
to form the final table name. Let's do this all in one place.
A nice side effect is that this allows us to avoid having to deal with
std::string.

The changes in the tests are caused by the different order of tables.
2025-08-19 06:19:54 +03:00
Shilei Tian
1f6e13a161 Revert "[AMDGPU][Attributor] Infer inreg attribute in AMDGPUAttributor (#146720)"
This reverts commit 84ab301554f8b8b16b94263a57b091b07e9204f2 because it breaks
several AMDGPU test bots.
2025-08-18 22:59:52 -04:00
Sudharsan Veeravalli
8495018a85
[RISCV] Use sd_match in trySignedBitfieldInsertInMask (#154152)
This keeps everything in APInt and makes it easier to understand and
maintain.
2025-08-19 08:22:06 +05:30
slavek-kucera
5b55899781
[clangd] Clangd running with --experimental-modules-support crashes when the compilation database is unavailable (#153802)
fixes llvm/llvm-project#132413
2025-08-19 10:19:13 +08:00
Shilei Tian
84ab301554
[AMDGPU][Attributor] Infer inreg attribute in AMDGPUAttributor (#146720)
This patch introduces `AAAMDGPUUniformArgument` that can infer `inreg` function
argument attribute. The idea is, for a function argument, if the corresponding
call site arguments are always uniform, we can mark it as `inreg` thus pass it
via SGPR.

In addition, this AA is also able to propagate the inreg attribute if feasible.
2025-08-18 22:01:47 -04:00
Iris Shi
cc68e45343
[CIR] Implement codegen for inline assembly without input and output operands (#153546)
- Part of #153267


https://github.com/llvm/clangir/blob/main/clang/lib/CIR/CodeGen/CIRAsm.cpp
2025-08-18 18:54:24 -07:00
ZhaoQi
be3fd6ae25
[LoongArch] Use section-relaxable check instead of relax feature from STI (#153792)
In some cases, such as using `lto` or `llc`, relax feature is not
available from this `SubtargetInfo` (`LoongArchAsmBackend` is
instantiated too early), causing loss of relocations.

This commit modifiy the condition to check whether the section which
contains the two symbols is relaxable. If not relaxable, no need to
record relocations.
2025-08-19 09:48:51 +08:00
Ye Tian
db843e5d09
[DAG] Add ISD::FP_TO_SINT_SAT/FP_TO_UINT_SAT handling to SelectionDAG::canCreateUndefOrPoison (#154244)
Related to https://github.com/llvm/llvm-project/issues/153366
2025-08-19 10:45:11 +09:00
Jianjian Guan
1eb5b18a04
[mlir][emitc] Support dense as init value for ShapedType (#144826) 2025-08-19 09:41:15 +08:00
Matt Arsenault
19ebfa6d0b
RuntimeLibcalls: Move exception call config to tablegen (#151948)
Also starts pruning out these calls if the exception model is
forced to none.

I worked backwards from the logic in addPassesToHandleExceptions
and the pass content. There appears to be some tolerance
for mixing and matching exception modes inside of a single module.
As far as I can tell _Unwind_CallPersonality is only relevant for
wasm, so just add it there.

As usual, the arm64ec case makes things difficult and is
missing test coverage. The set of calls in list form is necessary
to use foreach for the duplication, but in every other context a
dag is more convenient. You cannot use foreach over a dag, and I
haven't found a way to flatten a dag into a list.

This removes the last manual setLibcallImpl call in generic code.
2025-08-19 10:35:59 +09:00
Matt Arsenault
fe67267d19
MSP430: Move __mspabi_mpyll calling conv config to tablegen (#153988)
There are several libcall choices for MUL_I64 which depend on the
subtarget, but this is the base case. The manual custom ISelLowering
is still overriding the decision until we have a way to control
lowering choices, but we can still get the calling convention
set for now.
2025-08-19 10:25:10 +09:00
Helena Kotas
eb3d88423d
[HLSL] Global resource arrays element access (#152454)
Adds support for accessing individual resources from fixed-size global resource arrays.

Design proposal:
https://github.com/llvm/wg-hlsl/blob/main/proposals/0028-resource-arrays.md

Enables indexing into globally scoped, fixed-size resource arrays to retrieve individual resources. The initialization logic is primarily handled during codegen. When a global resource array is indexed, the
codegen translates the `ArraySubscriptExpr` AST node into a constructor call for the corresponding resource record type and binding.

To support this behavior, Sema needs to ensure that:
- The constructor for the specific resource type is instantiated.
- An implicit binding attribute is added to resource arrays that lack explicit bindings (#152452).

Closes #145424
2025-08-18 18:20:46 -07:00
Mariusz Borsa
0c512f7897
[Sanitizers][Test] narrower constraint for XFAIL (#154245)
It's a followup to https://github.com/llvm/llvm-project/pull/154189 ,
which broke test on android bot. Making sure XFAIL only happen on darwin
bots

rdar://158543555

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2025-08-18 18:17:25 -07:00
ZhaoQi
3acb7093c2
[LoongArch][NFC] Add tests for fixing missed addsub relocs when enabling relax (#154108) 2025-08-19 09:15:23 +08:00
Lang Hames
ee7a6a45bd
[ORC-RT] Initial check-in for a new, top-level ORC runtime project. (#113499)
Includes CMake files and placeholder header, library, test tool, regression
test and unit test.

The aim for this project is to create a replacement for the existing ORC
Runtime that currently resides in `llvm-project/compiler-rt/lib/orc`. The new
project will provide a superset of the original features, and the old runtime
will be removed once the new runtime is sufficiently developed.

See discussion at
https://discourse.llvm.org/t/rfc-move-orc-executor-support-into-top-level-project/81049
2025-08-19 10:56:18 +10:00
Mel Chen
1dac302ce7
[LV] Explicitly disallow interleaved access requiring gap mask for scalable VFs. nfc (#154122)
Currently, VPInterleaveRecipe::execute does not support generating LLVM
IR for interleaved accesses that require a gap mask for scalable VFs.
It would be better to detect and prevent such groups from being
vectorized as interleaved accesses in
LoopVectorizationCostModel::interleavedAccessCanBeWidened, rather than
relying on the TTI function getInterleavedMemoryOpCost to return an
invalid cost.
2025-08-19 08:42:39 +08:00
Jordan Rupprecht
fb4450c459
[bazel] Add more load statements for C++ rules (#154207)
Same thing as #149584, but for more elements of cc_rules (e.g.
`CcInfo`), and applying it to some files that were added since then
(build files under mlir/examples).

Command: `buildifier --lint=fix
--warnings=native-cc-binary,native-cc-import,native-cc-library,native-cc-objc-import,native-cc-objc-library,native-cc-shared-library,native-cc-test,native-cc-toolchain,native-cc-toolchain-suite,native-cc-fdo-prefetch-hints,native-cc-fdo-profile,native-cc-memprof-profile,native-cc-propeller-optimize,native-cc-common,native-cc-debug-package-info,native-cc-info,native-cc-shared-library-info,native-cc-shared-library-hint-info`
2025-08-18 19:41:49 -05:00
Muhammad Bassiouni
523c3a0197
[libc][math] fix coshf16 build errors. (#154226) 2025-08-19 03:39:24 +03:00
Oliver Hunt
62d2a8e682
[NFC][Clang][Docs] Update Pointer Authentication documentation (#152596)
This updates the pointer authentication documentation to include a
complete description of the existing functionaliy and behaviour, details
of the more complex aspects of the semantics and security properties,
and the Apple arm64e ABI design.

Co-authored-by: Ahmed Bougacha
Co-authored-by: Akira Hatanaka
Co-authored-by: John Mccall

---------

Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
Co-authored-by: Akira Hatanaka <ahatanak@gmail.com>
Co-authored-by: John Mccall <rjmccall@apple.com>
2025-08-18 17:27:36 -07:00
Craig Topper
6c0518a88f
[RISCV] Prioritize zext.h/zext.w over XTheadBb th.extu. (#154186)
Fixes #154125.
2025-08-18 16:56:57 -07:00
Craig Topper
396dfdf7be
[RISCV] Remove -O0 from rv32xandesperf.ll. NFC (#154224)
Invert icmp conditions in test input to make the tests generate the expected branch instructions.
2025-08-18 16:56:38 -07:00
Wenju He
a450dc80bf
[libclc] Implement __clc_get_local_size/__clc_get_max_sub_group_size for amdgcn (#153785)
This simplifies downstream refactoring of libspirv workitem function in
https://github.com/intel/llvm/tree/sycl/libclc/libspirv/lib/generic
2025-08-19 07:51:17 +08:00
Jesse Schwartzentruber
4d2288d318
[compiler-rt] [test] Add test for frame counter out of order. (#154190)
Add test for #148278. This was written with the aide of ChatGPT 5 and
tested on Linux x86_64.
2025-08-18 16:22:57 -07:00
Stanislav Mekhanoshin
3ef3b30c3c
Revert "[AMDGPU] Fold copies of constant physical registers into their uses (#154183)" (#154219)
This reverts commit 3395676a18ab580f21ebcd4324feaf1294a8b6d9.

Fails
libc/test/src/string/libc.test.src.string.memmove_test.__hermetic__
2025-08-18 16:22:47 -07:00
Florian Mayer
19474672e5
[UBSan] [min-rt] make minimal runtime handlers weak (#154220)
This allows people to override them, if they want.
2025-08-18 16:19:31 -07:00
Muhammad Bassiouni
2c79dc1082
[libc][math] Refactor coshf16 implementation to header-only in src/__support/math folder. (#153582)
Part of #147386

in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
2025-08-19 02:08:07 +03:00
Andy Kaylor
7ac4d9bd53
[CIR] Add support for calling virtual functions (#153893)
This change adds support for calling virtual functions. This includes
adding the cir.vtable.get_virtual_fn_addr operation to lookup the
address of the function being called from an object's vtable.
2025-08-18 15:56:33 -07:00
Sergei Barannikov
61a859bf6f Use llvm::copy instead of append_range to work around MacOS build failure 2025-08-19 01:43:22 +03:00
Mariusz Borsa
4dc32df3ca
[Sanitizers][Test] XFAIL suppressions/fread_fwrite (#154189)
These tests are failing on current macOS version installed on Apple bot

rdar://158543555

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2025-08-18 15:37:06 -07:00
Mariusz Borsa
0d9346e5e9
[Sanitizers][Test] XFAIL array cookie tests on arm (#154031)
Poisoning of C++ array redzones is only implemented for x86 CPUs. New
arm64 bots are being brought up, where these test fail.

Original C++ arrays shadow poisoning change:

http://reviews.llvm.org/D4774

rdar://158025391

Co-authored-by: Mariusz Borsa <m_borsa@apple.com>
2025-08-18 15:36:24 -07:00
Sergei Barannikov
0cd4ae9be0
Reland "[TableGen][DecoderEmitter] Store HW mode ID instead of name (NFC) (#154052)" (#154212)
This reverts commit 5612dc533a9222a0f5561b2ba7c897115f26673f.

Reland with MacOS build fixed.
2025-08-18 22:28:20 +00:00
Stanislav Mekhanoshin
a26c3e9491
[AMDGPU] User SGPR count increased to 32 on gfx1250 (#154205) 2025-08-18 15:04:56 -07:00
Daniel Paoliello
a4cff34f3f
[win][x64] Permit lea to adjust the stack when using unwind v2 (#154171)
In some cases `leaq` may be used to adjust the stack in an epilog, this
is permitted by unwind v2 and shouldn't raise an error.
2025-08-18 15:00:59 -07:00
Peter Klausler
50a40738d6
[flang] Catch semantic error with LBOUND/UBOUND (#154184)
The "ARRAY=" argument to these intrinsics cannot be scalar, whether
"DIM=" is present or not. (Allowing the "ARRAY=" argument to be scalar
when "DIM=" is absent would be a conceivable extension returning an
empty result array, like SHAPE() does with extents, but it doesn't seem
useful in a programming language without compilation-time rank
polymorphism apart from assumed-rank dummy arguments, and those are
supported.)

Fixes https://github.com/llvm/llvm-project/issues/154044.
2025-08-18 14:45:38 -07:00
Peter Klausler
638f8636df
[flang][runtime] Account for missing READ(SIZE=) characters (#153967)
One of the two formatted real input paths was failing to call GotChar()
to account for the characters that it consumes.

Fixes https://github.com/llvm/llvm-project/issues/153830.
2025-08-18 14:45:14 -07:00
Peter Klausler
9a7a16c8d5
[flang][runtime] Allow child NAMELIST input to advance records (#153963)
NAMELIST input in child I/O is rare, and it's not clear in the standard
whether it should be allowed to advance to later records in the parent
unit. But GNU Fortran supports it, and there's no good reason not to do
so since a NAMELIST input group that isn't terminated on the same line
is otherwise going to be a fatal error.

Fixes https://github.com/llvm/llvm-project/issues/153416.
2025-08-18 14:44:48 -07:00
Peter Klausler
ffec266980
[flang][runtime] Catch bad OPEN specifiers for unformatted files (#153707)
When an OPEN statement has specifiers that are allowed only for
formatted files, detect an error when the file turns out to be
unformatted.

Fixes https://github.com/llvm/llvm-project/issues/153480.
2025-08-18 14:44:23 -07:00
Peter Klausler
c53792b278
[flang][runtime] OPEN(existingUnit,POSITION=) (#153688)
Ensure that when a connected unit is reopened with POSITION='REWIND' or
'APPEND', and a STATUS='OLD' or unspecified, that it is actually
repositioned as requested.

Fixes https://github.com/llvm/llvm-project/issues/153426.
2025-08-18 14:44:00 -07:00
Peter Klausler
2cf982c0f5
[flang] Don't duplicate impure function call for UBOUND() (#153648)
Because the per-dimension information in a descriptor holds an extent
and a lower bound, but not an upper bound, the calculation of the upper
bound sometimes requires that the extent and lower bound be extracted
from a descriptor and added together, minus 1. This shouldn't be
attempted when the NamedEntity of the descriptor is something that
shouldn't be duplicated and used twice; specifically, it shouldn't apply
to NamedEntities containing references to impure functions as parts of
subscript expressions.

Fixes https://github.com/llvm/llvm-project/issues/153031.
2025-08-18 14:43:13 -07:00
Matthias Braun
48232594a0
llvm-profgen: Options cleanup / fixes (#147632)
- Add `cl::cat(ProfGenCategory)` to non-hidden options so they show up
  in `--help` output.
- Introduce `Options.h` for options referenced in multiple files.
2025-08-18 21:42:55 +00:00
Peter Klausler
50b55a5ee9
[flang][runtime] Fix AllocateAssignmentLHS for monomorphic LHS (#153073)
When the left-hand side of an assignment statement is an allocatable
that has a monomorphic derived type, and the right-hand side of the
assignment has a type that is an extension of that type, *don't* change
the incoming type or element size of the descriptor before allocating
it.

Fixes https://github.com/llvm/llvm-project/issues/152758.
2025-08-18 14:42:16 -07:00
Oliver Hunt
ec4e6aaac4
[clang][ObjC] Fix incorrect return type inference for discarded blocks (#154109)
When parsing a block expression we were not entering a new eval context
and as a result when parsing the block body we continue to treat any
return statements as discarded so infer a `void` result.

This fixes the problem by introducing an evaluation context around the
parsing of the body.
2025-08-18 14:38:50 -07:00
Shubham Sandeep Rastogi
5612dc533a Revert "[TableGen][DecoderEmitter] Store HW mode ID instead of name (NFC) (#154052)"
This reverts commit b20bbd48e8b1966731a284b4208e048e060e97c2.

Reverted due to greendragon failures:

20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/utils/TableGen/DecoderEmitter.cpp:14:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/utils/TableGen/Common/CodeGenHwModes.h:14:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/DenseMap.h:20:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/STLExtras.h:21:
20:34:43  In file included from /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/Hashing.h:53:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/algorithm:1913:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/chrono:746:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__chrono/convert_to_tm.h:19:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__chrono/statically_widen.h:17:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__format/concepts.h:17:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__format/format_parse_context.h:15:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/string_view:1027:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/functional:515:
20:34:43  In file included from /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/__functional/boyer_moore_searcher.h:26:
20:34:43  /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/include/c++/v1/vector:1376:19: error: object of type 'llvm::const_set_bits_iterator_impl<llvm::SmallBitVector>' cannot be assigned because its copy assignment operator is implicitly deleted
20:34:43              __mid =  __first;
20:34:43                    ^
20:34:43  /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/utils/TableGen/DecoderEmitter.cpp:2404:13: note: in instantiation of function template specialization 'std::vector<unsigned int>::assign<llvm::const_set_bits_iterator_impl<llvm::SmallBitVector>, 0>' requested here
20:34:43    HwModeIDs.assign(BV.set_bits_begin(), BV.set_bits_end());
20:34:43              ^
20:34:43  /Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/llvm/include/llvm/ADT/BitVector.h:35:21: note: copy assignment operator of 'const_set_bits_iterator_impl<llvm::SmallBitVector>' is implicitly deleted because field 'Parent' is of reference type 'const llvm::SmallBitVector &'
20:34:43    const BitVectorT &Parent;
20:34:43                      ^
20:34:43  1 warning and 1 error generated.
2025-08-18 14:36:54 -07:00
Stanislav Mekhanoshin
668e6492b8
[AMDGPU] Support merging of flat GVS ops (#154200) 2025-08-18 14:31:41 -07:00
Sergei Barannikov
13dd65096b [TableGen][DecoderEmitter] Rename some variables for clarity (NFC) 2025-08-19 00:16:56 +03:00
Oleksandr T.
c2eb895c20
[Clang] improve -Wstring-concatenation to warn on every missing comma in initializer lists (#154018)
Fixes #153745

---

This PR addresses a limitation in `-Wstring-concatenation`, where only
the first missing comma in an initializer list was diagnosed.
2025-08-19 00:10:53 +03:00
Aiden Grossman
8a0b3cc089
[CI] Ignore upload artifact failures (#154196)
Some CI runs are seeing issues with failures running the artifact upload
step. They seem related to
https://github.com/actions/upload-artifact/issues/569. We should
continue the workflow and ignore errors in the upload artifact step if
it fails so that users do not see a red CI that is not due to their
changes.

Fixes #154155.
2025-08-18 14:10:23 -07:00
Mehdi Amini
89abccc9a6
[MLIR] Update GreedyRewriter to use the LDBG() debug log mechanism (NFC) (#153961)
Also improve a bit the LDBG() implementation
2025-08-18 21:05:34 +00:00
Mehdi Amini
8c605bd1f4
[MLIR] Add logging to eraseUnreachableBlocks (NFC) (#153968) 2025-08-18 21:02:53 +00:00
Stanislav Mekhanoshin
906c9e9542
[AMDGPU] Remove misplaced assert. (#154187)
The assert that RegScavenger required for long branching is now
placed below the code to use s_add_pc64, where it is actually
used.
2025-08-18 13:58:54 -07:00
Florian Hahn
79be94c984
[VPlan] Compute cost single-scalar calls in computeCost. (NFC)
Compute the cost of non-intrinsic, single-scalar calls directly in
VPReplicateRecipe::computeCost.

This starts moving call cost computations to VPlan, handling the
simplest case first.
2025-08-18 21:56:56 +01:00
Jonas Devlieghere
d8208b0575
Revert "[lldb] Relax the error message in TestProcessCrashInfo.py" (#154197)
Reverts llvm/llvm-project#153653 because older versions of macOS do not
use the same prefix.
2025-08-18 20:53:12 +00:00
Mehdi Amini
dfaebe7f48
[MLIR] Fix Liveness analysis handling of unreachable code (#153973)
This patch is forcing all values to be initialized by the
LivenessAnalysis, even in dead blocks. The dataflow framework will skip
visiting values when its already knows that a block is dynamically
unreachable, so this requires specific handling.
Downstream code could consider that the absence of liveness is the same
a "dead".
However as the code is mutated, new value can be introduced, and a
transformation like "RemoveDeadValue" must conservatively consider that
the absence of liveness information meant that we weren't sure if a
value was dead (it could be a newly introduced value.

Fixes #153906
2025-08-18 20:50:36 +00:00
Mehdi Amini
191e7eba93
[MLIR] Stop visiting unreachable blocks in the walkAndApplyPatterns driver (#154038)
This is similar to the fix to the greedy driver in #153957 ; except that
instead of removing unreachable code, we just ignore it.

Operations like:

```
%add = arith.addi %add, %add : i64
```

are legal in unreachable code.
Unfortunately many patterns would be unsafe to apply on such IR and can
lead to crashes or infinite loops.
2025-08-18 20:46:59 +00:00
Oliver Hunt
624b724ca6
[clang][PAC] ptrauth_qualifier and ptrauth_intrinsic should only be available on Darwin (#153912)
For backwards compatibility reasons the `ptrauth_qualifier` and
`ptrauth_intrinsic` features need to be testable with `__has_feature()`
on Apple platforms, but for other platforms this backwards compatibility
issue does not exist.

This PR resolves these issues by making the `ptrauth_qualifier` and
`ptrauth_intrinsic` tests conditional upon a darwin target. This also
allows us to revert the ptrauth_qualifier check from an extension to a
feature test again, as is required on these platforms.

At the same time we introduce a new predefined macro `__PTRAUTH__` that
answers the same question as `__has_feature(ptrauth_qualifier)` and
`__has_feature(ptrauth_intrinsic)` as those tests are synonymous and
only exist separately for compatibility reasons.

The requirement to test for the `__PTRAUTH__` macro also resolves the
hazard presented by mixing the `ptrauth_qualifier` flag (that impacts
ABI and security policies) with `-pedantics-errors`, which makes
`__has_extension` return false for all extensions.

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>
2025-08-18 20:29:26 +00:00
Charitha Saumya
9617ce4862
[vector][distribution] Bug fix in moveRegionToNewWarpOpAndAppendReturns (#153656) 2025-08-18 13:26:08 -07:00
Stanislav Mekhanoshin
13716843eb
[AMDGPU] Make s_setprio_inc_wg a scheduling boundary (#154188) 2025-08-18 13:20:38 -07:00
Thurston Dang
4220538e25
[msan] Handle multiply-add-accumulate; apply to AVX Vector Neural Network Instructions (VNNI) (#153927)
This extends the pmadd handler (recently improved in https://github.com/llvm/llvm-project/pull/153353) to three-operand intrinsics (multiply-add-accumulate), and applies it to the AVX Vector Neural Network Instructions.

Updates the tests from https://github.com/llvm/llvm-project/pull/153135
2025-08-18 13:18:27 -07:00
Jordan Rupprecht
462929183c
[bazel] Port #153497: reland clang modules scanner change (#154192) 2025-08-18 20:15:12 +00:00
Stanislav Mekhanoshin
3395676a18
[AMDGPU] Fold copies of constant physical registers into their uses (#154183)
With current codegen this only affects src_flat_scratch_base_lo/hi.

Co-authored-by: Jay Foad <Jay.Foad@amd.com>

Co-authored-by: Jay Foad <Jay.Foad@amd.com>
2025-08-18 13:07:36 -07:00
Stanislav Mekhanoshin
c328c5d911
[AMDGPU] Combine to bf16 reciprocal square root. (#154185)
Co-authored-by: Ivan Kosarev <Ivan.Kosarev@amd.com>

Co-authored-by: Ivan Kosarev <Ivan.Kosarev@amd.com>
2025-08-18 13:07:20 -07:00
Sergei Barannikov
b20bbd48e8
[TableGen][DecoderEmitter] Store HW mode ID instead of name (NFC) (#154052)
This simplifies code a bit.
2025-08-18 22:53:09 +03:00
Baranov Victor
378d240125
[clang-tidy] Remove addition of emacs tag in checks headers (#153942)
After https://github.com/llvm/llvm-project/pull/118553, emacs tag is no
longer needed in LLVM files:
https://llvm.org/docs/CodingStandards.html#file-headers.
This patch removes it from `add_new_check.py` lowering complexity we
need to maintain.
2025-08-18 22:49:54 +03:00
Florian Hahn
7e9989390d
[VPlan] Materialize Build(Struct)Vectors for VPReplicateRecipes. (NFCI) (#151487)
Materialze Build(Struct)Vectors explicitly for VPRecplicateRecipes, to
serve their users requiring a vector, instead of doing so when unrolling
by VF.

Now we only need to implicitly build vectors in VPTransformState::get
for VPInstructions. Once they are also unrolled by VF we can remove the
code-path alltogether.

PR: https://github.com/llvm/llvm-project/pull/151487
2025-08-18 20:49:42 +01:00
Konrad Kleine
f5a648f919
[doc] Add documentation for clang-change-namespace (#148277)
This adds rst documentation for the `clang-change-namespace` program.

Fixes #35519
2025-08-18 21:46:34 +02:00
Naveen Seth Hanig
9403c2d64d
Reland [clang][modules-driver] Add scanner to detect C++20 module presence (#153497)
This patch is part of a series to support driver managed module builds
for C++ named modules and Clang modules.
This introduces a scanner that detects C++ named module usage early in
the driver with only negligible overhead.

For now, it is enabled only with the `-fmodules-driver` flag and serves
solely diagnostic purposes. In the future, the scanner will be enabled
for any (modules-driver compatible) compilation with two or more inputs,
and will help the driver determine whether to implicitly enable the
modules driver.

Since the scanner adds very little overhead, we are also exploring
enabling it for compilations with only a single input. This approach
could allow us to detect `import std` usage in a single-file
compilation, which would then activate the modules driver. For
performance measurements on this, see
https://github.com/naveen-seth/llvm-dev-cxx-modules-check-benchmark.

RFC for driver managed module builds:

https://discourse.llvm.org/t/rfc-modules-support-simple-c-20-modules-use-from-the-clang-driver-without-a-build-system

This patch relands the reland (2d31fc8) for commit ded1426. The earlier
reland failed due to a missing link dependency on `clangLex`. This
reland fixes the issue by adding the link dependency after discussing it
in the following RFC:

https://discourse.llvm.org/t/rfc-driver-link-the-driver-against-clangdependencyscanning-clangast-clangfrontend-clangserialization-and-clanglex
2025-08-18 21:21:08 +02:00
Daniel Thornburgh
986d7aa675
Bump ProtocolServerMCPTest timeout to 200ms (#154182)
This should reduce flakes observed in the Fuchsia AArch64 Linux LLDB CI
builders.
2025-08-18 12:19:19 -07:00
Stanislav Mekhanoshin
3d6177c14b
[AMDGPU] Avoid setting op_sel_hi bits if there is matrix_b_scale. NFCI. (#154176)
This is NFCI now as there is no matrix_b_scale without matrix_b_reuse,
but technically this condition shall be here.
2025-08-18 12:13:31 -07:00
Stanislav Mekhanoshin
e7c2c80fa1
[AMDGPU] Combine prng(undef) -> undef (#154160) 2025-08-18 12:13:16 -07:00
Usama Hameed
1bb7217050
[Sanitizers][Darwin][Test] The top few frames are inaccurate in UBSan. (#153899)
XFailing until further investigation

rdar://158303080
2025-08-18 12:08:45 -07:00
Utkarsh Saxena
d30fd562e8
[LifetimeSafety] Enhance benchmark script for new sub analyses (#149577)
Enhanced the lifetime safety analysis benchmark script with more
detailed performance metrics and a new nested loop test case. This is a
worst case for loan expiry analysis.

### What changed?

- Added a new test case `nested_loops` that generates code with N levels
of nested loops to test how analysis performance scales with loop
nesting depth
- Improved the trace file analysis to extract durations for sub-phases
of the lifetime analysis (FactGenerator, LoanPropagation, ExpiredLoans)
- Enhanced the markdown report generation to include:
    - Relative timing results as percentages of total Clang time
    - More detailed complexity analysis for each analysis phase

Report
# Lifetime Analysis Performance Report
> Generated on: 2025-08-18 13:29:57 

---

## Test Case: Pointer Cycle in Loop

**Timing Results:**

| N (Input Size) | Total Time | Analysis Time (%) | Fact Generator (%) |
Loan Propagation (%) | Expired Loans (%) |

|:---------------|-----------:|------------------:|-------------------:|---------------------:|------------------:|
| 10 | 10.75 ms | 24.61% | 0.00% | 24.38% | 0.00% |
| 25 | 64.98 ms | 86.08% | 0.00% | 86.02% | 0.00% |
| 50 | 709.37 ms | 98.53% | 0.00% | 98.51% | 0.00% |
| 75 | 3.13 s | 99.63% | 0.00% | 99.63% | 0.00% |
| 100 | 9.44 s | 99.85% | 0.00% | 99.84% | 0.00% |
| 150 | 45.31 s | 99.96% | 0.00% | 99.96% | 0.00% |

**Complexity Analysis:**

| Analysis Phase    | Complexity O(n<sup>k</sup>) |
|:------------------|:--------------------------|
| Total Analysis    | O(n<sup>3.87</sup> &pm; 0.01) |
| FactGenerator     | (Negligible)              |
| LoanPropagation   | O(n<sup>3.87</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 (%) |

|:---------------|-----------:|------------------:|-------------------:|---------------------:|------------------:|
| 10 | 8.54 ms | 0.00% | 0.00% | 0.00% | 0.00% |
| 50 | 40.85 ms | 65.09% | 0.00% | 64.61% | 0.00% |
| 100 | 207.70 ms | 93.58% | 0.00% | 93.46% | 0.00% |
| 200 | 1.54 s | 98.82% | 0.00% | 98.78% | 0.00% |
| 400 | 12.04 s | 99.72% | 0.00% | 99.71% | 0.01% |
| 800 | 96.73 s | 99.94% | 0.00% | 99.94% | 0.00% |

**Complexity Analysis:**

| Analysis Phase    | Complexity O(n<sup>k</sup>) |
|:------------------|:--------------------------|
| Total Analysis    | O(n<sup>3.01</sup> &pm; 0.00) |
| FactGenerator     | (Negligible)              |
| LoanPropagation   | O(n<sup>3.01</sup> &pm; 0.00) |
| ExpiredLoans      | (Negligible)              |

---

## Test Case: Deeply Nested Loops

**Timing Results:**

| N (Input Size) | Total Time | Analysis Time (%) | Fact Generator (%) |
Loan Propagation (%) | Expired Loans (%) |

|:---------------|-----------:|------------------:|-------------------:|---------------------:|------------------:|
| 10 | 8.25 ms | 0.00% | 0.00% | 0.00% | 0.00% |
| 50 | 27.25 ms | 51.87% | 0.00% | 45.71% | 5.93% |
| 100 | 113.42 ms | 82.48% | 0.00% | 72.74% | 9.62% |
| 200 | 730.05 ms | 95.24% | 0.00% | 83.95% | 11.25% |
| 400 | 5.40 s | 98.74% | 0.01% | 87.05% | 11.68% |
| 800 | 41.86 s | 99.62% | 0.00% | 87.77% | 11.84% |

**Complexity Analysis:**

| Analysis Phase    | Complexity O(n<sup>k</sup>) |
|:------------------|:--------------------------|
| Total Analysis    | O(n<sup>2.97</sup> &pm; 0.00) |
| FactGenerator     | (Negligible)              |
| LoanPropagation   | O(n<sup>2.96</sup> &pm; 0.00) |
| ExpiredLoans      | O(n<sup>2.97</sup> &pm; 0.00) |

---
2025-08-18 19:07:41 +00:00
Jonas Devlieghere
4b94c08a57
[lldb] Relax the error message in TestProcessCrashInfo.py (#153653)
The error message has been updated in macOS 26. Relax the error message
to check the more generic "BUG IN CLIENT OF LIBMALLOC" rather than the
error message that comes after.
2025-08-18 14:01:41 -05:00
Trevor Gross
549d7c4f35
[SPARC] Change half to use soft promotion rather than PromoteFloat (#152727)
`half` currently uses the default legalization of promoting to a `f32`;
however, this implementation implements math in a way that results in
incorrect rounding. Switch to the soft promote implementation, which
does not have this problem.

The SPARC ABI does not specify a `_Float16` type, so there is no concern
with keeping interface compatibility.

Fixes the SPARC part of
https://github.com/llvm/llvm-project/issues/97975
Fixes the SPARC part of
https://github.com/llvm/llvm-project/issues/97981
2025-08-18 20:56:24 +02:00
Matthias Braun
43df97a909
llvm-profgen: Avoid "using namespace" in headers (#147631)
Avoid global `using namespace` directives in headers as they are bad
style.
2025-08-18 18:55:23 +00:00
Krzysztof Parzyszek
8429f7faaa
[flang][OpenMP] Parsing support for DYN_GROUPPRIVATE (#153615)
This does not perform semantic checks or lowering.
2025-08-18 13:35:02 -05:00
Steven Perron
0fb1057e40
[SPIRV] Filter disallowed extensions for env (#150051)
Not all SPIR-V extensions are allows in every environment. When we use
the `-spirv-ext=all` option, the backend currently believes that all
extensions can be used.

This commit filters out the extensions on the command line to remove
those that are not known to be allowed for the current environment.

Alternatives considered: I considered modifying the
SPIRVExtensionsParser::parse to use a different list of extensions for
"all" depending on the target triple. However that does not work because
the target triple is not available, and cannot be made available in a
reasonable way.

Fixes #147717

---------

Co-authored-by: Victor Lomuller <victor@codeplay.com>
2025-08-18 18:33:58 +00:00
Thurston Dang
ade755d62b
[msan] Add Instrumentation for Avx512 Instructions: pmaddw, pmaddubs (#153919)
This applies the pmadd handler (recently improved in https://github.com/llvm/llvm-project/pull/153353) to the Avx512
equivalent of the pmaddw and pmaddubs intrinsics:
  <16 x i32> @llvm.x86.avx512.pmaddw.d.512(<32 x i16>, <32 x i16>)
  <32 x i16> @llvm.x86.avx512.pmaddubs.w.512(<64 x i8>, <64 x i8>)
2025-08-18 11:31:15 -07:00
Kyle Wang
064f02dac0
[VectorCombine] Preserve scoped alias metadata (#153714)
Right now if a load op is scalarized, the `!alias.scope` and `!noalias`
metadata are dropped. This PR is to keep them if exist.
2025-08-18 18:16:32 +00:00
Jordan Rupprecht
8d256733a0
[bazel] Port #151175: VectorFromElementsLowering (#154169) 2025-08-18 13:07:05 -05:00
Brox Chen
d49aab10bd
Revert "[AMDGPU][True16][CodeGen] use vgpr16 for zext patterns (#1538… (#154163)
This reverts commit 7c53c6162bd43d952546a3ef7d019babd5244c29.

This patch hit an issue in hip test. revert and will reopen later
2025-08-18 14:01:19 -04:00
Shaoce SUN
7e8ff2afa9
[RISCV][GISel] Optimize +0.0 to use fcvt.d.w for s64 on rv32 (#153978)
Resolve the TODO: on RV32, when constructing the double-precision
constant `+0.0` for `s64`, `BuildPairF64Pseudo` can be optimized to use
the `fcvt.d.w` instruction to generate the result directly.
2025-08-18 17:52:24 +00:00
Justin Fargnoli
58de8f2c25
[Inliner] Add option (default off) to inline all calls regardless of the cost (#152365)
Add a default off option to the inline cost calculation to always inline
all viable calls regardless of the cost/benefit and cost/threshold
calculations.

For performance reasons, some users require that all calls be inlined.
Rather than forcing them to adjust the inlining threshold to an
arbitrarily high value, offer an option to inline all calls.
2025-08-18 17:48:49 +00:00
LauraElanorJones
350f4a3e3b
Decent to Descent (#154040)
[lldb] Rename RecursiveDecentFormatter to RecursiveDescentFormatter (NFC)
2025-08-18 12:47:14 -05:00
Krzysztof Drewniak
7f27482a32
[AMDGPU][LowerBufferFatPointers] Fix lack of rewrite when loading/storing null (#154128)
Fixes #154056.

The fat buffer lowering pass was erroniously detecting that it did not
need to run on functions that only load/store to the null constant (or
other such constants). We thought this would be covered by specializing
constants out to instructions, but that doesn't account foc trivial
constants like null. Therefore, we check the operands of instructions
for buffer fat pointers in order to find such constants and ensure the
pass runs.

---------

Co-authored-by: Nikita Popov <github@npopov.com>
2025-08-18 12:32:54 -05:00
Shafik Yaghmour
99829573cc
[Clang][Webassembly] Remove unrachable code in ParseTypeQualifierListOpt (#153729)
Static analysis flagged this goto as unreachable and indeed it is, so
removing it.
2025-08-18 10:27:37 -07:00
Aiden Grossman
6960bf556c
[Github] Drop llvm-project-tests
All users of this have been claned up so we can now drop it fully.

Reviewers: cmtice, tstellar

Reviewed By: cmtice

Pull Request: https://github.com/llvm/llvm-project/pull/153877
2025-08-18 10:20:31 -07:00
Panagiotis Karouzakis
c2e7fad446
[DemandedBits] Support non-constant shift amounts (#148880)
This patch adds support for the shift operators to handle non-constant
shift operands.

ashr proof -->https://alive2.llvm.org/ce/z/EN-siK
lshr proof --> https://alive2.llvm.org/ce/z/eeGzyB
shl proof --> https://alive2.llvm.org/ce/z/dpvbkq
2025-08-19 01:11:16 +08:00
Yang Bai
4eb1a07d7d
[mlir][vector] Support multi-dimensional vectors in VectorFromElementsLowering (#151175)
This patch introduces a new unrolling-based approach for lowering
multi-dimensional `vector.from_elements` operations.

**Implementation Details:**
1. **New Transform Pattern**: Added `UnrollFromElements` that unrolls a
N-D(N>=2) from_elements op to a (N-1)-D from_elements op align the
outermost dimension.
2. **Utility Functions**: Added `unrollVectorOp` to reuse the unroll
algo of vector.gather for vector.from_elements.
3. **Integration**: Added the unrolling pattern to the
convert-vector-to-llvm pass as a temporal transformation.
4. Use direct LLVM dialect operations instead of intermediate
vector.insert operations for efficiency in `VectorFromElementsLowering`.

**Example:**
```mlir
// unroll
%v = vector.from_elements  %e0, %e1, %e2, %e3 : vector<2x2xf32>
=>
%poison_2d = ub.poison : vector<2x2xf32>
%vec_1d_0 = vector.from_elements %e0, %e1 : vector<2xf32>
%vec_2d_0 = vector.insert %vec_1d_0, %poison_2d [0] : vector<2xf32> into vector<2x2xf32>
%vec_1d_1 = vector.from_elements %e2, %e3 : vector<2xf32>
%result = vector.insert %vec_1d_1, %vec_2d_0 [1] : vector<2xf32> into vector<2x2xf32>

// convert-vector-to-llvm
%v = vector.from_elements %e0, %e1, %e2, %e3 : vector<2x2xf32>
=>
%poison_2d = ub.poison : vector<2x2xf32>
%poison_2d_cast = builtin.unrealized_conversion_cast %poison_2d : vector<2x2xf32> to !llvm.array<2 x vector<2xf32>>
%poison_1d_0 = llvm.mlir.poison : vector<2xf32>
%c0_0 = llvm.mlir.constant(0 : i64) : i64
%vec_1d_0_0 = llvm.insertelement %e0, %poison_1d_0[%c0_0 : i64] : vector<2xf32>
%c1_0 = llvm.mlir.constant(1 : i64) : i64
%vec_1d_0_1 = llvm.insertelement %e1, %vec_1d_0_0[%c1_0 : i64] : vector<2xf32>
%vec_2d_0 = llvm.insertvalue %vec_1d_0_1, %poison_2d_cast[0] : !llvm.array<2 x vector<2xf32>>
%poison_1d_1 = llvm.mlir.poison : vector<2xf32>
%c0_1 = llvm.mlir.constant(0 : i64) : i64
%vec_1d_1_0 = llvm.insertelement %e2, %poison_1d_1[%c0_1 : i64] : vector<2xf32>
%c1_1 = llvm.mlir.constant(1 : i64) : i64
%vec_1d_1_1 = llvm.insertelement %e3, %vec_1d_1_0[%c1_1 : i64] : vector<2xf32>
%vec_2d_1 = llvm.insertvalue %vec_1d_1_1, %vec_2d_0[1] : !llvm.array<2 x vector<2xf32>>
%result = builtin.unrealized_conversion_cast %vec_2d_1 : !llvm.array<2 x vector<2xf32>> to vector<2x2xf32>
```

---------

Co-authored-by: Nicolas Vasilache <Nico.Vasilache@amd.com>
Co-authored-by: Yang Bai <yangb@nvidia.com>
Co-authored-by: James Newling <james.newling@gmail.com>
Co-authored-by: Diego Caballero <dieg0ca6aller0@gmail.com>
2025-08-18 10:09:12 -07:00
Tobias Stadler
8135b7c1ab
[LV] Emit all remarks for unvectorizable instructions (#153833)
If ExtraAnalysis is requested, emit all remarks caused by unvectorizable instructions - instead of only the first.
This is in line with how other places handle DoExtraAnalysis and it can be quite helpful to get info about all instructions in a loop that prevent vectorization.
2025-08-18 18:04:53 +01:00
Ramkumar Ramachandra
97f554249c
[VPlan] Preserve nusw in createInBoundsPtrAdd (#151549)
Rename createInBoundsPtrAdd to createNoWrapPtrAdd, and preserve nusw as
well as inbounds at the callsite.
2025-08-18 17:48:42 +01:00
Andreas Jonson
1b60236200
[SimplifyCFG] Avoid redundant calls in gather. (NFC) (#154133)
Split out from https://github.com/llvm/llvm-project/pull/154007 as it
showed compile time improvements

NFC as there needs to be at least two icmps that is part of the chain.
2025-08-18 18:45:52 +02:00
Nishant Patel
4a9d038acd
[MLIR][XeGPU] Distribute load_nd/store_nd/prefetch_nd with offsets from Wg to Sg (#153432)
This PR adds pattern to distribute the load/store/prefetch nd ops with
offsets from workgroup to subgroup IR. This PR is part of the transition
to move offsets from create_nd to load/store/prefetch nd ops.

Create_nd PR : #152351
2025-08-18 09:45:29 -07:00
LLVM GN Syncbot
d6e0922a5e [gn build] Port 3ecfc0330d93 2025-08-18 16:02:02 +00:00
Damyan Pepper
cc49f3b3e1
[NFC][HLSL] Remove confusing enum aliases / duplicates (#153909)
Remove:

* DescriptorType enum - this almost exactly shadowed the ResourceClass
enum
* ClauseType aliased ResourceClass

Although these were introduced to make the HLSL root signature handling
code a bit cleaner, they were ultimately causing confusion as they
appeared to be unique enums that needed to be converted between each
other.

Closes #153890
2025-08-18 08:58:33 -07:00
Yitzhak Mandelbaum
3ecfc0330d
[clang][dataflow] Add support for serialization and deserialization. (#152487)
Adds support for compact serialization of Formulas, and a corresponding
parse function. Extends Environment and AnalysisContext with necessary
functions for serializing and deserializing all formula-related parts of
the environment.
2025-08-18 11:55:12 -04:00
Jeremy Kun
c67d27dad0
[mlir][Presburger] NFC: return var index from IntegerRelation::addLocalFloorDiv (#153463)
addLocalFloorDiv currently returns void and requires the caller to know
that the newly added local variable is in a particular index. This
commit returns the index of the newly added variable so that callers
need not tie themselves to this implementation detail.

I found one relevant callsite demonstrating this and updated it. I am
using this API out of tree and wanted to make our out-of-tree code a bit
more resilient to upstream changes.
2025-08-18 08:47:47 -07:00
Antonio Frighetto
33761df961
Revert "[SimpleLoopUnswitch] Record loops from unswitching non-trivial conditions"
This reverts commit e9de32fd159d30cfd6fcc861b57b7e99ec2742ab due to
multiple performance regressions observed across downstream Numba
benchmarks (https://github.com/llvm/llvm-project/issues/138509#issuecomment-3193855772).

While avoiding non-trivial unswitches on newly-cloned loops helps
mitigate the pathological case reported in https://github.com/llvm/llvm-project/issues/138509,
it may as well make the IR less friendly to vectorization / loop-
canonicalization (in the test reported, previously no select with
loop-carried dependence existed in the new specialized loops),
leading the abovementioned approach to be reconsidered.
2025-08-18 17:40:08 +02:00
Aiden Grossman
17f5f5ba55 [X86] Avoid Register implicit int conversion
PushedRegisters in this patch needs to be of type int64_t because iot is
grabbing registers from immediate operands of pseudo instructions.
However, we then compare to an actual register type later, which relies
on the implicit conversion within Register to int, which can result in
build failures in some configurations.
2025-08-18 15:37:25 +00:00
黃國庭
0773854575
[DAG] Fold trunc(avg(x,y)) for avgceil/floor u/s nodes if they have sufficient leading zero/sign bits (#152273)
avgceil version :  https://alive2.llvm.org/ce/z/2CKrRh  

Fixes #147773 

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-18 16:36:26 +01:00
Alex MacLean
d12f58ff11
[NVVM] Add various intrinsic attrs, cleanup and consolidate td (#153436)
- llvm.nvvm.reflect - Use a PureIntrinsic for (adding speculatable),
this will be replaced by a constant prior to lowering so speculation is
fine.
- llvm.nvvm.tex.* - Add [IntrNoCallback, IntrNoFree, IntrWillReturn]
- llvm.nvvm.suld.* - Add [IntrNoCallback, IntrNoFree] and
[IntrWillReturn] when not using "clamp" mode
- llvm.nvvm.sust.* - Add [IntrNoCallback, IntrNoFree, IntrWriteMem] and
[IntrWillReturn] when not using "clamp" mode
- llvm.nvvm.[suq|txq|istypep].* - Use DefaultAttrsIntrinsic
- llvm.nvvm.read.ptx.sreg.* - Add [IntrNoFree, IntrWillReturn] to
non-constant reads as well.
2025-08-18 08:33:23 -07:00
Andres-Salamanca
916218ccbd
[CIR] Upstream GotoOp (#153701)
This PR upstreams `GotoOp`. It moves some tests from the `goto` test
file to the `label` test file, and adds verify logic to `FuncOp`. The
gotosSolver, required for lowering, will be implemented in a future PR.
2025-08-18 10:25:40 -05:00
Craig Topper
60aa0d4bfc
[RISCV] Add P-ext MC support for pli.dh, pli.db, and plui.dh. (#153972)
Refactor the pli.b/h/w and plui.h/w tablegen classes.
2025-08-18 08:23:14 -07:00
Jacques Pienaar
4bf33958da
[mlir] Update builders to use new form. (#154132)
Mechanically applied using clang-tidy.
2025-08-18 15:19:34 +00:00
Jay Foad
f15c6ff6cb
[AMDGPU] Make use of SIInstrInfo::isWaitcnt. NFC. (#154087) 2025-08-18 16:18:46 +01:00
Timm Baeder
6ce13ae1c2
[clang][bytecode] Always track item types in InterpStack (#151088)
This has been a long-standing problem, but we didn't use to call the
destructors of items on the stack unless we explicitly `pop()` or
`discard()` them.

When interpretation was interrupted midway-through (because something
failed), we left `Pointer`s on the stack. Since all `Block`s track what
`Pointer`s point to them (via a doubly-linked list in the `Pointer`),
that meant we potentially leave deallocated pointers in that list. We
used to work around this by removing the `Pointer` from the list before
deallocating the block.

However, we now want to track pointers to global blocks as well, which
poses a problem since the blocks are never deallocated and thus those
pointers are always left dangling.

I've tried a few different approaches to fixing this but in the end I
just gave up on the idea of never knowing what items are in the stack.
We already have an `ItemTypes` vector that we use for debugging
assertions. This patch simply enables this vector unconditionally and
uses it in the abort case to properly `discard()` all elements from the
stack. That's a little sad IMO but I don't know of another way of
solving this problem.

As expected, this is a slight hit to compile times:
https://llvm-compile-time-tracker.com/compare.php?from=574d0a92060bf4808776b7a0239ffe91a092b15d&to=0317105f559093cfb909bfb01857a6b837991940&stat=instructions:u
2025-08-18 17:15:31 +02:00
AZero13
08a140add8
[AArch64] Fix build-bot assertion error in AArch64 (#154124)
Fixes build bot assertion.

I forgot to include logic that will be added in a future PR that handles
-1 correctly. For now, let's just return nullptr like we used to.
2025-08-18 15:12:07 +00:00
William Tran-Viet
1c51886920
[libc++] Implement P3168R2: Give optional range support (#149441)
Resolves #105430

- Implement all required pieces of P3168R2
- Leverage existing `wrap_iter` and `bounded_iter` classes to implement
the `optional` regular and hardened iterator type, respectively
- Update documentation to match
2025-08-18 18:04:45 +03:00
Tiger Ding
4ab14685a0
[AMDGPU] Narrow only on store to pow of 2 mem location (#150093)
Lowering in GlobalISel for AMDGPU previously always narrows to i32 on
truncating store regardless of mem size or scalar size, causing issues
with types like i65 which is first extended to i128 then stored as i64 +
i8 to i128 locations. Narrowing only on store to pow of 2 mem location
ensures only narrowing to mem size near end of legalization.

This LLVM defect was identified via the AMD Fuzzing project.
2025-08-19 00:04:27 +09:00
Brox Chen
7c53c6162b
[AMDGPU][True16][CodeGen] use vgpr16 for zext patterns (#153894)
Update true16 mode with zext patterns using vgpr16 for 16bit data types.
This stop isel from inserting invalid "vgpr32 = copy vgpr16"
2025-08-18 11:01:57 -04:00
David Green
03912a1de5
[GlobalISel] Translate scalar sequential vecreduce.fadd/fmul as fadd/fmul. (#153966)
A llvm.vector.reduce.fadd(float, <1 x float>) will be translated to
G_VECREDUCE_SEQ_FADD with two scalar operands, which is illegal
according to the verifier. This makes sure we generate a fadd/fmul
instead.
2025-08-18 14:59:44 +00:00
LLVM GN Syncbot
f4b5c24022 [gn build] Port e6e874ce8f05 2025-08-18 14:52:19 +00:00
LLVM GN Syncbot
ad064bc5c3 [gn build] Port a0f325bd41c9 2025-08-18 14:52:18 +00:00
erichkeane
ec227050e3 [OpenACC] Fix verify lines from 8fc80519cdb97c
Like a big dummy, I completely skipped running this test locally and
forgot it would need check lines.  *sigh*, Looks like SOMEONE has a case
of the Mondays!

Anyway, this patch fixes it by adding the proper verify lines.
2025-08-18 07:49:38 -07:00
Craig Topper
98e8f01d18
[RISCV] Rename MIPS_PREFETCH->MIPS_PREF. NFC (#154062)
This matches the instruction's assembler mnemonic.
2025-08-18 07:38:10 -07:00
erichkeane
8fc80519cd [OpenACC] Fix crash on error recovery of variable in OpenACC mode
As reported, OpenACC's variable declaration handling was assuming some
semblence of legality in the example, so it didn't properly handle an
error case.  This patch fixes its assumptions so that we don't crash.

Fixes #154008
2025-08-18 07:37:45 -07:00
Timm Baeder
8f0da9b8bd
[clang][bytecode] Disable EndLifetime op for array elements (#154119)
This breaks a ton of libc++ tests otherwise, since calling
std::destroy_at will currently end the lifetime of the entire array not
just the given element.

See https://github.com/llvm/llvm-project/issues/147528
2025-08-18 16:32:50 +02:00
David Green
8b52e5ac22 [AArch64] Update and cleanup irtranslator-reductions.ll. NFC 2025-08-18 15:30:23 +01:00
erichkeane
0dbcdf33b8 [OpenACC] Fix racing commit test failures for firstprivate lowering
The original patch to implement basic lowering for firstprivate didn't
have the Sema work to change the name of the variable being generated
from openacc.private.init to openacc.firstprivate.init. I forgot about
that when I merged the Sema changes this morning, so the tests now
failed.  This patch fixes those up.

Additionally, Suggested on #153622 post-commit, it seems like a good idea to
use a size of APInt that matches the size-type, so this changes us to use that
instead.
2025-08-18 07:26:50 -07:00
Aaron Ballman
f5dc3021cd
[C] Fix failing assertion with designated inits (#154120)
Incompatible pointer to integer conversion diagnostic checks would
trigger an assertion when the designated initializer is for an array of
unknown bounds.

Fixes #154046
2025-08-18 14:22:31 +00:00
Connector Switch
b368e7f6a5
[flang] optimize acosd precision (#154118)
Part of https://github.com/llvm/llvm-project/issues/150452.
2025-08-18 14:15:52 +00:00
Krzysztof Parzyszek
ae75884130
[Frontend][OpenMP] Add 6.1 as a valid OpenMP version (#153628)
Co-authored-by: Michael Klemm <michael.klemm@amd.com>
2025-08-18 09:13:27 -05:00
Aiden Grossman
2497864e09
[Github] Remove call to llvm-project-tests from libclang tests
This allows for removing llvm-project-tests.yml. This significantly
reduces the complexity of this workflow (including the complexity of
llvm-project-tests.yml) at the cost of a little bit of duplication with
the other workflows that were also using llvm-project-tests.yml.

Reviewers: tstellar, DeinAlptraum

Reviewed By: DeinAlptraum

Pull Request: https://github.com/llvm/llvm-project/pull/153876
2025-08-18 07:07:26 -07:00
Aiden Grossman
f8cd582534
[Github] Remove call to llvm-project-tests.yml from mlir-spirv-tests.yml
This will eventually allow for removing llvm-project-tests.yml. This
should significantly reduce the complexity of this workflow (including
the complexity of llvm-project-tests.yml) at the cost of a little bit of
duplication.

Reviewers: IgWod-IMG, kuhar

Reviewed By: kuhar

Pull Request: https://github.com/llvm/llvm-project/pull/153871
2025-08-18 07:05:39 -07:00
Kazu Hirata
c48ec7fb60
[clang] Proofread SourceBasedCodeCoverage.rst (#154050) 2025-08-18 07:02:15 -07:00
Kazu Hirata
07eb7b7692
[llvm] Replace SmallSet with SmallPtrSet (NFC) (#154068)
This patch replaces SmallSet<T *, N> with SmallPtrSet<T *, N>.  Note
that SmallSet.h "redirects" SmallSet to SmallPtrSet for pointer
element types:

  template <typename PointeeType, unsigned N>
class SmallSet<PointeeType*, N> : public SmallPtrSet<PointeeType*, N>
{};

We only have 140 instances that rely on this "redirection", with the
vast majority of them under llvm/. Since relying on the redirection
doesn't improve readability, this patch replaces SmallSet with
SmallPtrSet for pointer element types.
2025-08-18 07:01:29 -07:00
AZero13
0e52092ff7
[AArch64] Adjust comparison constant if adjusting it means less instructions (#151024)
Prefer constants that require less instructions to materialize, in both
Global-ISel and Selection-DAG
2025-08-18 14:56:45 +01:00
Simon Pilgrim
858d1dfa2c
[DAG] visitTRUNCATE - early out from computeKnownBits/ComputeNumSignBits failures. NFC. (#154111)
Avoid unnecessary (costly) computeKnownBits/ComputeNumSignBits calls - use MaskedValueIsZero instead of computeKnownBits directly to simplify code.
2025-08-18 14:55:09 +01:00
Benjamin Maxwell
81c06d198e
Reland "[AArch64][SME] Port all SME routines to RuntimeLibcalls" (#153417)
This updates everywhere we emit/check an SME routines to use
RuntimeLibcalls to get the function name and calling convention.
2025-08-18 14:53:40 +01:00
halbi2
2a02147ff5
[clang] [Sema] Simplify Expr::isUnusedResultAWarning for CXXConstructExpr (#153116)
…Expr

Two tests have new warnings because `warn_unused_result` is now
respected for constructor temporaries. These tests were newly added in
#112521 last year. This is good because the new behavior is better than
the old.

@Sirraide and @Mick235711 what do you think about it?
2025-08-18 06:49:04 -07:00
Aiden Grossman
5b2c3aac90
[MCA][X86] Pretend To Have a Stack Engine (#153348)
This patch removes RSP dependencies from push and pop instructions to
pretend that we have a stack engine. This does not model details like
sync uops that are relevant implementation details due to complexity.
This is just enabled on all X86 CPUs given LLVM does not have a
scheduling model for any X86 CPU that does not have a stack engine.

This fixes #152008.
2025-08-18 13:44:43 +00:00
Shilei Tian
e37eff5dcd
[AMDGPU] Add an option to completely disable kernel argument preload (#153975)
The existing `amdgpu-kernarg-preload-count` can't be used as a switch to
turn it off if it is set to 0. This PR adds an extra option to turn it
off.

Fixes SWDEV-550147.
2025-08-18 09:44:20 -04:00
Jonathan Thackray
f38c83c582
[AArch64][llvm] Disassemble instructions in SYS alias encoding space more correctly (#153905)
For instructions in the `SYS` alias encoding space which take no
register operands, and where the unused 5 register bits are not all set
(0x31, 0b11111), then disassemble to a `SYS` alias and not the
instruction, since it is not considered valid.

This is because it is specified in the Arm ARM in text similar to this
(e.g. page C5-1037 of DDI0487L.b for `TLBI ALLE1`, or page C5-1585 for
`GCSPOPX`):
```
  Rt should be encoded as 0b11111. If the Rt field is not set to 0b11111,
  it is CONSTRAINED UNPREDICTABLE whether:
    * The instruction is UNDEFINED.
    * The instruction behaves as if the Rt field is set to 0b11111.
```

Since we want to follow "should" directives, and not encourage undefined
behaviour, only assemble or disassemble instructions considered valid.
Add an extra test-case for this, and all existing test-cases are
continuing to pass.
2025-08-18 14:41:41 +01:00
Timm Baeder
31d2db2a68
[clang][bytecode][NFC] Use UnsignedOrNone for Block::DeclID (#154104) 2025-08-18 15:40:44 +02:00
Erich Keane
340fa3e1bb
[OpenACC] Implement firstprivate lowering except init. (#153847)
This patch implements the basic lowering infrastructure, but does not
quite implement the copy initialization, which requires #153622.

It does however pass verification for the 'copy' section, which just
contains a yield.
2025-08-18 06:33:40 -07:00
Aiden Grossman
1650e4a73c
[X86] Remove TuningPOPCNTFalseDeps from AlderLake (#154004)
This false dependency issue was fixed in CannonLake looking at the data
from uops.info. This is confirmed not to be an issue based on
benchmarking data in #153983. Setting this can potentially lead to extra
xor instructions whihc could consume extra frontend/renaming resources.

None of the other CPUs that have had this fixed have the tuning flag.

Fixes #153983.
2025-08-18 06:31:16 -07:00
Matthias Springer
f84aaa6eaa
[mlir][Transforms] Dialect conversion: Add flag to dump materialization kind (#119532)
Add a debugging flag to the dialect conversion to dump the
materialization kind. This flag is useful to find out whether a missing
materialization rule is for source or target materializations.

Also add missing test coverage for the `buildMaterializations` flag.
2025-08-18 13:25:18 +00:00
Nikita Popov
ba45ac61b6 [CAS] Temporarily disable broken test
This test hangs forever if executed with less than three cores
available, see:
https://github.com/llvm/llvm-project/pull/114096#issuecomment-3196698403
2025-08-18 15:09:08 +02:00
Chaitanya
4a3bf27c69
[OpenMP] Introduce omp.target_allocmem and omp.target_freemem omp dialect ops. (#145464)
This PR introduces two new ops in omp dialect, omp.target_allocmem and
omp.target_freemem.
omp.target_allocmem: Allocates heap memory on device. Will be lowered to
omp_target_alloc call in llvm.
omp.target_freemem: Deallocates heap memory on device. Will be lowered
to omp+target_free call in llvm.


Example:
  %1 = omp.target_allocmem %device : i32, i64
  omp.target_freemem %device, %1 : i32, i64

The work in this PR is C-P/inspired from @ivanradanov commit from
coexecute implementation:
[Add fir omp target alloc and free
ops](be860ac8ba)
[Lower omp_target_{alloc,free} to
llvm](6e2d584dc9)
2025-08-18 18:15:11 +05:30
jofrn
e8e3e6e893
[LiveVariables] Mark use without implicit if defined at instr (#119446)
LiveVariables will mark instructions with their implicit subregister
uses. However, it will also mark the subregister as an implicit if its
own definition is a subregister of it, i.e. `$r3 = OP val, implicit-def
$r0_r1_r2_r3, ..., implicit $r2_r3`, even if it is otherwise unused,
which defines $r3 on the same line it is used.

This change ensures such uses are marked without implicit, i.e. `$r3 =
OP val, implicit-def $r0_r1_r2_r3, ..., $r2_r3`.

---------

Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
2025-08-18 08:34:59 -04:00
Akash Banerjee
6aafe6582d Fix test added in 1fd1d634630754cc9b9c4b5526961d5856f64ff9 2025-08-18 13:29:23 +01:00
ZhaoQi
8f671a675f
[LoongArch] Always emit symbol-based relocations regardless of relaxation (#153943)
This commit changes all relocations to be relocated with symbols.

Without this commit, errors may occur in some cases, such as when using
`llc/lto+relax`, or combining relaxed and norelaxed object files using
`ld -r`.

Some tests updated.
2025-08-18 20:15:49 +08:00
Jonathan Cohen
c6fe567064
[AArch64][MachineCombiner] Combine sequences of gather patterns (#152979)
Reland of #142941

Squashed with fixes for #150004, #149585

This pattern matches gather-like patterns where
values are loaded per lane into neon registers, and 
replaces it with loads into 2 separate registers, which
will be combined with a zip instruction. This decreases
the critical path length and improves Memory Level
Parallelism.

rdar://151851094
2025-08-18 15:10:59 +03:00
Utkarsh Saxena
673750feea
[LifetimeSafety] Implement a basic use-after-free diagnostic (#149731)
Implement use-after-free detection in the lifetime safety analysis with two warning levels.

- Added a `LifetimeSafetyReporter` interface for reporting lifetime safety issues
- Created two warning levels:
    - Definite errors (reported with `-Wexperimental-lifetime-safety-permissive`)
    - Potential errors (reported with `-Wexperimental-lifetime-safety-strict`)
- Implemented a `LifetimeChecker` class that analyzes loan propagation and expired loans to detect use-after-free issues.
- Added tracking of use sites through a new `UseFact` class.
- Enhanced the `ExpireFact` to track the expressions where objects are destroyed.
- Added test cases for both definite and potential use-after-free scenarios.

The implementation now tracks pointer uses and can determine when a pointer is dereferenced after its loan has been expired, with appropriate diagnostics.

The two warning levels provide flexibility - definite errors for high-confidence issues and potential errors for cases that depend on control flow.
2025-08-18 13:46:43 +02:00
Kareem Ergawy
c1e2a9c66d
[flang][OpenMP] Only privaize pre-determined symbols when defined the evaluation. (#154070)
Fixes a regression uncovered by Fujitsu test 0686_0024.f90. In
particular, verifies that a pre-determined symbol is only privatized by
its defining evaluation (e.g. the loop for which the symbol was marked
as pre-determined).
2025-08-18 13:36:08 +02:00
Mehdi Amini
cfe5975eaf
[MLIR] Fix SCF verifier crash (#153974)
An operand of the nested yield op can be null and hasn't been verified
yet when processing the enclosing operation. Using `getResultTypes()`
will dereference this null Value and crash in the verifier.
2025-08-18 12:48:55 +02:00
Simon Pilgrim
681ecae913
[DAG] visitTRUNCATE - test abd legality early to avoid unnecessary computeKnownBits/ComputeNumSignBits calls. NFC. (#154085)
isOperationLegal is much cheaper than value tracking
2025-08-18 11:06:29 +01:00
林克
6842cc5562
[RISCV] Add SpacemiT XSMTVDot (SpacemiT Vector Dot Product) extension. (#151706)
The full spec can be found at spacemit-x60 processor support scope:
Section 2.1.2.2 (Features):

https://developer.spacemit.com/documentation?token=BWbGwbx7liGW21kq9lucSA6Vnpb#2.1

This patch only supports assembler.
2025-08-18 18:03:17 +08:00
Arne Stenkrona
ea2f5395b1
[SimplifyCFG] Avoid threading for loop headers (#151142)
Updates SimplifyCFG to avoid jump threading through loop headers if
-keep-loops is requested. Canonical loop form requires a loop header
that dominates all blocks in the loop. If we thread through a header, we
risk breaking its domination of the loop. This change avoids this issue
by conservatively avoiding threading through headers entirely.

Fixes: https://github.com/llvm/llvm-project/issues/151144
2025-08-18 09:46:55 +00:00
Simon Pilgrim
169b43d4b8 Remove unused variable introduced in #152705 2025-08-18 10:45:09 +01:00
ZhaoQi
76fb1619f0
[LoongArch] Reduce number of reserved relocations when relax enabled (#153769) 2025-08-18 17:42:43 +08:00
Andrzej Warzyński
51b5a3e1a6
[MLIR] Add Egress dialects maintainers (#151721)
As per https://discourse.llvm.org/t/mlir-project-maintainers/87189, this
PR adds maintainers for the "egress" dialects.

Compared to the original proposal, two changes are included:
* The "mesh" dialect has been renamed to "shard"
(https://discourse.llvm.org/t/mlir-mesh-cleanup-mesh/).
* The "XeVM" dialect has been added
(https://discourse.llvm.org/t/rfc-proposal-for-new-xevm-dialect/).
2025-08-18 10:34:44 +01:00
Simon Pilgrim
36f911173a [X86] avx512vlbw-builtins.c - add C/C++ test coverage 2025-08-18 10:30:15 +01:00
Simon Pilgrim
6036e5d0d7 [X86] avx512vlbw-reduceIntrin.c - add C/C++ and -fno-signed-char test coverage 2025-08-18 10:30:14 +01:00
Timm Baeder
0d05c42b6a
[clang][bytecode] Improve __builtin_{,dynamic_}object_size implementation (#153601) 2025-08-18 11:12:33 +02:00
Oliver Hunt
bcab8ac126
[clang] return type not correctly deduced for discarded lambdas (#153921)
The early return for lamda expressions with deduced return types in
Sema::ActOnCapScopeReturnStmt meant that we were not actually perform
the required return type deduction for such lambdas when in a discarded
context.

This PR removes that early return allowing the existing return type
deduction steps to be performed.

Fixes #153884

Fix developed by, and

Co-authored-by: Corentin Jabot <corentinjabot@gmail.com>
2025-08-18 02:07:27 -07:00
Mehdi Amini
16aa283344
[MLIR] Refactor the walkAndApplyPatterns driver to remove the recursion (#154037)
This is in preparation of a follow-up change to stop traversing
unreachable blocks.

This is not NFC because of a subtlety of the early_inc. On a test case
like:

```
  scf.if %cond {
    "test.move_after_parent_op"() ({
      "test.any_attr_of_i32_str"() {attr = 0 : i32} : () -> ()
    }) : () -> ()
  }
```

We recursively traverse the nested regions, and process an op when the
region is done (post-order).
We need to pre-increment the iterator before processing an operation in
case it gets deleted. However
we can do this before or after processing the nested region. This
implementation does the latter.
2025-08-18 09:07:19 +00:00
Balázs Kéri
a0f325bd41
[clang-tidy] Added check 'misc-override-with-different-visibility' (#140086) 2025-08-18 11:00:42 +02:00
Mehdi Amini
87e6fd161a
[MLIR] Erase unreachable blocks before applying patterns in the greedy rewriter (#153957)
Operations like:

    %add = arith.addi %add, %add : i64

are legal in unreachable code. Unfortunately many patterns would be
unsafe to apply on such IR and can lead to crashes or infinite loops. To
avoid this we can remove unreachable blocks before attempting to apply
patterns.
We may have to do this also whenever the CFG is changed by a pattern, it
is left up for future work right now.

Fixes #153732
2025-08-18 10:59:43 +02:00
David Sherwood
7ee6cf06c8
[LV] Fix incorrect cost kind in VPReplicateRecipe::computeCost (#153216)
We were incorrectly using the TTI::TCK_RecipThroughput cost kind and
ignoring the kind set in the context.
2025-08-18 09:52:31 +01:00
hstk30-hw
c99cbc880f
[llvm] Fix typo for CGProfile (NFC) (#153370) 2025-08-18 16:46:27 +08:00
Joachim
98dd1888bf
[OpenMP][Test][NFC] output tool data as hex to improve readibility (#152757)
Using hex format allows to better interpret IDs: 
the first digits represent the thread number, the last digits represent
the ID within a thread

The main change is in callback.h: PRIu64 -> PRIx64

The patch also guards RUN/CHECK lines in openmp/runtime/tests/ompt with clang-format on/off comments and clang-formats the directory.

---------

Co-authored-by: Kaloyan Ignatov <kaloyan.ignatov@rwth-aachen.de>
2025-08-18 10:42:33 +02:00
Simon Pilgrim
ce5276f61c
[Clang][X86] Add avx512 __builtin_ia32_select* constexpr handling (#152705)
This should allow us to constexpr many avx512 predicated intrinsics where they wrap basic intrinsics that are already constexpr

Fixes #152321
2025-08-18 09:37:20 +01:00
Matthias Springer
ff68f7115c
[mlir][builtin] Make unrealized_conversion_cast inlineable (#139722)
Until now, `builtin.unrealized_conversion_cast` ops could not be inlined
by the Inliner pass.
2025-08-18 10:23:26 +02:00
Matt Arsenault
53e9d3247e
DAG: Remove unnecessary getPointerTy call (#154055)
getValueType already did this
2025-08-18 17:12:16 +09:00
David Green
8f98529209 [AArch64] Remove SIMDLongThreeVectorTiedBHSabal tablegen class.
Similar to #152987 this removes SIMDLongThreeVectorTiedBHSabal as it is
equivalent to SIMDLongThreeVectorTiedBHS with a better TriOpFrag pattern.
2025-08-18 09:11:13 +01:00
ZhaoQi
8181c76bca
[LoongArch][NFC] More tests to ensure branch relocs reserved when relax enabled (#153768) 2025-08-18 16:07:36 +08:00
Ahmad Yasin
1b0bce972b
Reorder checks to speed up getAppleRuntimeUnrollPreferences() (#154010)
- Delay load/store values calculation unless a best unroll-count is
found
- Remove extra getLoopLatch() invocation
2025-08-18 11:06:37 +03:00
Matthias Springer
f7b09ad700
[mlir][LLVM] ArithToLLVM: Add 1:N support for arith.select lowering (#153944)
Add 1:N support for the `arith.select` lowering. Only cases where the
entire true/false value is selected are supported.
2025-08-18 09:42:37 +02:00
Jim Lin
127ba533bd
[RISCV] Remove ST->hasVInstructions() from getIntrinsicInstrCost for cttz/ctlz/ctpop. NFC. (#154064)
That isn't necessary if we've checked ST->hasStdExtZvbb().
2025-08-18 15:24:25 +08:00
Nikita Popov
246a64a12e
[Clang] Rename HasLegalHalfType -> HasFastHalfType (NFC) (#153163)
This option is confusingly named. What it actually controls is whether,
under the default of `-ffloat16-excess-precision=standard`, it is
beneficial for performance to perform calculations on float (without
intermediate rounding) or not. For `-ffloat16-excess-precision=none` the
LLVM `half` type will always be used, and all backends are expected to
legalize it correctly.
2025-08-18 09:23:48 +02:00
Nikita Popov
238c3dcd0d
[CodeGen][Mips] Remove fp128 libcall list (#153798)
Mips requires fp128 args/returns to be passed differently than i128. It
handles this by inspecting the pre-legalization type. However, for soft
float libcalls, the original type is currently not provided (it will
look like a i128 call). To work around that, MIPS maintains a list of
libcalls working on fp128.

This patch removes that list by providing the original, pre-softening
type to calling convention lowering. This is done by carrying additional
information in CallLoweringInfo, as we unfortunately do need both types
(we want the un-softened type for OrigTy, but we need the softened type
for the actual register assignment etc.)

This is in preparation for completely removing all the custom
pre-analysis code in the Mips backend and replacing it with use of
OrigTy.
2025-08-18 09:22:41 +02:00
David Green
790bee99de
[VectorCombine] Remove dead node immediately in VectorCombine (#149047)
The vector combiner will process all instructions as it first loops
through the function, adding any newly added and deleted instructions to
a worklist which is then processed when all nodes are done. These leaves
extra uses in the graph as the initial processing is performed, leading
to sub-optimal decisions being made for other combines. This changes it
so that trivially dead instructions are removed immediately. The main
changes that this requires is to make sure iterator invalidation does not
occur.
2025-08-18 07:55:21 +01:00
ZhaoQi
6957e44d8e
[LoongArch][MC] Refine conditions for emitting ALIGN relocations (#153365)
According to the suggestions in
https://github.com/llvm/llvm-project/pull/150816, this commit refine the
conditions for emitting R_LARCH_ALIGN relocations.

Some existing tests are updated to avoid being affected by this
optimization. New tests are added to verify: removal of redundant ALIGN
relocations, ALIGN emitted after the first linker-relaxable instruction,
and conservatively emitted ALIGN in lower-numbered subsections.
2025-08-18 14:54:27 +08:00
Kazu Hirata
b6a62a496f
[ADT] Use range-based for loops in SetVector (NFC) (#154058) 2025-08-17 23:46:43 -07:00
Kazu Hirata
cbf5af9668
[llvm] Remove unused includes (NFC) (#154051)
These are identified by misc-include-cleaner.  I've filtered out those
that break builds.  Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
2025-08-17 23:46:35 -07:00
Kazu Hirata
400dde6ca8
[RISCV] Remove an unnecessary cast (NFC) (#154049)
&UncompressedMI is already of MCInst *.
2025-08-17 23:46:27 -07:00
Kazu Hirata
1f3c38f125
[Support] Remove an unnecessary cast (NFC) (#154048)
qp is already of uint64_t.
2025-08-17 23:46:20 -07:00
2887 changed files with 177091 additions and 74608 deletions

View File

@ -49,8 +49,7 @@ DEPENDENTS_TO_TEST = {
"flang",
},
"lld": {"bolt", "cross-project-tests"},
# TODO(issues/132795): LLDB should be enabled on clang changes.
"clang": {"clang-tools-extra", "cross-project-tests"},
"clang": {"clang-tools-extra", "cross-project-tests", "lldb"},
"mlir": {"flang"},
# Test everything if ci scripts are changed.
".ci": {

View File

@ -83,11 +83,11 @@ class TestComputeProjects(unittest.TestCase):
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;lld;llvm",
"clang;clang-tools-extra;lld;lldb;llvm",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-tools",
"check-clang check-clang-tools check-lldb",
)
self.assertEqual(
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
@ -158,11 +158,11 @@ class TestComputeProjects(unittest.TestCase):
)
self.assertEqual(
env_variables["projects_to_build"],
"clang;clang-tools-extra;lld;llvm;mlir",
"clang;clang-tools-extra;lld;lldb;llvm;mlir",
)
self.assertEqual(
env_variables["project_check_targets"],
"check-clang check-clang-cir check-clang-tools",
"check-clang check-clang-cir check-clang-tools check-lldb",
)
self.assertEqual(
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"

View File

@ -60,7 +60,8 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
-D LLDB_ENABLE_PYTHON=ON \
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
-D CMAKE_EXE_LINKER_FLAGS="-no-pie"
start-group "ninja"

View File

@ -4,7 +4,6 @@ permissions:
contents: read
on:
workflow_dispatch:
push:
branches:
- 'main'
@ -13,29 +12,46 @@ on:
- 'clang/tools/libclang/**'
- 'clang/CMakeList.txt'
- '.github/workflows/libclang-python-tests.yml'
- '.github/workflows/llvm-project-tests.yml'
pull_request:
paths:
- 'clang/bindings/python/**'
- 'clang/tools/libclang/**'
- 'clang/CMakeList.txt'
- '.github/workflows/libclang-python-tests.yml'
- '.github/workflows/llvm-project-tests.yml'
jobs:
check-clang-python:
# Build libclang and then run the libclang Python binding's unit tests.
# There is an issue running on "windows-2019".
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
name: Build and run Python unit tests
if: github.repository == 'llvm/llvm-project'
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.13"]
uses: ./.github/workflows/llvm-project-tests.yml
with:
build_target: check-clang-python
projects: clang
# There is an issue running on "windows-2019".
# See https://github.com/llvm/llvm-project/issues/76601#issuecomment-1873049082.
os_list: '["ubuntu-24.04"]'
python_version: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ matrix.python-version }}
- name: Setup ccache
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
with:
max-size: 2G
key: spirv-ubuntu-24.04
variant: sccache
- name: Build and Test
run: |
mkdir build
cmake -GNinja \
-S llvm \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DLLVM_ENABLE_PROJECTS=clang
ninja -C build check-clang-python

View File

@ -1,149 +0,0 @@
name: LLVM Project Tests
permissions:
contents: read
on:
workflow_dispatch:
inputs:
build_target:
required: false
projects:
required: false
extra_cmake_args:
required: false
os_list:
required: false
default: '["ubuntu-24.04", "windows-2019", "macOS-13"]'
python_version:
required: false
type: string
default: '3.11'
workflow_call:
inputs:
build_target:
required: false
type: string
default: "all"
projects:
required: true
type: string
extra_cmake_args:
required: false
type: string
os_list:
required: false
type: string
# Use windows-2019 due to:
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
default: '["ubuntu-24.04", "windows-2019", "macOS-13"]'
python_version:
required: false
type: string
default: '3.11'
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
# If the group name here is the same as the group name in the workflow that includes
# this one, then the action will try to wait on itself and get stuck.
group: llvm-project-${{ github.workflow }}-${{ inputs.projects }}-${{ inputs.python_version }}${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
lit-tests:
name: Lit Tests
runs-on: ${{ matrix.os }}
container:
image: ${{(startsWith(matrix.os, 'ubuntu') && 'ghcr.io/llvm/ci-ubuntu-24.04:latest') || null}}
volumes:
- /mnt/:/mnt/
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(inputs.os_list) }}
steps:
- name: Setup Windows
if: startsWith(matrix.os, 'windows')
uses: llvm/actions/setup-windows@main
with:
arch: amd64
# On Windows, starting with win19/20220814.1, cmake choose the 32-bit
# python3.10.6 libraries instead of the 64-bit libraries when building
# lldb. Using this setup-python action to make 3.10 the default
# python fixes this.
- name: Setup Python
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
with:
python-version: ${{ inputs.python_version }}
- name: Install Ninja
if: runner.os != 'Linux'
uses: llvm/actions/install-ninja@main
# actions/checkout deletes any existing files in the new git directory,
# so this needs to either run before ccache-action or it has to use
# clean: false.
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 250
- name: Setup ccache
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
with:
# A full build of llvm, clang, lld, and lldb takes about 250MB
# of ccache space. There's not much reason to have more than this,
# because we usually won't need to save cache entries from older
# builds. Also, there is an overall 10GB cache limit, and each
# run creates a new cache entry so we want to ensure that we have
# enough cache space for all the tests to run at once and still
# fit under the 10 GB limit.
# Default to 2G to workaround: https://github.com/hendrikmuhs/ccache-action/issues/174
max-size: 2G
key: ${{ matrix.os }}
variant: sccache
- name: Build and Test
env:
# Workaround for https://github.com/actions/virtual-environments/issues/5900.
# This should be a no-op for non-mac OSes
PKG_CONFIG_PATH: /usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig//12
shell: bash
id: build-llvm
run: |
if [ "${{ runner.os }}" == "Linux" ]; then
builddir="/mnt/build/"
sudo mkdir -p $builddir
sudo chown gha $builddir
extra_cmake_args="-DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang"
else
builddir="$(pwd)"/build
fi
if [ "${{ runner.os }}" == "macOS" ]; then
# Workaround test failure on some lld tests on MacOS
# https://github.com/llvm/llvm-project/issues/81967
extra_cmake_args="-DLLVM_DISABLE_ASSEMBLY_FILES=ON"
fi
echo "llvm-builddir=$builddir" >> "$GITHUB_OUTPUT"
cmake -G Ninja \
-B "$builddir" \
-S llvm \
-DLLVM_ENABLE_PROJECTS="${{ inputs.projects }}" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLDB_INCLUDE_TESTS=OFF \
-DLIBCLC_TARGETS_TO_BUILD="amdgcn--;amdgcn--amdhsa;r600--;nvptx--;nvptx64--;nvptx--nvidiacl;nvptx64--nvidiacl" \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
$extra_cmake_args \
${{ inputs.extra_cmake_args }}
ninja -C "$builddir" '${{ inputs.build_target }}'
- name: Build and Test libclc
if: "!startsWith(matrix.os, 'windows') && contains(inputs.projects, 'libclc')"
env:
LLVM_BUILDDIR: ${{ steps.build-llvm.outputs.llvm-builddir }}
run: |
# The libclc tests don't have a generated check target so all we can
# do is build it.
ninja -C "$LLVM_BUILDDIR"

View File

@ -1,32 +0,0 @@
# This workflow will test the llvm-project-tests workflow in PRs
# targetting the main branch. Since this workflow doesn't normally
# run on main PRs, we need some way to test it to ensure new updates
# don't break it.
name: LLVM Workflow Test
permissions:
contents: read
on:
pull_request:
branches:
- 'main'
paths:
- '.github/workflows/llvm-project-tests.yml'
- '.github/workflows/llvm-project-workflow-tests.yml'
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
llvm-test:
if: github.repository_owner == 'llvm'
name: Build and Test
uses: ./.github/workflows/llvm-project-tests.yml
with:
build_target: check-all
projects: clang;lld;libclc;lldb

View File

@ -24,9 +24,28 @@ jobs:
check_spirv:
if: github.repository_owner == 'llvm'
name: Test MLIR SPIR-V
uses: ./.github/workflows/llvm-project-tests.yml
with:
build_target: check-mlir
projects: mlir
extra_cmake_args: '-DLLVM_TARGETS_TO_BUILD="host" -DLLVM_INCLUDE_SPIRV_TOOLS_TESTS=ON'
os_list: '["ubuntu-24.04"]'
runs-on: ubuntu-24.04
container:
image: ghcr.io/llvm/ci-ubuntu-24.04:latest
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: Setup ccache
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
with:
max-size: 2G
key: spirv-mlir-ubuntu-24.04
variant: sccache
- name: Build and Test
run: |
mkdir build
cmake -GNinja \
-S llvm \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DLLVM_TARGETS_TO_BUILD="host" \
-DLLVM_INCLUDE_SPIRV_TOOLS_TESTS=ON \
-DLLVM_ENABLE_PROJECTS=mlir
ninja -C build check-mlir

View File

@ -70,8 +70,6 @@ jobs:
- name: Run code formatter
env:
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
START_REV: ${{ github.event.pull_request.base.sha }}
END_REV: ${{ github.event.pull_request.head.sha }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
# Create an empty comments file so the pr-write job doesn't fail.
run: |

View File

@ -69,6 +69,11 @@ jobs:
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
- name: Upload Artifacts
# In some cases, Github will fail to upload the artifact. We want to
# continue anyways as a failed artifact upload is an infra failure, not
# a checks failure.
# https://github.com/actions/upload-artifact/issues/569
continue-on-error: true
if: '!cancelled()'
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
@ -114,6 +119,11 @@ jobs:
# these environment variables.
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
- name: Upload Artifacts
# In some cases, Github will fail to upload the artifact. We want to
# continue anyways as a failed artifact upload is an infra failure, not
# a checks failure.
# https://github.com/actions/upload-artifact/issues/569
continue-on-error: true
if: '!cancelled()'
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:

View File

@ -138,6 +138,12 @@
Dump function CFGs to graphviz format after each stage;enable '-print-loops'
for color-coded blocks
- `--dump-dot-func=<func1,func2,func3...>`
Dump function CFGs to graphviz format for specified functions only;
takes function name patterns (regex supported). Note: C++ function names
must be passed using their mangled names
- `--dump-linux-exceptions`
Dump Linux kernel exception table

View File

@ -1196,11 +1196,6 @@ public:
return getSecondaryEntryPointSymbol(BB.getLabel());
}
/// Remove a label from the secondary entry point map.
void removeSymbolFromSecondaryEntryPointMap(const MCSymbol *Label) {
SecondaryEntryPoints.erase(Label);
}
/// Return true if the basic block is an entry point into the function
/// (either primary or secondary).
bool isEntryPoint(const BinaryBasicBlock &BB) const {

View File

@ -241,7 +241,7 @@ private:
/// Adjust function sizes and set proper maximum size values after the whole
/// symbol table has been processed.
void adjustFunctionBoundaries();
void adjustFunctionBoundaries(DenseMap<uint64_t, MarkerSymType> &MarkerSyms);
/// Make .eh_frame section relocatable.
void relocateEHFrameSection();

View File

@ -15,6 +15,12 @@
#include "llvm/Support/CommandLine.h"
namespace llvm {
namespace bolt {
class BinaryFunction;
}
} // namespace llvm
namespace opts {
enum HeatmapModeKind {
@ -100,6 +106,9 @@ extern llvm::cl::opt<unsigned> Verbosity;
/// Return true if we should process all functions in the binary.
bool processAllFunctions();
/// Return true if we should dump dot graphs for the given function.
bool shouldDumpDot(const llvm::bolt::BinaryFunction &Function);
enum GadgetScannerKind { GS_PACRET, GS_PAUTH, GS_ALL };
extern llvm::cl::bits<GadgetScannerKind> GadgetScannersToRun;

View File

@ -1915,13 +1915,9 @@ void BinaryFunction::postProcessEntryPoints() {
continue;
// If we have grabbed a wrong code label which actually points to some
// constant island inside the function, ignore this label and remove it
// from the secondary entry point map.
if (isStartOfConstantIsland(Offset)) {
BC.SymbolToFunctionMap.erase(Label);
removeSymbolFromSecondaryEntryPointMap(Label);
// constant island inside the function, ignore this label.
if (isStartOfConstantIsland(Offset))
continue;
}
BC.errs() << "BOLT-WARNING: reference in the middle of instruction "
"detected in function "

View File

@ -30,6 +30,11 @@ using namespace bolt;
using namespace MCPlus;
namespace opts {
cl::opt<bool>
TerminalHLT("terminal-x86-hlt",
cl::desc("Assume that execution stops at x86 HLT instruction"),
cl::init(true), cl::Hidden, cl::cat(BoltCategory));
cl::opt<bool>
TerminalTrap("terminal-trap",
cl::desc("Assume that execution stops at trap instruction"),
@ -132,10 +137,13 @@ bool MCPlusBuilder::equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
}
bool MCPlusBuilder::isTerminator(const MCInst &Inst) const {
return (opts::TerminalTrap && Info->get(Inst.getOpcode()).isTrap()) ||
Analysis->isTerminator(Inst)
? !isX86HLT(Inst)
: false;
if (isX86HLT(Inst))
return opts::TerminalHLT;
if (Info->get(Inst.getOpcode()).isTrap())
return opts::TerminalTrap;
return Analysis->isTerminator(Inst);
}
void MCPlusBuilder::setTailCall(MCInst &Inst) const {

View File

@ -52,6 +52,7 @@ namespace opts {
extern cl::opt<bool> PrintAll;
extern cl::opt<bool> PrintDynoStats;
extern cl::opt<bool> DumpDotAll;
extern bool shouldDumpDot(const bolt::BinaryFunction &Function);
extern cl::opt<std::string> AsmDump;
extern cl::opt<bolt::PLTCall::OptType> PLT;
extern cl::opt<bolt::IdenticalCodeFolding::ICFLevel, false,
@ -340,7 +341,7 @@ Error BinaryFunctionPassManager::runPasses() {
Function.print(BC.outs(), Message);
if (opts::DumpDotAll)
if (opts::shouldDumpDot(Function))
Function.dumpGraphForPass(PassIdName);
}
}

View File

@ -84,6 +84,7 @@ extern cl::opt<bool> KeepNops;
extern cl::opt<bool> Lite;
extern cl::list<std::string> ReorderData;
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
extern cl::opt<bool> TerminalHLT;
extern cl::opt<bool> TerminalTrap;
extern cl::opt<bool> TimeBuild;
extern cl::opt<bool> TimeRewrite;
@ -114,6 +115,35 @@ cl::opt<bool> DumpDotAll(
"enable '-print-loops' for color-coded blocks"),
cl::Hidden, cl::cat(BoltCategory));
cl::list<std::string> DumpDotFunc(
"dump-dot-func", cl::CommaSeparated,
cl::desc(
"dump function CFGs to graphviz format for specified functions only;"
"takes function name patterns (regex supported)"),
cl::value_desc("func1,func2,func3,..."), cl::Hidden, cl::cat(BoltCategory));
bool shouldDumpDot(const bolt::BinaryFunction &Function) {
// If dump-dot-all is enabled, dump all functions
if (DumpDotAll)
return !Function.isIgnored();
// If no specific functions specified in dump-dot-func, don't dump any
if (DumpDotFunc.empty())
return false;
if (Function.isIgnored())
return false;
// Check if function matches any of the specified patterns
for (const std::string &Name : DumpDotFunc) {
if (Function.hasNameRegex(Name)) {
return true;
}
}
return false;
}
static cl::list<std::string>
ForceFunctionNames("funcs",
cl::CommaSeparated,
@ -880,14 +910,9 @@ void RewriteInstance::discoverFileObjects() {
// code section (see IHI0056B). $d identifies data contents.
// Compilers usually merge multiple data objects in a single $d-$x interval,
// but we need every data object to be marked with $d. Because of that we
// create a vector of MarkerSyms with all locations of data objects.
// keep track of marker symbols with all locations of data objects.
struct MarkerSym {
uint64_t Address;
MarkerSymType Type;
};
std::vector<MarkerSym> SortedMarkerSymbols;
DenseMap<uint64_t, MarkerSymType> MarkerSymbols;
auto addExtraDataMarkerPerSymbol = [&]() {
bool IsData = false;
uint64_t LastAddr = 0;
@ -911,14 +936,14 @@ void RewriteInstance::discoverFileObjects() {
}
if (MarkerType != MarkerSymType::NONE) {
SortedMarkerSymbols.push_back(MarkerSym{SymInfo.Address, MarkerType});
MarkerSymbols[SymInfo.Address] = MarkerType;
LastAddr = SymInfo.Address;
IsData = MarkerType == MarkerSymType::DATA;
continue;
}
if (IsData) {
SortedMarkerSymbols.push_back({SymInfo.Address, MarkerSymType::DATA});
MarkerSymbols[SymInfo.Address] = MarkerSymType::DATA;
LastAddr = SymInfo.Address;
}
}
@ -1283,27 +1308,24 @@ void RewriteInstance::discoverFileObjects() {
BC->setHasSymbolsWithFileName(FileSymbols.size());
// Now that all the functions were created - adjust their boundaries.
adjustFunctionBoundaries();
adjustFunctionBoundaries(MarkerSymbols);
// Annotate functions with code/data markers in AArch64
for (auto ISym = SortedMarkerSymbols.begin();
ISym != SortedMarkerSymbols.end(); ++ISym) {
auto *BF =
BC->getBinaryFunctionContainingAddress(ISym->Address, true, true);
for (auto &[Address, Type] : MarkerSymbols) {
auto *BF = BC->getBinaryFunctionContainingAddress(Address, true, true);
if (!BF) {
// Stray marker
continue;
}
const auto EntryOffset = ISym->Address - BF->getAddress();
if (ISym->Type == MarkerSymType::CODE) {
const auto EntryOffset = Address - BF->getAddress();
if (Type == MarkerSymType::CODE) {
BF->markCodeAtOffset(EntryOffset);
continue;
}
if (ISym->Type == MarkerSymType::DATA) {
if (Type == MarkerSymType::DATA) {
BF->markDataAtOffset(EntryOffset);
BC->AddressToConstantIslandMap[ISym->Address] = BF;
BC->AddressToConstantIslandMap[Address] = BF;
continue;
}
llvm_unreachable("Unknown marker");
@ -1832,7 +1854,8 @@ void RewriteInstance::disassemblePLT() {
}
}
void RewriteInstance::adjustFunctionBoundaries() {
void RewriteInstance::adjustFunctionBoundaries(
DenseMap<uint64_t, MarkerSymType> &MarkerSyms) {
for (auto BFI = BC->getBinaryFunctions().begin(),
BFE = BC->getBinaryFunctions().end();
BFI != BFE; ++BFI) {
@ -1870,12 +1893,15 @@ void RewriteInstance::adjustFunctionBoundaries() {
continue;
}
// This is potentially another entry point into the function.
uint64_t EntryOffset = NextSymRefI->first - Function.getAddress();
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: adding entry point to function "
<< Function << " at offset 0x"
<< Twine::utohexstr(EntryOffset) << '\n');
Function.addEntryPointAtOffset(EntryOffset);
auto It = MarkerSyms.find(NextSymRefI->first);
if (It == MarkerSyms.end() || It->second != MarkerSymType::DATA) {
// This is potentially another entry point into the function.
uint64_t EntryOffset = NextSymRefI->first - Function.getAddress();
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: adding entry point to function "
<< Function << " at offset 0x"
<< Twine::utohexstr(EntryOffset) << '\n');
Function.addEntryPointAtOffset(EntryOffset);
}
++NextSymRefI;
}
@ -2177,7 +2203,9 @@ void RewriteInstance::adjustCommandLineOptions() {
if (!opts::KeepNops.getNumOccurrences())
opts::KeepNops = true;
// Linux kernel may resume execution after a trap instruction in some cases.
// Linux kernel may resume execution after a trap or x86 HLT instruction.
if (!opts::TerminalHLT.getNumOccurrences())
opts::TerminalHLT = false;
if (!opts::TerminalTrap.getNumOccurrences())
opts::TerminalTrap = false;
}
@ -3570,7 +3598,7 @@ void RewriteInstance::postProcessFunctions() {
if (opts::PrintAll || opts::PrintCFG)
Function.print(BC->outs(), "after building cfg");
if (opts::DumpDotAll)
if (opts::shouldDumpDot(Function))
Function.dumpGraphForPass("00_build-cfg");
if (opts::PrintLoopInfo) {

View File

@ -0,0 +1,38 @@
# This test is to ensure that we query data marker symbols to avoid
# misidentifying constant data island symbol as extra entry point.
# RUN: %clang %cflags %s -o %t.so -Wl,-q -Wl,--init=_bar -Wl,--fini=_bar
# RUN: llvm-bolt %t.so -o %t.instr.so
.text
.global _start
.type _start, %function
_start:
ret
.text
.global _foo
.type _foo, %function
_foo:
cbz x1, _foo_2
_foo_1:
add x1, x2, x0
b _foo
_foo_2:
ret
# None of these constant island symbols should be identified as extra entry
# point for function `_foo'.
.align 4
_const1: .short 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80
_const2: .short 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xa0
_const3: .short 0x04, 0x08, 0x0c, 0x20, 0x60, 0x80, 0xa0, 0xc0
.text
.global _bar
.type _bar, %function
_bar:
ret
# Dummy relocation to force relocation mode
.reloc 0, R_AARCH64_NONE

View File

@ -0,0 +1,24 @@
#include <iostream>
// Multiple functions to test selective dumping
int add(int a, int b) { return a + b; }
int multiply(int a, int b) { return a * b; }
int main_helper() {
std::cout << "Helper function" << std::endl;
return 42;
}
int main_secondary() { return add(5, 3); }
void other_function() { std::cout << "Other function" << std::endl; }
int main() {
int result = add(10, 20);
result = multiply(result, 2);
main_helper();
main_secondary();
other_function();
return result;
}

View File

@ -1,17 +0,0 @@
## Check CFG for halt instruction
# RUN: %clang %cflags %s -static -o %t.exe -nostdlib
# RUN: llvm-bolt %t.exe --print-cfg --print-only=main -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-CFG
# RUN: llvm-objdump -d %t --print-imm-hex | FileCheck %s --check-prefix=CHECK-BIN
# CHECK-CFG: BB Count : 1
# CHECK-BIN: <main>:
# CHECK-BIN-NEXT: f4 hlt
# CHECK-BIN-NEXT: c3 retq
.global main
.type main, %function
main:
hlt
retq
.size main, .-main

View File

@ -0,0 +1,24 @@
## Check that HLT instruction is handled differently depending on the flags.
## It's a terminator in the user-level code, but the execution can resume in
## ring 0.
# RUN: %clang %cflags %s -static -o %t.exe -nostdlib
# RUN: llvm-bolt %t.exe --print-cfg --print-only=main --terminal-x86-hlt=0 \
# RUN: -o %t.ring0 2>&1 | FileCheck %s --check-prefix=CHECK-RING0
# RUN: llvm-bolt %t.exe --print-cfg --print-only=main \
# RUN: -o %t.ring3 2>&1 | FileCheck %s --check-prefix=CHECK-RING3
# RUN: llvm-objdump -d %t.ring0 --print-imm-hex | FileCheck %s --check-prefix=CHECK-BIN
# CHECK-RING0: BB Count : 1
# CHECK-RING3: BB Count : 2
# CHECK-BIN: <main>:
# CHECK-BIN-NEXT: f4 hlt
# CHECK-BIN-NEXT: c3 retq
.global main
.type main, %function
main:
hlt
retq
.size main, .-main

View File

@ -0,0 +1,52 @@
# Test the --dump-dot-func option with multiple functions
# (includes tests for both mangled/unmangled names)
RUN: %clang++ %p/Inputs/multi-func.cpp -o %t.exe -Wl,-q
# Test 1: --dump-dot-func with specific function name (mangled)
RUN: llvm-bolt %t.exe -o %t.bolt1 --dump-dot-func=_Z3addii -v=1 2>&1 | FileCheck %s --check-prefix=ADD
# Test 2: --dump-dot-func with regex pattern (main.*)
RUN: llvm-bolt %t.exe -o %t.bolt2 --dump-dot-func="main.*" -v=1 2>&1 | FileCheck %s --check-prefix=MAIN-REGEX
# Test 3: --dump-dot-func with multiple specific functions (mangled names)
RUN: llvm-bolt %t.exe -o %t.bolt3 --dump-dot-func=_Z3addii,_Z8multiplyii -v=1 2>&1 | FileCheck %s --check-prefix=MULTI
# Test 4: No option specified should create no dot files
RUN: llvm-bolt %t.exe -o %t.bolt4 2>&1 | FileCheck %s --check-prefix=NONE
# Test 5: --dump-dot-func with non-existent function
RUN: llvm-bolt %t.exe -o %t.bolt5 --dump-dot-func=nonexistent -v=1 2>&1 | FileCheck %s --check-prefix=NONEXISTENT
# Test 6: Backward compatibility - --dump-dot-all should still work
RUN: llvm-bolt %t.exe -o %t.bolt6 --dump-dot-all -v=1 2>&1 | FileCheck %s --check-prefix=ALL
# Test 7: Test with unmangled function name (main function)
RUN: llvm-bolt %t.exe -o %t.bolt7 --dump-dot-func=main -v=1 2>&1 | FileCheck %s --check-prefix=MAIN-UNMANGLED
# Check that specific functions are dumped
ADD: BOLT-INFO: dumping CFG to _Z3addii-00_build-cfg.dot
ADD-NOT: BOLT-INFO: dumping CFG to main-00_build-cfg.dot
ADD-NOT: BOLT-INFO: dumping CFG to _Z8multiplyii-00_build-cfg.dot
ADD-NOT: BOLT-INFO: dumping CFG to _Z11main_helperv-00_build-cfg.dot
MAIN-REGEX-DAG: BOLT-INFO: dumping CFG to main-00_build-cfg.dot
MAIN-REGEX-NOT: BOLT-INFO: dumping CFG to _Z3addii-00_build-cfg.dot
MAIN-REGEX-NOT: BOLT-INFO: dumping CFG to _Z8multiplyii-00_build-cfg.dot
MULTI-DAG: BOLT-INFO: dumping CFG to _Z3addii-00_build-cfg.dot
MULTI-DAG: BOLT-INFO: dumping CFG to _Z8multiplyii-00_build-cfg.dot
MULTI-NOT: BOLT-INFO: dumping CFG to main-00_build-cfg.dot
MULTI-NOT: BOLT-INFO: dumping CFG to _Z11main_helperv-00_build-cfg.dot
# Should be no dumping messages when no option is specified
NONE-NOT: BOLT-INFO: dumping CFG
# Should be no dumping messages for non-existent function
NONEXISTENT-NOT: BOLT-INFO: dumping CFG
ALL: BOLT-INFO: dumping CFG to main-00_build-cfg.dot
MAIN-UNMANGLED: BOLT-INFO: dumping CFG to main-00_build-cfg.dot
MAIN-UNMANGLED-NOT: BOLT-INFO: dumping CFG to _Z3addii-00_build-cfg.dot
MAIN-UNMANGLED-NOT: BOLT-INFO: dumping CFG to _Z8multiplyii-00_build-cfg.dot

View File

@ -544,7 +544,7 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
ArrayRef<std::string> InputFiles,
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
bool ApplyAnyFix, bool EnableCheckProfile,
llvm::StringRef StoreCheckProfile) {
llvm::StringRef StoreCheckProfile, bool Quiet) {
ClangTool Tool(Compilations, InputFiles,
std::make_shared<PCHContainerOperations>(), BaseFS);
@ -581,8 +581,9 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
class ActionFactory : public FrontendActionFactory {
public:
ActionFactory(ClangTidyContext &Context,
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS)
: ConsumerFactory(Context, std::move(BaseFS)) {}
IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
bool Quiet)
: ConsumerFactory(Context, std::move(BaseFS)), Quiet(Quiet) {}
std::unique_ptr<FrontendAction> create() override {
return std::make_unique<Action>(&ConsumerFactory);
}
@ -593,6 +594,8 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
DiagnosticConsumer *DiagConsumer) override {
// Explicitly ask to define __clang_analyzer__ macro.
Invocation->getPreprocessorOpts().SetUpStaticAnalyzer = true;
if (Quiet)
Invocation->getDiagnosticOpts().ShowCarets = false;
return FrontendActionFactory::runInvocation(
Invocation, Files, PCHContainerOps, DiagConsumer);
}
@ -611,9 +614,10 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
};
ClangTidyASTConsumerFactory ConsumerFactory;
bool Quiet;
};
ActionFactory Factory(Context, std::move(BaseFS));
ActionFactory Factory(Context, std::move(BaseFS), Quiet);
Tool.run(&Factory);
return DiagConsumer.take();
}

View File

@ -94,7 +94,8 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
ArrayRef<std::string> InputFiles,
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> BaseFS,
bool ApplyAnyFix, bool EnableCheckProfile = false,
llvm::StringRef StoreCheckProfile = StringRef());
llvm::StringRef StoreCheckProfile = StringRef(),
bool Quiet = false);
/// Controls what kind of fixes clang-tidy is allowed to apply.
enum FixBehaviour {

View File

@ -89,13 +89,9 @@ def write_header(
+ check_name_camel.upper()
+ "_H"
)
f.write("//===--- ")
f.write(os.path.basename(filename))
f.write(" - clang-tidy ")
f.write("-" * max(0, 42 - len(os.path.basename(filename))))
f.write("*- C++ -*-===//")
f.write(
"""
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@ -145,13 +141,9 @@ def write_implementation(
filename = os.path.join(module_path, check_name_camel) + ".cpp"
print("Creating %s..." % filename)
with io.open(filename, "w", encoding="utf8", newline="\n") as f:
f.write("//===--- ")
f.write(os.path.basename(filename))
f.write(" - clang-tidy ")
f.write("-" * max(0, 51 - len(os.path.basename(filename))))
f.write("-===//")
f.write(
"""
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.

View File

@ -1575,6 +1575,10 @@ template <typename T, std::size_t N = SmallDataStructureSize>
using ParamToSmallSetMap =
llvm::DenseMap<const ParmVarDecl *, llvm::SmallSet<T, N>>;
template <typename T, std::size_t N = SmallDataStructureSize>
using ParamToSmallPtrSetMap =
llvm::DenseMap<const ParmVarDecl *, llvm::SmallPtrSet<T, N>>;
/// Returns whether the sets mapped to the two elements in the map have at
/// least one element in common.
template <typename MapTy, typename ElemTy>
@ -1699,7 +1703,7 @@ public:
/// Implements the heuristic that marks two parameters related if the same
/// member is accessed (referred to) inside the current function's body.
class AccessedSameMemberOf {
ParamToSmallSetMap<const Decl *> AccessedMembers;
ParamToSmallPtrSetMap<const Decl *> AccessedMembers;
public:
void setup(const FunctionDecl *FD) {

View File

@ -188,7 +188,7 @@ static bool isKnownToHaveValue(const Expr &Cond, const ASTContext &Ctx,
/// \return true iff all `CallExprs` visited have callees; false otherwise
/// indicating there is an unresolved indirect call.
static bool populateCallees(const Stmt *StmtNode,
llvm::SmallSet<const Decl *, 16> &Callees) {
llvm::SmallPtrSet<const Decl *, 16> &Callees) {
if (const auto *Call = dyn_cast<CallExpr>(StmtNode)) {
const Decl *Callee = Call->getDirectCallee();
@ -212,7 +212,7 @@ static bool populateCallees(const Stmt *StmtNode,
/// returns true iff `SCC` contains `Func` and its' function set overlaps with
/// `Callees`
static bool overlap(ArrayRef<CallGraphNode *> SCC,
const llvm::SmallSet<const Decl *, 16> &Callees,
const llvm::SmallPtrSet<const Decl *, 16> &Callees,
const Decl *Func) {
bool ContainsFunc = false, Overlap = false;
@ -264,7 +264,7 @@ static bool hasRecursionOverStaticLoopCondVariables(const Expr *Cond,
if (!hasStaticLocalVariable(Cond))
return false;
llvm::SmallSet<const Decl *, 16> CalleesInLoop;
llvm::SmallPtrSet<const Decl *, 16> CalleesInLoop;
if (!populateCallees(LoopStmt, CalleesInLoop)) {
// If there are unresolved indirect calls, we assume there could

View File

@ -15,14 +15,12 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {
namespace {
// Determine if the result of an expression is "stored" in some way.
// It is true if the value is stored into a variable or used as initialization
// or passed to a function or constructor.
// For this use case compound assignments are not counted as a "store" (the 'E'
// expression should have pointer type).
bool isExprValueStored(const Expr *E, ASTContext &C) {
static bool isExprValueStored(const Expr *E, ASTContext &C) {
E = E->IgnoreParenCasts();
// Get first non-paren, non-cast parent.
ParentMapContext &PMap = C.getParentMapContext();
@ -49,6 +47,8 @@ bool isExprValueStored(const Expr *E, ASTContext &C) {
return isa<CallExpr, CXXConstructExpr>(ParentE);
}
namespace {
AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
ast_matchers::internal::Matcher<QualType>, InnerMatcher) {
for (unsigned NH = Node.getNumHandlers(), I = 0; I < NH; ++I) {

View File

@ -14,10 +14,8 @@ using namespace clang::ast_matchers;
namespace clang::tidy::bugprone {
namespace {
bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
const StringLiteral *Lit) {
static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
const StringLiteral *Lit) {
// String literals surrounded by parentheses are assumed to be on purpose.
// i.e.: const char* Array[] = { ("a" "b" "c"), "d", [...] };
@ -58,6 +56,8 @@ bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
return false;
}
namespace {
AST_MATCHER_P(StringLiteral, isConcatenatedLiteral, unsigned,
MaxConcatenatedTokens) {
return Node.getNumConcatenated() > 1 &&

View File

@ -46,7 +46,9 @@ enum class ConversionKind {
ToLongDouble
};
ConversionKind classifyConversionFunc(const FunctionDecl *FD) {
} // namespace
static ConversionKind classifyConversionFunc(const FunctionDecl *FD) {
return llvm::StringSwitch<ConversionKind>(FD->getName())
.Cases("atoi", "atol", ConversionKind::ToInt)
.Case("atoll", ConversionKind::ToLongInt)
@ -54,8 +56,8 @@ ConversionKind classifyConversionFunc(const FunctionDecl *FD) {
.Default(ConversionKind::None);
}
ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
const TargetInfo &TI) {
static ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
const TargetInfo &TI) {
// Scan the format string for the first problematic format specifier, then
// report that as the conversion type. This will miss additional conversion
// specifiers, but that is acceptable behavior.
@ -128,7 +130,7 @@ ConversionKind classifyFormatString(StringRef Fmt, const LangOptions &LO,
return H.get();
}
StringRef classifyConversionType(ConversionKind K) {
static StringRef classifyConversionType(ConversionKind K) {
switch (K) {
case ConversionKind::None:
llvm_unreachable("Unexpected conversion kind");
@ -148,7 +150,7 @@ StringRef classifyConversionType(ConversionKind K) {
llvm_unreachable("Unknown conversion kind");
}
StringRef classifyReplacement(ConversionKind K) {
static StringRef classifyReplacement(ConversionKind K) {
switch (K) {
case ConversionKind::None:
llvm_unreachable("Unexpected conversion kind");
@ -173,7 +175,6 @@ StringRef classifyReplacement(ConversionKind K) {
}
llvm_unreachable("Unknown conversion kind");
}
} // unnamed namespace
void StrToNumCheck::check(const MatchFinder::MatchResult &Result) {
const auto *Call = Result.Nodes.getNodeAs<CallExpr>("expr");

View File

@ -32,6 +32,7 @@ add_clang_library(clangTidyMiscModule STATIC
NoRecursionCheck.cpp
NonCopyableObjects.cpp
NonPrivateMemberVariablesInClassesCheck.cpp
OverrideWithDifferentVisibilityCheck.cpp
RedundantExpressionCheck.cpp
StaticAssertCheck.cpp
ThrowByValueCatchByReferenceCheck.cpp

View File

@ -22,6 +22,7 @@
#include "NoRecursionCheck.h"
#include "NonCopyableObjects.h"
#include "NonPrivateMemberVariablesInClassesCheck.h"
#include "OverrideWithDifferentVisibilityCheck.h"
#include "RedundantExpressionCheck.h"
#include "StaticAssertCheck.h"
#include "ThrowByValueCatchByReferenceCheck.h"
@ -81,6 +82,8 @@ public:
"misc-use-anonymous-namespace");
CheckFactories.registerCheck<UseInternalLinkageCheck>(
"misc-use-internal-linkage");
CheckFactories.registerCheck<OverrideWithDifferentVisibilityCheck>(
"misc-override-with-different-visibility");
}
};

View File

@ -59,7 +59,9 @@ AST_MATCHER(FunctionDecl, isPlacementOverload) {
return true;
}
OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
} // namespace
static OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
switch (FD->getOverloadedOperator()) {
default:
break;
@ -75,7 +77,7 @@ OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
llvm_unreachable("Not an overloaded allocation operator");
}
const char *getOperatorName(OverloadedOperatorKind K) {
static const char *getOperatorName(OverloadedOperatorKind K) {
switch (K) {
default:
break;
@ -91,13 +93,14 @@ const char *getOperatorName(OverloadedOperatorKind K) {
llvm_unreachable("Not an overloaded allocation operator");
}
bool areCorrespondingOverloads(const FunctionDecl *LHS,
const FunctionDecl *RHS) {
static bool areCorrespondingOverloads(const FunctionDecl *LHS,
const FunctionDecl *RHS) {
return RHS->getOverloadedOperator() == getCorrespondingOverload(LHS);
}
bool hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
const CXXRecordDecl *RD = nullptr) {
static bool
hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
const CXXRecordDecl *RD = nullptr) {
if (RD) {
// Check the methods in the given class and accessible to derived classes.
for (const auto *BMD : RD->methods())
@ -124,8 +127,6 @@ bool hasCorrespondingOverloadInBaseClass(const CXXMethodDecl *MD,
return false;
}
} // anonymous namespace
void NewDeleteOverloadsCheck::registerMatchers(MatchFinder *Finder) {
// Match all operator new and operator delete overloads (including the array
// forms). Do not match implicit operators, placement operators, or

View File

@ -0,0 +1,150 @@
//===--- OverrideWithDifferentVisibilityCheck.cpp - clang-tidy ------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "OverrideWithDifferentVisibilityCheck.h"
#include "../utils/Matchers.h"
#include "../utils/OptionsUtils.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
using namespace clang::ast_matchers;
using namespace clang;
namespace {
AST_MATCHER(NamedDecl, isOperatorDecl) {
DeclarationName::NameKind const NK = Node.getDeclName().getNameKind();
return NK != DeclarationName::Identifier &&
NK != DeclarationName::CXXConstructorName &&
NK != DeclarationName::CXXDestructorName;
}
} // namespace
namespace clang::tidy {
template <>
struct OptionEnumMapping<
misc::OverrideWithDifferentVisibilityCheck::ChangeKind> {
static llvm::ArrayRef<std::pair<
misc::OverrideWithDifferentVisibilityCheck::ChangeKind, StringRef>>
getEnumMapping() {
static constexpr std::pair<
misc::OverrideWithDifferentVisibilityCheck::ChangeKind, StringRef>
Mapping[] = {
{misc::OverrideWithDifferentVisibilityCheck::ChangeKind::Any,
"any"},
{misc::OverrideWithDifferentVisibilityCheck::ChangeKind::Widening,
"widening"},
{misc::OverrideWithDifferentVisibilityCheck::ChangeKind::Narrowing,
"narrowing"},
};
return {Mapping};
}
};
namespace misc {
OverrideWithDifferentVisibilityCheck::OverrideWithDifferentVisibilityCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
DetectVisibilityChange(
Options.get("DisallowedVisibilityChange", ChangeKind::Any)),
CheckDestructors(Options.get("CheckDestructors", false)),
CheckOperators(Options.get("CheckOperators", false)),
IgnoredFunctions(utils::options::parseStringList(
Options.get("IgnoredFunctions", ""))) {}
void OverrideWithDifferentVisibilityCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "DisallowedVisibilityChange", DetectVisibilityChange);
Options.store(Opts, "CheckDestructors", CheckDestructors);
Options.store(Opts, "CheckOperators", CheckOperators);
Options.store(Opts, "IgnoredFunctions",
utils::options::serializeStringList(IgnoredFunctions));
}
void OverrideWithDifferentVisibilityCheck::registerMatchers(
MatchFinder *Finder) {
const auto IgnoredDecl =
namedDecl(matchers::matchesAnyListedName(IgnoredFunctions));
const auto FilterDestructors =
CheckDestructors ? decl() : decl(unless(cxxDestructorDecl()));
const auto FilterOperators =
CheckOperators ? namedDecl() : namedDecl(unless(isOperatorDecl()));
Finder->addMatcher(
cxxMethodDecl(
isVirtual(), FilterDestructors, FilterOperators,
ofClass(
cxxRecordDecl(unless(isExpansionInSystemHeader())).bind("class")),
forEachOverridden(cxxMethodDecl(ofClass(cxxRecordDecl().bind("base")),
unless(IgnoredDecl))
.bind("base_func")))
.bind("func"),
this);
}
void OverrideWithDifferentVisibilityCheck::check(
const MatchFinder::MatchResult &Result) {
const auto *const MatchedFunction =
Result.Nodes.getNodeAs<FunctionDecl>("func");
if (!MatchedFunction->isCanonicalDecl())
return;
const auto *const ParentClass =
Result.Nodes.getNodeAs<CXXRecordDecl>("class");
const auto *const BaseClass = Result.Nodes.getNodeAs<CXXRecordDecl>("base");
CXXBasePaths Paths;
if (!ParentClass->isDerivedFrom(BaseClass, Paths))
return;
const auto *const OverriddenFunction =
Result.Nodes.getNodeAs<FunctionDecl>("base_func");
AccessSpecifier const ActualAccess = MatchedFunction->getAccess();
AccessSpecifier OverriddenAccess = OverriddenFunction->getAccess();
const CXXBaseSpecifier *InheritanceWithStrictVisibility = nullptr;
for (const CXXBasePath &Path : Paths) {
for (const CXXBasePathElement &Elem : Path) {
if (Elem.Base->getAccessSpecifier() > OverriddenAccess) {
OverriddenAccess = Elem.Base->getAccessSpecifier();
InheritanceWithStrictVisibility = Elem.Base;
}
}
}
if (ActualAccess != OverriddenAccess) {
if (DetectVisibilityChange == ChangeKind::Widening &&
ActualAccess > OverriddenAccess)
return;
if (DetectVisibilityChange == ChangeKind::Narrowing &&
ActualAccess < OverriddenAccess)
return;
if (InheritanceWithStrictVisibility) {
diag(MatchedFunction->getLocation(),
"visibility of function %0 is changed from %1 (through %1 "
"inheritance of class %2) to %3")
<< MatchedFunction << OverriddenAccess
<< InheritanceWithStrictVisibility->getType() << ActualAccess;
diag(InheritanceWithStrictVisibility->getBeginLoc(),
"%0 is inherited as %1 here", DiagnosticIDs::Note)
<< InheritanceWithStrictVisibility->getType() << OverriddenAccess;
} else {
diag(MatchedFunction->getLocation(),
"visibility of function %0 is changed from %1 in class %2 to %3")
<< MatchedFunction << OverriddenAccess << BaseClass << ActualAccess;
}
diag(OverriddenFunction->getLocation(), "function declared here as %0",
DiagnosticIDs::Note)
<< OverriddenFunction->getAccess();
}
}
} // namespace misc
} // namespace clang::tidy

View File

@ -0,0 +1,43 @@
//===--- OverrideWithDifferentVisibilityCheck.h - clang-tidy --*- C++ -*---===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OVERRIDEWITHDIFFERENTVISIBILITYCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OVERRIDEWITHDIFFERENTVISIBILITYCHECK_H
#include "../ClangTidyCheck.h"
namespace clang::tidy::misc {
/// Finds virtual function overrides with different visibility than the function
/// in the base class.
///
/// For the user-facing documentation see:
/// http://clang.llvm.org/extra/clang-tidy/checks/misc/override-with-different-visibility.html
class OverrideWithDifferentVisibilityCheck : public ClangTidyCheck {
public:
enum class ChangeKind { Any, Widening, Narrowing };
OverrideWithDifferentVisibilityCheck(StringRef Name,
ClangTidyContext *Context);
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
}
private:
ChangeKind DetectVisibilityChange;
bool CheckDestructors;
bool CheckOperators;
std::vector<llvm::StringRef> IgnoredFunctions;
};
} // namespace clang::tidy::misc
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_OVERRIDEWITHDIFFERENTVISIBILITYCHECK_H

View File

@ -29,11 +29,13 @@ void UnconventionalAssignOperatorCheck::registerMatchers(
const auto HasGoodReturnType =
cxxMethodDecl(returns(hasCanonicalType(lValueReferenceType(pointee(
unless(isConstQualified()),
anyOf(autoType(), hasDeclaration(equalsBoundNode("class"))))))));
anyOf(autoType(),
hasDeclaration(declaresSameEntityAsBoundNode("class"))))))));
const auto IsSelf = qualType(hasCanonicalType(
anyOf(hasDeclaration(equalsBoundNode("class")),
referenceType(pointee(hasDeclaration(equalsBoundNode("class")))))));
anyOf(hasDeclaration(declaresSameEntityAsBoundNode("class")),
referenceType(pointee(
hasDeclaration(declaresSameEntityAsBoundNode("class")))))));
const auto IsAssign =
cxxMethodDecl(unless(anyOf(isDeleted(), isPrivate(), isImplicit())),
hasName("operator="), ofClass(recordDecl().bind("class")))

View File

@ -395,16 +395,12 @@ void MacroToEnumCallbacks::Endif(SourceLocation Loc, SourceLocation IfLoc) {
--CurrentFile->ConditionScopes;
}
namespace {
template <size_t N>
bool textEquals(const char (&Needle)[N], const char *HayStack) {
static bool textEquals(const char (&Needle)[N], const char *HayStack) {
return StringRef{HayStack, N - 1} == Needle;
}
template <size_t N> size_t len(const char (&)[N]) { return N - 1; }
} // namespace
template <size_t N> static size_t len(const char (&)[N]) { return N - 1; }
void MacroToEnumCallbacks::PragmaDirective(SourceLocation Loc,
PragmaIntroducerKind Introducer) {

View File

@ -16,14 +16,13 @@ using namespace clang::ast_matchers;
namespace clang::tidy::modernize {
namespace {
static constexpr char ConstructorCall[] = "constructorCall";
static constexpr char ResetCall[] = "resetCall";
static constexpr char NewExpression[] = "newExpression";
constexpr char ConstructorCall[] = "constructorCall";
constexpr char ResetCall[] = "resetCall";
constexpr char NewExpression[] = "newExpression";
std::string getNewExprName(const CXXNewExpr *NewExpr, const SourceManager &SM,
const LangOptions &Lang) {
static std::string getNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
const LangOptions &Lang) {
StringRef WrittenName = Lexer::getSourceText(
CharSourceRange::getTokenRange(
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
@ -34,8 +33,6 @@ std::string getNewExprName(const CXXNewExpr *NewExpr, const SourceManager &SM,
return WrittenName.str();
}
} // namespace
const char MakeSmartPtrCheck::PointerType[] = "pointerType";
MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name, ClangTidyContext *Context,

View File

@ -19,9 +19,7 @@ using namespace clang::ast_matchers;
namespace clang::tidy::modernize {
namespace {
bool containsEscapes(StringRef HayStack, StringRef Escapes) {
static bool containsEscapes(StringRef HayStack, StringRef Escapes) {
size_t BackSlash = HayStack.find('\\');
if (BackSlash == StringRef::npos)
return false;
@ -35,16 +33,16 @@ bool containsEscapes(StringRef HayStack, StringRef Escapes) {
return true;
}
bool isRawStringLiteral(StringRef Text) {
static bool isRawStringLiteral(StringRef Text) {
// Already a raw string literal if R comes before ".
const size_t QuotePos = Text.find('"');
assert(QuotePos != StringRef::npos);
return (QuotePos > 0) && (Text[QuotePos - 1] == 'R');
}
bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
const StringLiteral *Literal,
const CharsBitSet &DisallowedChars) {
static bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
const StringLiteral *Literal,
const CharsBitSet &DisallowedChars) {
// FIXME: Handle L"", u8"", u"" and U"" literals.
if (!Literal->isOrdinary())
return false;
@ -64,14 +62,12 @@ bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
return containsEscapes(Text, R"('\"?x01)");
}
bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {
static bool containsDelimiter(StringRef Bytes, const std::string &Delimiter) {
return Bytes.find(Delimiter.empty()
? std::string(R"lit()")lit")
: (")" + Delimiter + R"(")")) != StringRef::npos;
}
} // namespace
RawStringLiteralCheck::RawStringLiteralCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),

View File

@ -29,12 +29,13 @@
using namespace clang::ast_matchers;
namespace clang::tidy::objc {
namespace {
static constexpr StringRef WeakText = "__weak";
static constexpr StringRef StrongText = "__strong";
static constexpr StringRef UnsafeUnretainedText = "__unsafe_unretained";
namespace {
/// Matches ObjCIvarRefExpr, DeclRefExpr, or MemberExpr that reference
/// Objective-C object (or block) variables or fields whose object lifetimes
/// are not __unsafe_unretained.
@ -49,6 +50,8 @@ AST_POLYMORPHIC_MATCHER(isObjCManagedLifetime,
QT.getQualifiers().getObjCLifetime() > Qualifiers::OCL_ExplicitNone;
}
} // namespace
static std::optional<FixItHint>
fixItHintReplacementForOwnershipString(StringRef Text, CharSourceRange Range,
StringRef Ownership) {
@ -93,8 +96,6 @@ fixItHintForVarDecl(const VarDecl *VD, const SourceManager &SM,
return FixItHint::CreateInsertion(Range.getBegin(), "__unsafe_unretained ");
}
} // namespace
void NSInvocationArgumentLifetimeCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
traverse(

View File

@ -27,11 +27,14 @@ enum NamingStyle {
CategoryProperty = 2,
};
} // namespace
/// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to
/// 'camelCase' or 'abc_camelCase'. For other cases the users need to
/// come up with a proper name by their own.
/// FIXME: provide fix for snake_case to snakeCase
FixItHint generateFixItHint(const ObjCPropertyDecl *Decl, NamingStyle Style) {
static FixItHint generateFixItHint(const ObjCPropertyDecl *Decl,
NamingStyle Style) {
auto Name = Decl->getName();
auto NewName = Decl->getName().str();
size_t Index = 0;
@ -50,7 +53,7 @@ FixItHint generateFixItHint(const ObjCPropertyDecl *Decl, NamingStyle Style) {
return {};
}
std::string validPropertyNameRegex(bool UsedInMatcher) {
static std::string validPropertyNameRegex(bool UsedInMatcher) {
// Allow any of these names:
// foo
// fooBar
@ -72,13 +75,13 @@ std::string validPropertyNameRegex(bool UsedInMatcher) {
return StartMatcher + "([a-z]|[A-Z][A-Z0-9])[a-z0-9A-Z]*$";
}
bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
static bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
auto RegexExp =
llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
return RegexExp.match(PropertyName);
}
bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
static bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
size_t Start = PropertyName.find_first_of('_');
assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
auto Prefix = PropertyName.substr(0, Start);
@ -88,7 +91,6 @@ bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
return RegexExp.match(PropertyName.substr(Start + 1));
}
} // namespace
void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(objcPropertyDecl(

View File

@ -17,7 +17,6 @@
#include <optional>
namespace clang::tidy::performance {
namespace {
using namespace ::clang::ast_matchers;
using llvm::StringRef;
@ -30,8 +29,8 @@ static constexpr StringRef MethodDeclId = "methodDecl";
static constexpr StringRef FunctionDeclId = "functionDecl";
static constexpr StringRef OldVarDeclId = "oldVarDecl";
void recordFixes(const VarDecl &Var, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
static void recordFixes(const VarDecl &Var, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
Diagnostic << utils::fixit::changeVarDeclToReference(Var, Context);
if (!Var.getType().isLocalConstQualified()) {
if (std::optional<FixItHint> Fix = utils::fixit::addQualifierToVarDecl(
@ -40,8 +39,8 @@ void recordFixes(const VarDecl &Var, ASTContext &Context,
}
}
std::optional<SourceLocation> firstLocAfterNewLine(SourceLocation Loc,
SourceManager &SM) {
static std::optional<SourceLocation> firstLocAfterNewLine(SourceLocation Loc,
SourceManager &SM) {
bool Invalid = false;
const char *TextAfter = SM.getCharacterData(Loc, &Invalid);
if (Invalid) {
@ -51,8 +50,8 @@ std::optional<SourceLocation> firstLocAfterNewLine(SourceLocation Loc,
return Loc.getLocWithOffset(TextAfter[Offset] == '\0' ? Offset : Offset + 1);
}
void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
static void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
DiagnosticBuilder &Diagnostic) {
auto &SM = Context.getSourceManager();
// Attempt to remove trailing comments as well.
auto Tok = utils::lexer::findNextTokenSkippingComments(Stmt.getEndLoc(), SM,
@ -74,6 +73,8 @@ void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
}
}
namespace {
AST_MATCHER_FUNCTION_P(StatementMatcher,
isRefReturningMethodCallWithConstOverloads,
std::vector<StringRef>, ExcludedContainerTypes) {
@ -130,6 +131,8 @@ AST_MATCHER_FUNCTION_P(StatementMatcher, initializerReturnsReferenceToConst,
hasUnaryOperand(OldVarDeclRef)))));
}
} // namespace
// This checks that the variable itself is only used as const, and also makes
// sure that it does not reference another variable that could be modified in
// the BlockStmt. It does this by checking the following:
@ -180,13 +183,13 @@ static bool isInitializingVariableImmutable(
return false;
}
bool isVariableUnused(const VarDecl &Var, const Stmt &BlockStmt,
ASTContext &Context) {
static bool isVariableUnused(const VarDecl &Var, const Stmt &BlockStmt,
ASTContext &Context) {
return allDeclRefExprs(Var, BlockStmt, Context).empty();
}
const SubstTemplateTypeParmType *getSubstitutedType(const QualType &Type,
ASTContext &Context) {
static const SubstTemplateTypeParmType *
getSubstitutedType(const QualType &Type, ASTContext &Context) {
auto Matches = match(
qualType(anyOf(substTemplateTypeParmType().bind("subst"),
hasDescendant(substTemplateTypeParmType().bind("subst")))),
@ -194,9 +197,9 @@ const SubstTemplateTypeParmType *getSubstitutedType(const QualType &Type,
return selectFirst<SubstTemplateTypeParmType>("subst", Matches);
}
bool differentReplacedTemplateParams(const QualType &VarType,
const QualType &InitializerType,
ASTContext &Context) {
static bool differentReplacedTemplateParams(const QualType &VarType,
const QualType &InitializerType,
ASTContext &Context) {
if (const SubstTemplateTypeParmType *VarTmplType =
getSubstitutedType(VarType, Context)) {
if (const SubstTemplateTypeParmType *InitializerTmplType =
@ -212,8 +215,8 @@ bool differentReplacedTemplateParams(const QualType &VarType,
return false;
}
QualType constructorArgumentType(const VarDecl *OldVar,
const BoundNodes &Nodes) {
static QualType constructorArgumentType(const VarDecl *OldVar,
const BoundNodes &Nodes) {
if (OldVar) {
return OldVar->getType();
}
@ -224,8 +227,6 @@ QualType constructorArgumentType(const VarDecl *OldVar,
return MethodDecl->getReturnType();
}
} // namespace
UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),

View File

@ -21,16 +21,14 @@ using namespace clang::ast_matchers;
namespace clang::tidy::performance {
namespace {
std::string paramNameOrIndex(StringRef Name, size_t Index) {
static std::string paramNameOrIndex(StringRef Name, size_t Index) {
return (Name.empty() ? llvm::Twine('#') + llvm::Twine(Index + 1)
: llvm::Twine('\'') + Name + llvm::Twine('\''))
.str();
}
bool hasLoopStmtAncestor(const DeclRefExpr &DeclRef, const Decl &Decl,
ASTContext &Context) {
static bool hasLoopStmtAncestor(const DeclRefExpr &DeclRef, const Decl &Decl,
ASTContext &Context) {
auto Matches = match(
traverse(TK_AsIs,
decl(forEachDescendant(declRefExpr(
@ -41,8 +39,6 @@ bool hasLoopStmtAncestor(const DeclRefExpr &DeclRef, const Decl &Decl,
return Matches.empty();
}
} // namespace
UnnecessaryValueParamCheck::UnnecessaryValueParamCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),

View File

@ -122,15 +122,15 @@ AST_MATCHER(EnumDecl, hasSequentialInitialValues) {
return !AllEnumeratorsArePowersOfTwo;
}
std::string getName(const EnumDecl *Decl) {
} // namespace
static std::string getName(const EnumDecl *Decl) {
if (!Decl->getDeclName())
return "<unnamed>";
return Decl->getQualifiedNameAsString();
}
} // namespace
EnumInitialValueCheck::EnumInitialValueCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),

View File

@ -144,6 +144,8 @@ struct CognitiveComplexity final {
void account(SourceLocation Loc, unsigned short Nesting, Criteria C);
};
} // namespace
// All the possible messages that can be output. The choice of the message
// to use is based of the combination of the CognitiveComplexity::Criteria.
// It would be nice to have it in CognitiveComplexity struct, but then it is
@ -163,23 +165,27 @@ static const std::array<const StringRef, 4> Msgs = {{
}};
// Criteria is a bitset, thus a few helpers are needed.
CognitiveComplexity::Criteria operator|(CognitiveComplexity::Criteria LHS,
CognitiveComplexity::Criteria RHS) {
static CognitiveComplexity::Criteria
operator|(CognitiveComplexity::Criteria LHS,
CognitiveComplexity::Criteria RHS) {
return static_cast<CognitiveComplexity::Criteria>(llvm::to_underlying(LHS) |
llvm::to_underlying(RHS));
}
CognitiveComplexity::Criteria operator&(CognitiveComplexity::Criteria LHS,
CognitiveComplexity::Criteria RHS) {
static CognitiveComplexity::Criteria
operator&(CognitiveComplexity::Criteria LHS,
CognitiveComplexity::Criteria RHS) {
return static_cast<CognitiveComplexity::Criteria>(llvm::to_underlying(LHS) &
llvm::to_underlying(RHS));
}
CognitiveComplexity::Criteria &operator|=(CognitiveComplexity::Criteria &LHS,
CognitiveComplexity::Criteria RHS) {
static CognitiveComplexity::Criteria &
operator|=(CognitiveComplexity::Criteria &LHS,
CognitiveComplexity::Criteria RHS) {
LHS = operator|(LHS, RHS);
return LHS;
}
CognitiveComplexity::Criteria &operator&=(CognitiveComplexity::Criteria &LHS,
CognitiveComplexity::Criteria RHS) {
static CognitiveComplexity::Criteria &
operator&=(CognitiveComplexity::Criteria &LHS,
CognitiveComplexity::Criteria RHS) {
LHS = operator&(LHS, RHS);
return LHS;
}
@ -199,6 +205,8 @@ void CognitiveComplexity::account(SourceLocation Loc, unsigned short Nesting,
Total += Increase;
}
namespace {
class FunctionASTVisitor final
: public RecursiveASTVisitor<FunctionASTVisitor> {
using Base = RecursiveASTVisitor<FunctionASTVisitor>;

View File

@ -41,9 +41,11 @@ AST_MATCHER(Stmt, isNULLMacroExpansion) {
return isNULLMacroExpansion(&Node, Finder->getASTContext());
}
StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
QualType Type,
ASTContext &Context) {
} // namespace
static StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
QualType Type,
ASTContext &Context) {
switch (CastExprKind) {
case CK_IntegralToBoolean:
return Type->isUnsignedIntegerType() ? "0u" : "0";
@ -62,15 +64,15 @@ StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
}
}
bool isUnaryLogicalNotOperator(const Stmt *Statement) {
static bool isUnaryLogicalNotOperator(const Stmt *Statement) {
const auto *UnaryOperatorExpr = dyn_cast<UnaryOperator>(Statement);
return UnaryOperatorExpr && UnaryOperatorExpr->getOpcode() == UO_LNot;
}
void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
const ImplicitCastExpr *Cast, const Stmt *Parent,
ASTContext &Context,
bool UseUpperCaseLiteralSuffix) {
static void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
const ImplicitCastExpr *Cast,
const Stmt *Parent, ASTContext &Context,
bool UseUpperCaseLiteralSuffix) {
// In case of expressions like (! integer), we should remove the redundant not
// operator and use inverted comparison (integer == 0).
bool InvertComparison =
@ -133,8 +135,8 @@ void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
Diag << FixItHint::CreateInsertion(EndLoc, EndLocInsertion);
}
StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
ASTContext &Context) {
static StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
ASTContext &Context) {
if (isNULLMacroExpansion(Expression, Context)) {
return "false";
}
@ -161,7 +163,7 @@ StringRef getEquivalentBoolLiteralForExpr(const Expr *Expression,
return {};
}
bool needsSpacePrefix(SourceLocation Loc, ASTContext &Context) {
static bool needsSpacePrefix(SourceLocation Loc, ASTContext &Context) {
SourceRange PrefixRange(Loc.getLocWithOffset(-1), Loc);
StringRef SpaceBeforeStmtStr = Lexer::getSourceText(
CharSourceRange::getCharRange(PrefixRange), Context.getSourceManager(),
@ -173,9 +175,10 @@ bool needsSpacePrefix(SourceLocation Loc, ASTContext &Context) {
return !AllowedCharacters.contains(SpaceBeforeStmtStr.back());
}
void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,
const ImplicitCastExpr *Cast,
ASTContext &Context, StringRef OtherType) {
static void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,
const ImplicitCastExpr *Cast,
ASTContext &Context,
StringRef OtherType) {
if (!Context.getLangOpts().CPlusPlus) {
Diag << FixItHint::CreateInsertion(Cast->getBeginLoc(),
(Twine("(") + OtherType + ")").str());
@ -200,8 +203,9 @@ void fixGenericExprCastFromBool(DiagnosticBuilder &Diag,
}
}
StringRef getEquivalentForBoolLiteral(const CXXBoolLiteralExpr *BoolLiteral,
QualType DestType, ASTContext &Context) {
static StringRef
getEquivalentForBoolLiteral(const CXXBoolLiteralExpr *BoolLiteral,
QualType DestType, ASTContext &Context) {
// Prior to C++11, false literal could be implicitly converted to pointer.
if (!Context.getLangOpts().CPlusPlus11 &&
(DestType->isPointerType() || DestType->isMemberPointerType()) &&
@ -222,8 +226,8 @@ StringRef getEquivalentForBoolLiteral(const CXXBoolLiteralExpr *BoolLiteral,
return BoolLiteral->getValue() ? "1" : "0";
}
bool isCastAllowedInCondition(const ImplicitCastExpr *Cast,
ASTContext &Context) {
static bool isCastAllowedInCondition(const ImplicitCastExpr *Cast,
ASTContext &Context) {
std::queue<const Stmt *> Q;
Q.push(Cast);
@ -251,8 +255,6 @@ bool isCastAllowedInCondition(const ImplicitCastExpr *Cast,
return false;
}
} // anonymous namespace
ImplicitBoolConversionCheck::ImplicitBoolConversionCheck(
StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),

View File

@ -28,8 +28,11 @@ AST_MATCHER_P(QualType, hasUnqualifiedType,
enum class Qualifier { Const, Volatile, Restrict };
std::optional<Token> findQualToken(const VarDecl *Decl, Qualifier Qual,
const MatchFinder::MatchResult &Result) {
} // namespace
static std::optional<Token>
findQualToken(const VarDecl *Decl, Qualifier Qual,
const MatchFinder::MatchResult &Result) {
// Since either of the locs can be in a macro, use `makeFileCharRange` to be
// sure that we have a consistent `CharSourceRange`, located entirely in the
// source file.
@ -58,7 +61,7 @@ std::optional<Token> findQualToken(const VarDecl *Decl, Qualifier Qual,
*Result.SourceManager);
}
std::optional<SourceRange>
static std::optional<SourceRange>
getTypeSpecifierLocation(const VarDecl *Var,
const MatchFinder::MatchResult &Result) {
SourceRange TypeSpecifier(
@ -73,8 +76,8 @@ getTypeSpecifierLocation(const VarDecl *Var,
return TypeSpecifier;
}
std::optional<SourceRange> mergeReplacementRange(SourceRange &TypeSpecifier,
const Token &ConstToken) {
static std::optional<SourceRange>
mergeReplacementRange(SourceRange &TypeSpecifier, const Token &ConstToken) {
if (TypeSpecifier.getBegin().getLocWithOffset(-1) == ConstToken.getEndLoc()) {
TypeSpecifier.setBegin(ConstToken.getLocation());
return std::nullopt;
@ -86,21 +89,19 @@ std::optional<SourceRange> mergeReplacementRange(SourceRange &TypeSpecifier,
return SourceRange(ConstToken.getLocation(), ConstToken.getEndLoc());
}
bool isPointerConst(QualType QType) {
static bool isPointerConst(QualType QType) {
QualType Pointee = QType->getPointeeType();
assert(!Pointee.isNull() && "can't have a null Pointee");
return Pointee.isConstQualified();
}
bool isAutoPointerConst(QualType QType) {
static bool isAutoPointerConst(QualType QType) {
QualType Pointee =
cast<AutoType>(QType->getPointeeType().getTypePtr())->desugar();
assert(!Pointee.isNull() && "can't have a null Pointee");
return Pointee.isConstQualified();
}
} // namespace
QualifiedAutoCheck::QualifiedAutoCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),

View File

@ -14,19 +14,18 @@ using namespace clang::ast_matchers;
namespace clang::tidy::readability {
namespace {
static const char *const RedundantReturnDiag =
"redundant return statement at the end "
"of a function with a void return type";
static const char *const RedundantContinueDiag =
"redundant continue statement at the "
"end of loop statement";
const char *const RedundantReturnDiag = "redundant return statement at the end "
"of a function with a void return type";
const char *const RedundantContinueDiag = "redundant continue statement at the "
"end of loop statement";
bool isLocationInMacroExpansion(const SourceManager &SM, SourceLocation Loc) {
static bool isLocationInMacroExpansion(const SourceManager &SM,
SourceLocation Loc) {
return SM.isMacroBodyExpansion(Loc) || SM.isMacroArgExpansion(Loc);
}
} // namespace
void RedundantControlFlowCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
functionDecl(isDefinition(), returns(voidType()),

View File

@ -717,7 +717,7 @@ int clangTidyMain(int argc, const char **argv) {
EnableModuleHeadersParsing);
std::vector<ClangTidyError> Errors =
runClangTidy(Context, OptionsParser->getCompilations(), PathList, BaseFS,
FixNotes, EnableCheckProfile, ProfilePrefix);
FixNotes, EnableCheckProfile, ProfilePrefix, Quiet);
bool FoundErrors = llvm::any_of(Errors, [](const ClangTidyError &E) {
return E.DiagLevel == ClangTidyError::Error;
});

View File

@ -13,16 +13,14 @@
namespace clang::tidy::utils::type_traits {
namespace {
bool classHasTrivialCopyAndDestroy(QualType Type) {
static bool classHasTrivialCopyAndDestroy(QualType Type) {
auto *Record = Type->getAsCXXRecordDecl();
return Record && Record->hasDefinition() &&
!Record->hasNonTrivialCopyConstructor() &&
!Record->hasNonTrivialDestructor();
}
bool hasDeletedCopyConstructor(QualType Type) {
static bool hasDeletedCopyConstructor(QualType Type) {
auto *Record = Type->getAsCXXRecordDecl();
if (!Record || !Record->hasDefinition())
return false;
@ -33,8 +31,6 @@ bool hasDeletedCopyConstructor(QualType Type) {
return false;
}
} // namespace
std::optional<bool> isExpensiveToCopy(QualType Type,
const ASTContext &Context) {
if (Type->isDependentType() || Type->isIncompleteType())

View File

@ -985,7 +985,7 @@ resolveForwardingParameters(const FunctionDecl *D, unsigned MaxDepth) {
// Recurse on pack parameters
size_t Depth = 0;
const FunctionDecl *CurrentFunction = D;
llvm::SmallSet<const FunctionTemplateDecl *, 4> SeenTemplates;
llvm::SmallPtrSet<const FunctionTemplateDecl *, 4> SeenTemplates;
if (const auto *Template = D->getPrimaryTemplate()) {
SeenTemplates.insert(Template);
}

View File

@ -6,7 +6,7 @@ add_subdirectory(support)
# Configure the Features.inc file.
if (NOT DEFINED CLANGD_BUILD_XPC)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set(CLANGD_BUILD_XPC_DEFAULT ON)
else ()
set(CLANGD_BUILD_XPC_DEFAULT OFF)
@ -193,7 +193,7 @@ if(CLANGD_TIDY_CHECKS)
endif()
add_subdirectory(refactor/tweaks)
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
# FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
add_subdirectory(fuzzer)
endif()

View File

@ -833,6 +833,10 @@ bool OverlayCDB::setCompileCommand(PathRef File,
std::unique_ptr<ProjectModules>
OverlayCDB::getProjectModules(PathRef File) const {
auto MDB = DelegatingCDB::getProjectModules(File);
if (!MDB) {
log("Failed to get compilation Database for {0}", File);
return {};
}
MDB->setCommandMangler([&Mangler = Mangler](tooling::CompileCommand &Command,
PathRef CommandPath) {
Mangler(Command, CommandPath);

View File

@ -1876,7 +1876,7 @@ static void fillSubTypes(const SymbolID &ID,
});
}
using RecursionProtectionSet = llvm::SmallSet<const CXXRecordDecl *, 4>;
using RecursionProtectionSet = llvm::SmallPtrSet<const CXXRecordDecl *, 4>;
// Extracts parents from AST and populates the type hierarchy item.
static void fillSuperTypes(const CXXRecordDecl &CXXRD, llvm::StringRef TUPath,

View File

@ -181,7 +181,7 @@ struct ExtractionZone {
bool requiresHoisting(const SourceManager &SM,
const HeuristicResolver *Resolver) const {
// First find all the declarations that happened inside extraction zone.
llvm::SmallSet<const Decl *, 1> DeclsInExtZone;
llvm::SmallPtrSet<const Decl *, 1> DeclsInExtZone;
for (auto *RootStmt : RootStmts) {
findExplicitReferences(
RootStmt,

View File

@ -0,0 +1,66 @@
# A smoke test to check that clangd works without compilation database
#
# Windows have different escaping modes.
# FIXME: We should add one for windows.
# UNSUPPORTED: system-windows
#
# RUN: rm -fr %t
# RUN: mkdir -p %t
# RUN: split-file %s %t
#
# RUN: sed -e "s|DIR|%/t|g" %t/definition.jsonrpc.tmpl > %t/definition.jsonrpc
#
# RUN: clangd -experimental-modules-support -lit-test < %t/definition.jsonrpc \
# RUN: | FileCheck -strict-whitespace %t/definition.jsonrpc
#--- A.h
void printA();
#--- Use.cpp
#include "A.h"
void foo() {
print
}
#--- definition.jsonrpc.tmpl
{
"jsonrpc": "2.0",
"id": 0,
"method": "initialize",
"params": {
"processId": 123,
"rootPath": "clangd",
"capabilities": {
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true
}
}
}
},
"trace": "off"
}
}
---
{
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file://DIR/Use.cpp",
"languageId": "cpp",
"version": 1,
"text": "#include \"A.h\"\nvoid foo() {\n print\n}\n"
}
}
}
# CHECK: "message"{{.*}}printA{{.*}}(fix available)
---
{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file://DIR/Use.cpp"},"context":{"triggerKind":1},"position":{"line":2,"character":6}}}
---
{"jsonrpc":"2.0","id":2,"method":"shutdown"}
---
{"jsonrpc":"2.0","method":"exit"}

View File

@ -4473,6 +4473,198 @@ TEST(CompletionTest, SkipExplicitObjectParameter) {
snippetSuffix(""))));
}
}
TEST(CompletionTest, MemberAccessInExplicitObjMemfn) {
Annotations Code(R"cpp(
struct A {
int member {};
int memberFnA(int a);
int memberFnA(this A&, float a);
void foo(this A& self) {
// Should not offer any members here, since
// it needs to be referenced through `self`.
mem$c1^;
// should offer all results
self.mem$c2^;
[&]() {
// should not offer any results
mem$c3^;
}();
}
};
)cpp");
auto TU = TestTU::withCode(Code.code());
TU.ExtraArgs = {"-std=c++23"};
auto Preamble = TU.preamble();
ASSERT_TRUE(Preamble);
CodeCompleteOptions Opts{};
MockFS FS;
auto Inputs = TU.inputs(FS);
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c1"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(Result.Completions, ElementsAre());
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c2"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(named("member"),
AllOf(named("memberFnA"), signature("(int a)"),
snippetSuffix("(${1:int a})")),
AllOf(named("memberFnA"), signature("(float a)"),
snippetSuffix("(${1:float a})"))));
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c3"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(Result.Completions, ElementsAre());
}
}
TEST(CompletionTest, ListExplicitObjectOverloads) {
Annotations Code(R"cpp(
struct S {
void foo1(int a);
void foo2(int a) const;
void foo2(this const S& self, float a);
void foo3(this const S& self, int a);
void foo4(this S& self, int a);
};
void S::foo1(int a) {
this->$c1^;
}
void S::foo2(int a) const {
this->$c2^;
}
void S::foo3(this const S& self, int a) {
self.$c3^;
}
void S::foo4(this S& self, int a) {
self.$c4^;
}
void test1(S s) {
s.$c5^;
}
void test2(const S s) {
s.$c6^;
}
)cpp");
auto TU = TestTU::withCode(Code.code());
TU.ExtraArgs = {"-std=c++23"};
auto Preamble = TU.preamble();
ASSERT_TRUE(Preamble);
CodeCompleteOptions Opts{};
MockFS FS;
auto Inputs = TU.inputs(FS);
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c1"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(AllOf(named("foo1"), signature("(int a)"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(float a) const"),
snippetSuffix("(${1:float a})")),
AllOf(named("foo3"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo4"), signature("(int a)"),
snippetSuffix("(${1:int a})"))));
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c2"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(float a) const"),
snippetSuffix("(${1:float a})")),
AllOf(named("foo3"), signature("(int a) const"),
snippetSuffix("(${1:int a})"))));
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c3"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(float a) const"),
snippetSuffix("(${1:float a})")),
AllOf(named("foo3"), signature("(int a) const"),
snippetSuffix("(${1:int a})"))));
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c4"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(AllOf(named("foo1"), signature("(int a)"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(float a) const"),
snippetSuffix("(${1:float a})")),
AllOf(named("foo3"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo4"), signature("(int a)"),
snippetSuffix("(${1:int a})"))));
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c5"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(AllOf(named("foo1"), signature("(int a)"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(float a) const"),
snippetSuffix("(${1:float a})")),
AllOf(named("foo3"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo4"), signature("(int a)"),
snippetSuffix("(${1:int a})"))));
}
{
auto Result = codeComplete(testPath(TU.Filename), Code.point("c6"),
Preamble.get(), Inputs, Opts);
EXPECT_THAT(
Result.Completions,
UnorderedElementsAre(AllOf(named("foo2"), signature("(int a) const"),
snippetSuffix("(${1:int a})")),
AllOf(named("foo2"), signature("(float a) const"),
snippetSuffix("(${1:float a})")),
AllOf(named("foo3"), signature("(int a) const"),
snippetSuffix("(${1:int a})"))));
}
}
} // namespace
} // namespace clangd
} // namespace clang

View File

@ -731,6 +731,12 @@ TEST_F(TargetDeclTest, BuiltinTemplates) {
using type_pack_element = [[__type_pack_element]]<N, Pack...>;
)cpp";
EXPECT_DECLS("TemplateSpecializationTypeLoc", );
Code = R"cpp(
template <template <class...> class Templ, class... Types>
using dedup_types = Templ<[[__builtin_dedup_pack]]<Types...>...>;
)cpp";
EXPECT_DECLS("TemplateSpecializationTypeLoc", );
}
TEST_F(TargetDeclTest, MemberOfTemplate) {

View File

@ -119,6 +119,9 @@ Improvements to clang-tidy
- Improved documentation of the `-line-filter` command-line flag of
:program:`clang-tidy` and :program:`run-clang-tidy.py`.
- Improved :program:`clang-tidy` option `-quiet` by suppressing diagnostic
count messages.
New checks
^^^^^^^^^^
@ -134,6 +137,12 @@ New checks
Checks for uses of MLIR's old/to be deprecated ``OpBuilder::create<T>`` form
and suggests using ``T::create`` instead.
- New :doc:`misc-override-with-different-visibility
<clang-tidy/checks/misc/override-with-different-visibility>` check.
Finds virtual function overrides with different visibility than the function
in the base class.
New check aliases
^^^^^^^^^^^^^^^^^
@ -206,7 +215,8 @@ Changes in existing checks
- Improved :doc:`readability-identifier-naming
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
declarations in system headers.
declarations in system headers. The documentation is also improved to
differentiate the general options from the specific ones.
- Improved :doc:`readability-qualified-auto
<clang-tidy/checks/readability/qualified-auto>` check by adding the option

View File

@ -0,0 +1,314 @@
======================
Clang-Change-Namespace
======================
.. contents::
.. toctree::
:maxdepth: 1
:program:`clang-change-namespace` can be used to change the surrounding
namespaces of class/function definitions.
Classes/functions in the moved namespace will have new namespaces while
references to symbols (e.g. types, functions) which are not defined in the
changed namespace will be correctly qualified by prepending namespace specifiers
before them. This will try to add shortest namespace specifiers possible.
When a symbol reference needs to be fully-qualified, this adds a `::` prefix to
the namespace specifiers unless the new namespace is the global namespace. For
classes, only classes that are declared/defined in the given namespace in
specified files will be moved: forward declarations will remain in the old
namespace. The will be demonstrated in the next example.
Example usage
-------------
For example, consider this `test.cc` example here with the forward declared
class `FWD` and the defined class `A`, both in the namespace `a`.
.. code-block:: c++
namespace a {
class FWD;
class A {
FWD *fwd;
};
} // namespace a
And now let's change the namespace `a` to `x`.
.. code-block:: console
clang-change-namespace \
--old_namespace "a" \
--new_namespace "x" \
--file_pattern "test.cc" \
--i \
test.cc
Note that in the code below there's still the forward decalred class `FWD` that
stayed in the namespace `a`. It wasn't moved to the new namespace because it
wasn't defined/declared here in `a` but only forward declared.
.. code-block:: c++
namespace a {
class FWD;
} // namespace a
namespace x {
class A {
a::FWD *fwd;
};
} // namespace x
Another example
---------------
Consider this `test.cc` file:
.. code-block:: c++
namespace na {
class X {};
namespace nb {
class Y {
X x;
};
} // namespace nb
} // namespace na
To move the definition of class `Y` from namespace `na::nb` to `x::y`, run:
.. code-block:: console
clang-change-namespace \
--old_namespace "na::nb" \
--new_namespace "x::y" \
--file_pattern "test.cc" \
--i \
test.cc
This will overwrite `test.cc` to look like this:
.. code-block:: c++
namespace na {
class X {};
} // namespace na
namespace x {
namespace y {
class Y {
na::X x;
};
} // namespace y
} // namespace x
Note, that we've successfully moved the class `Y` from namespace `na::nb` to
namespace `x::y`.
Caveats
=======
Content already exists in new namespace
---------------------------------------
Consider this `test.cc` example that defines two `class A` one inside the
namespace `a` and one in namespace `b`:
.. code-block:: c++
namespace a {
class A {
int classAFromWithinNamespace_a;
};
} // namespace a
namespace b {
class A {
int classAFromWithinNamespace_b;
};
} //namespace b
Let's move everything from namespace `a` to namespace `b`:
.. code-block:: console
clang-change-namespace \
--old_namespace "a" \
--new_namespace "b" \
--file_pattern test.cc \
test.cc
As expected we now have to definitions of `class A` inside the namespace `b`:
.. code-block:: c++
namespace b {
class A {
int classAFromWithinNamespace_a;
};
} // namespace b
namespace b {
class A {
int classAFromWithinNamespace_b;
};
} //namespace b
The re-factoring looks correct but the code will not compile due to the name
duplication. It is not up to the tool to ensure compilability in that sense.
But one has to be aware of that.
Inline namespace doesn't work
-----------------------------
Consider this usage of two versions of implementations for a `greet` function:
.. code-block:: c++
#include <cstdio>
namespace Greeter {
inline namespace Version1 {
const char* greet() { return "Hello from version 1!"; }
} // namespace Version1
namespace Version2 {
const char* greet() { return "Hello from version 2!"; }
} // namespace Version2
} // namespace Greeter
int main(int argc, char* argv[]) {
printf("%s\n", Greeter::greet());
return 0;
}
Note, that currently `Greeter::greet()` will result in a call to
`Greeter::Version1::greet()` because that's the inlined namespace.
Let's say you want to move one and make `Version2` the default now and remove
the `inline` from the `Version1`. First let's try to turn `namespace Version2`
into `inline namespace Version2`:
.. code-block:: console
clang-change-namespace \
--old_namespace "Greeter::Version2" \
--new_namespace "inline Version2" \
--file_pattern main.cc main.cc
But this will put the `inline` keyword in the wrong place resulting in:
.. code-block:: c++
#include <cstdio>
namespace Greeter {
inline namespace Version1 {
const char* greet() { return "Hello from version 1!"; }
} // namespace Version1
} // namespace Greeter
namespace inline Greeter {
namespace Version2 {
const char *greet() { return "Hello from version 2!"; }
} // namespace Version2
} // namespace inline Greeter
int main(int argc, char* argv[]) {
printf("%s\n", Greeter::greet());
return 0;
}
One cannot use `:program:`clang-change-namespace` to inline a namespace.
Symbol references not updated
-----------------------------
Consider this `test.cc` file:
.. code-block:: c++
namespace old {
struct foo {};
} // namespace old
namespace b {
old::foo g_foo;
} // namespace b
Notice that namespace `b` defines a global variable of type `old::foo`. If we
now change the name of the `old` namespace to `modern`, the reference will not
be updated:
.. code-block:: console
clang-change-namespace \
--old_namespace "old" \
--new_namespace "modern" \
--file_pattern test.cc \
test.cc
.. code-block:: c++
namespace modern {
struct foo {};
} // namespace modern
namespace b {
old::foo g_foo;
} // namespace b
`g_foo` is still of the no longer existing type `old::foo` while instead it
should use `modern::foo`.
Only symbol references in the moved namespace are updated, not outside of it.
:program:`clang-change-namespace` Command Line Options
======================================================
.. option:: --allowed_file=<string>
A file containing regexes of symbol names that are not expected to be updated
when changing namespaces around them.
.. option:: --dump_result
Dump new file contents in YAML, if specified.
.. option:: --extra-arg=<string>
Additional argument to append to the compiler command line
.. option:: --extra-arg-before=<string>
Additional argument to prepend to the compiler command line
.. option:: --file_pattern=<string>
Only rename namespaces in files that match the given regular expression
pattern.
.. option:: -i
Inplace edit <file>s, if specified.
.. option:: --new_namespace=<string>
New namespace. Use `""` when you target the global namespace.
.. option:: --old_namespace=<string>
Old namespace.
.. option:: -p <string>
Build path
.. option:: --style=<string>
The style name used for reformatting.

View File

@ -271,6 +271,7 @@ Clang-Tidy Checks
:doc:`misc-no-recursion <misc/no-recursion>`,
:doc:`misc-non-copyable-objects <misc/non-copyable-objects>`,
:doc:`misc-non-private-member-variables-in-classes <misc/non-private-member-variables-in-classes>`,
:doc:`misc-override-with-different-visibility <misc/override-with-different-visibility>`,
:doc:`misc-redundant-expression <misc/redundant-expression>`, "Yes"
:doc:`misc-static-assert <misc/static-assert>`, "Yes"
:doc:`misc-throw-by-value-catch-by-reference <misc/throw-by-value-catch-by-reference>`,

View File

@ -0,0 +1,87 @@
.. title:: clang-tidy - misc-override-with-different-visibility
misc-override-with-different-visibility
=======================================
Finds virtual function overrides with different visibility than the function
in the base class. This includes for example if a virtual function declared as
``private`` is overridden and declared as ``public`` in a subclass. The detected
change is the modification of visibility resulting from keywords ``public``,
``protected``, ``private`` at overridden virtual functions. The check applies to
any normal virtual function and optionally to destructors or operators. Use of
the ``using`` keyword is not considered as visibility change by this check.
.. code-block:: c++
class A {
public:
virtual void f_pub();
private:
virtual void f_priv();
};
class B: public A {
public:
void f_priv(); // warning: changed visibility from private to public
private:
void f_pub(); // warning: changed visibility from public to private
};
class C: private A {
// no warning: f_pub becomes private in this case but this is from the
// private inheritance
};
class D: private A {
public:
void f_pub(); // warning: changed visibility from private to public
// 'f_pub' would have private access but is forced to be
// public
};
If the visibility is changed in this way, it can indicate bad design or
programming error.
If a virtual function is private in a subclass but public in the base class, it
can still be accessed from a pointer to the subclass if the pointer is converted
to the base type. Probably private inheritance can be used instead.
A protected virtual function that is made public in a subclass may have valid
use cases but similar (not exactly same) effect can be achieved with the
``using`` keyword.
Options
-------
.. option:: DisallowedVisibilityChange
Controls what kind of change to the visibility will be detected by the check.
Possible values are `any`, `widening`, `narrowing`. For example the
`widening` option will produce warning only if the visibility is changed
from more restrictive (``private``) to less restrictive (``public``).
Default value is `any`.
.. option:: CheckDestructors
If `true`, the check does apply to destructors too. Otherwise destructors
are ignored by the check.
Default value is `false`.
.. option:: CheckOperators
If `true`, the check does apply to overloaded C++ operators (as virtual
member functions) too. This includes other special member functions (like
conversions) too. This option is probably useful only in rare cases because
operators and conversions are not often virtual functions.
Default value is `false`.
.. option:: IgnoredFunctions
This option can be used to ignore the check at specific functions.
To configure this option, a semicolon-separated list of function names
should be provided. The list can contain regular expressions, in this way it
is possible to select all functions of a specific class (like `MyClass::.*`)
or a specific function of any class (like `my_function` or
`::.*::my_function`). The function names are matched at the base class.
Default value is empty string.

View File

@ -43,14 +43,21 @@ The options and their corresponding values are:
- ``LowerCase`` - example: ``int i_Variable``
- ``CamelCase`` - example: ``int IVariable``
Options
-------
Options summary
---------------
The following options are described below:
The available options are summarized below:
**General options**
- :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`, :option:`AbstractClassHungarianPrefix`
- :option:`AggressiveDependentMemberLookup`
- :option:`CheckAnonFieldInParent`
- :option:`GetConfigPerFile`
- :option:`IgnoreMainLikeFunctions`
**Specific options**
- :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`, :option:`AbstractClassHungarianPrefix`
- :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassIgnoredRegexp`, :option:`ClassHungarianPrefix`
- :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, :option:`ClassConstantIgnoredRegexp`, :option:`ClassConstantHungarianPrefix`
- :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`, :option:`ClassMemberIgnoredRegexp`, :option:`ClassMemberHungarianPrefix`
@ -66,13 +73,11 @@ The following options are described below:
- :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`, :option:`EnumIgnoredRegexp`
- :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`, :option:`EnumConstantIgnoredRegexp`, :option:`EnumConstantHungarianPrefix`
- :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`, :option:`FunctionIgnoredRegexp`
- :option:`GetConfigPerFile`
- :option:`GlobalConstantCase`, :option:`GlobalConstantPrefix`, :option:`GlobalConstantSuffix`, :option:`GlobalConstantIgnoredRegexp`, :option:`GlobalConstantHungarianPrefix`
- :option:`GlobalConstantPointerCase`, :option:`GlobalConstantPointerPrefix`, :option:`GlobalConstantPointerSuffix`, :option:`GlobalConstantPointerIgnoredRegexp`, :option:`GlobalConstantPointerHungarianPrefix`
- :option:`GlobalFunctionCase`, :option:`GlobalFunctionPrefix`, :option:`GlobalFunctionSuffix`, :option:`GlobalFunctionIgnoredRegexp`
- :option:`GlobalPointerCase`, :option:`GlobalPointerPrefix`, :option:`GlobalPointerSuffix`, :option:`GlobalPointerIgnoredRegexp`, :option:`GlobalPointerHungarianPrefix`
- :option:`GlobalVariableCase`, :option:`GlobalVariablePrefix`, :option:`GlobalVariableSuffix`, :option:`GlobalVariableIgnoredRegexp`, :option:`GlobalVariableHungarianPrefix`
- :option:`IgnoreMainLikeFunctions`
- :option:`InlineNamespaceCase`, :option:`InlineNamespacePrefix`, :option:`InlineNamespaceSuffix`, :option:`InlineNamespaceIgnoredRegexp`
- :option:`LocalConstantCase`, :option:`LocalConstantPrefix`, :option:`LocalConstantSuffix`, :option:`LocalConstantIgnoredRegexp`, :option:`LocalConstantHungarianPrefix`
- :option:`LocalConstantPointerCase`, :option:`LocalConstantPointerPrefix`, :option:`LocalConstantPointerSuffix`, :option:`LocalConstantPointerIgnoredRegexp`, :option:`LocalConstantPointerHungarianPrefix`
@ -105,6 +110,12 @@ The following options are described below:
- :option:`VariableCase`, :option:`VariablePrefix`, :option:`VariableSuffix`, :option:`VariableIgnoredRegexp`, :option:`VariableHungarianPrefix`
- :option:`VirtualMethodCase`, :option:`VirtualMethodPrefix`, :option:`VirtualMethodSuffix`, :option:`VirtualMethodIgnoredRegexp`
Options description
-------------------
A detailed description of each option is presented below:
.. option:: AbstractClassCase
When defined, the check will ensure abstract class names conform to the

View File

@ -343,6 +343,107 @@ An overview of all the command-line options:
some-check.SomeOption: 'some value'
...
Clang-Tidy Automation
=====================
:program:`clang-tidy` can analyze multiple source files by specifying them on
the command line. For larger projects, automation scripts provide additional
functionality like parallel execution and integration with version control
systems.
Running Clang-Tidy in Parallel
-------------------------------
:program:`clang-tidy` can process multiple files sequentially, but for projects
with many source files, the :program:`run-clang-tidy.py` script provides
parallel execution to significantly reduce analysis time. This script is
included with clang-tidy and runs :program:`clang-tidy` over all files in a
compilation database or a specified path concurrently.
The script requires a compilation database (``compile_commands.json``) which
can be generated by build systems like CMake (using
``-DCMAKE_EXPORT_COMPILE_COMMANDS=ON``) or by tools like `Bear`_.
The script supports most of the same options as :program:`clang-tidy` itself,
including ``-checks=``, ``-fix``, ``-header-filter=``, and configuration
options. Run ``run-clang-tidy.py --help`` for a complete list of available
options.
Example invocations:
.. code-block:: console
# Run clang-tidy on all files in the compilation database in parallel
$ run-clang-tidy.py -p=build/
# Run with specific checks and apply fixes
$ run-clang-tidy.py -p=build/ -fix -checks=-*,readability-*
# Run on specific files/directories with header filtering
$ run-clang-tidy.py -p=build/ -header-filter=src/ src/
# Run with parallel execution (uses all CPU cores by default)
$ run-clang-tidy.py -p=build/ -j 4
Running Clang-Tidy on Diff
---------------------------
The :program:`clang-tidy-diff.py` script allows you to run
:program:`clang-tidy` on the lines that have been modified in your working
directory or in a specific diff. Importantly, :program:`clang-tidy-diff.py` only reports
diagnostics for changed lines; :program:`clang-tidy` still analyzes the entire
file and filters out unchanged lines after analysis, so this does not improve
performance. This is particularly useful for code reviews and continuous
integration, as it focuses analysis on the changed code rather than the entire
codebase.
The script can work with various diff sources:
* Git working directory changes
* Output from ``git diff``
* Output from ``svn diff``
* Patch files
Example invocations:
.. code-block:: console
# Run clang-tidy on all changes in the working directory
$ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1
# Run with specific checks and apply fixes
$ git diff -U0 --no-color HEAD^ | clang-tidy-diff.py -p1 -fix \
-checks=-*,readability-*
# Run on staged changes
$ git diff -U0 --no-color --cached | clang-tidy-diff.py -p1
# Run on changes between two commits
$ git diff -U0 --no-color HEAD~2 HEAD | clang-tidy-diff.py -p1
# Run on a patch file
$ clang-tidy-diff.py -p1 < changes.patch
The ``-p1`` option tells the script to strip one level of path prefix from
the diff, which is typically needed for Git diffs. The script supports most of
the same options as :program:`clang-tidy` itself, including ``-checks=``,
``-fix``, ``-header-filter=``, and configuration options.
While :program:`clang-tidy-diff.py` is useful for focusing on recent changes,
relying solely on it may lead to incomplete analysis. Since the script only
reports warnings from the modified lines, it may miss issues that are caused
by the changes but manifest elsewhere in the code. For example, changes that
only add lines to a function may cause it to violate size limits (e.g.,
`readability-function-size <checks/readability/function-size.html>`_), but the
diagnostic will be reported at the function declaration, which may not be in
the diff and thus filtered out. Modifications to header files may also affect
many implementation files, but only warnings in the modified header lines will
be reported.
For comprehensive analysis, especially before merging significant changes,
consider running :program:`clang-tidy` on the entire affected files or the
whole project using :program:`run-clang-tidy.py`.
.. _clang-tidy-nolint:
Suppressing Undesired Diagnostics
@ -465,5 +566,6 @@ example, ``NOLINTBEGIN(check-name)`` can be paired with
:program:`clang-tidy` will generate a ``clang-tidy-nolint`` error diagnostic if
any ``NOLINTBEGIN``/``NOLINTEND`` comment violates these requirements.
.. _Bear: https://github.com/rizsotto/Bear
.. _LibTooling: https://clang.llvm.org/docs/LibTooling.html
.. _How To Setup Tooling For LLVM: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html

View File

@ -17,6 +17,7 @@ Contents
clang-tidy/index
clang-include-fixer
clang-change-namespace
modularize
pp-trace
clangd <https://clangd.llvm.org/>

View File

@ -0,0 +1,14 @@
#pragma clang system_header
namespace sys {
struct Base {
virtual void publicF();
};
struct Derived: public Base {
private:
void publicF() override;
};
}

View File

@ -0,0 +1,60 @@
// RUN: %check_clang_tidy %s misc-override-with-different-visibility %t -- \
// RUN: -config="{CheckOptions: {misc-override-with-different-visibility.IgnoredFunctions: 'IgnoreAlways::.*;::a::IgnoreSelected::.*;IgnoreFunctions::f1;ignored_f'}}"
class IgnoreAlways {
virtual void f();
};
class IgnoreSelected {
virtual void f();
};
namespace a {
class IgnoreAlways {
virtual void f();
};
class IgnoreSelected {
virtual void f();
};
}
namespace ignore_always {
class Test1: public IgnoreAlways {
public:
void f();
void ignored_f(int);
};
class Test2: public a::IgnoreAlways {
public:
void f();
};
}
namespace ignore_selected {
class Test1: public IgnoreSelected {
public:
void f();
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'f'
// CHECK-MESSAGES: :9:16: note: function declared here
void ignored_f(int);
};
class Test2: public a::IgnoreSelected {
public:
void f();
};
}
class IgnoreFunctions {
virtual void f1();
virtual void f2();
virtual void ignored_f();
};
class IgnoreFunctionsTest: public IgnoreFunctions {
public:
void f1();
void f2();
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'f2'
// CHECK-MESSAGES: :[[@LINE-9]]:16: note: function declared here
void ignored_f();
};

View File

@ -0,0 +1,75 @@
// RUN: %check_clang_tidy -check-suffixes=DTORS,WIDENING,NARROWING %s misc-override-with-different-visibility %t -- \
// RUN: -config="{CheckOptions: {misc-override-with-different-visibility.CheckDestructors: true}}"
// RUN: %check_clang_tidy -check-suffixes=OPS,WIDENING,NARROWING %s misc-override-with-different-visibility %t -- \
// RUN: -config="{CheckOptions: {misc-override-with-different-visibility.CheckOperators: true}}"
// RUN: %check_clang_tidy -check-suffixes=WIDENING %s misc-override-with-different-visibility %t -- \
// RUN: -config="{CheckOptions: {misc-override-with-different-visibility.DisallowedVisibilityChange: 'widening'}}"
// RUN: %check_clang_tidy -check-suffixes=NARROWING %s misc-override-with-different-visibility %t -- \
// RUN: -config="{CheckOptions: {misc-override-with-different-visibility.DisallowedVisibilityChange: 'narrowing'}}"
namespace test_change {
class A {
protected:
virtual void f1();
virtual void f2();
};
class B: public A {
public:
void f1();
// CHECK-MESSAGES-WIDENING: :[[@LINE-1]]:8: warning: visibility of function 'f1'
// CHECK-MESSAGES-WIDENING: :[[@LINE-8]]:16: note: function declared here
private:
void f2();
// CHECK-MESSAGES-NARROWING: :[[@LINE-1]]:8: warning: visibility of function 'f2'
// CHECK-MESSAGES-NARROWING: :[[@LINE-11]]:16: note: function declared here
};
}
namespace test_destructor {
class A {
public:
virtual ~A();
};
class B: public A {
protected:
~B();
// CHECK-MESSAGES-DTORS: :[[@LINE-1]]:3: warning: visibility of function '~B'
// CHECK-MESSAGES-DTORS: :[[@LINE-7]]:11: note: function declared here
};
}
namespace test_operator {
class A {
virtual A& operator=(const A&);
virtual A& operator++();
virtual int operator()(int);
virtual operator double() const;
};
class B: public A {
protected:
A& operator=(const A&);
// CHECK-MESSAGES-OPS: :[[@LINE-1]]:6: warning: visibility of function 'operator='
// CHECK-MESSAGES-OPS: :[[@LINE-10]]:14: note: function declared here
A& operator++();
// CHECK-MESSAGES-OPS: :[[@LINE-1]]:6: warning: visibility of function 'operator++'
// CHECK-MESSAGES-OPS: :[[@LINE-12]]:14: note: function declared here
int operator()(int);
// CHECK-MESSAGES-OPS: :[[@LINE-1]]:7: warning: visibility of function 'operator()'
// CHECK-MESSAGES-OPS: :[[@LINE-14]]:15: note: function declared here
operator double() const;
// CHECK-MESSAGES-OPS: :[[@LINE-1]]:3: warning: visibility of function 'operator double'
// CHECK-MESSAGES-OPS: :[[@LINE-16]]:11: note: function declared here
};
}

View File

@ -0,0 +1,289 @@
// RUN: %check_clang_tidy %s misc-override-with-different-visibility %t -- -config="{CheckOptions: {misc-override-with-different-visibility.CheckDestructors: true,misc-override-with-different-visibility.CheckOperators: true}}" -- -I %S/Inputs/override-with-different-visibility
#include <test-system-header.h>
class A {
public:
virtual void pub_foo1() {}
virtual void pub_foo2() {}
virtual void pub_foo3() {}
protected:
virtual void prot_foo1();
virtual void prot_foo2();
virtual void prot_foo3();
private:
virtual void priv_foo1() {}
virtual void priv_foo2() {}
virtual void priv_foo3() {}
};
void A::prot_foo1() {}
void A::prot_foo2() {}
void A::prot_foo3() {}
namespace test1 {
class B: public A {
public:
void pub_foo1() override {}
void prot_foo1() override {}
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo1' is changed from protected in class 'A' to public [misc-override-with-different-visibility]
// CHECK-MESSAGES: :9:16: note: function declared here as protected
void priv_foo1() override {}
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'priv_foo1' is changed from private in class 'A' to public [misc-override-with-different-visibility]
// CHECK-MESSAGES: :13:16: note: function declared here as private
protected:
void pub_foo2() override {}
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'pub_foo2' is changed from public in class 'A' to protected [misc-override-with-different-visibility]
// CHECK-MESSAGES: :6:16: note: function declared here as public
void prot_foo2() override {}
void priv_foo2() override {}
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'priv_foo2' is changed from private in class 'A' to protected [misc-override-with-different-visibility]
// CHECK-MESSAGES: :14:16: note: function declared here as private
private:
void pub_foo3() override {}
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'pub_foo3' is changed from public in class 'A' to private [misc-override-with-different-visibility]
// CHECK-MESSAGES: :7:16: note: function declared here as public
void prot_foo3() override {}
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo3' is changed from protected in class 'A' to private [misc-override-with-different-visibility]
// CHECK-MESSAGES: :11:16: note: function declared here as protected
void priv_foo3() override {}
};
class C: public B {
public:
void pub_foo1() override;
protected:
void prot_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo1' is changed from public in class 'B' to protected [misc-override-with-different-visibility]
// CHECK-MESSAGES: :27:8: note: function declared here as public
private:
void priv_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'priv_foo1' is changed from public in class 'B' to private [misc-override-with-different-visibility]
// CHECK-MESSAGES: :30:8: note: function declared here as public
};
void C::prot_foo1() {}
void C::priv_foo1() {}
}
namespace test2 {
class B: public A {
public:
void pub_foo1() override;
protected:
void prot_foo1() override;
private:
void priv_foo1() override;
};
class C: public B {
public:
void pub_foo1() override;
void prot_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo1' is changed from protected in class 'B' to public
// CHECK-MESSAGES: :75:8: note: function declared here as protected
void priv_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'priv_foo1' is changed from private in class 'B' to public
// CHECK-MESSAGES: :77:8: note: function declared here as private
void pub_foo2() override;
void prot_foo2() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo2' is changed from protected in class 'A' to public
// CHECK-MESSAGES: :10:16: note: function declared here as protected
void priv_foo2() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'priv_foo2' is changed from private in class 'A' to public
// CHECK-MESSAGES: :14:16: note: function declared here as private
};
}
namespace test3 {
class B: private A {
public:
void pub_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'pub_foo1' is changed from private (through private inheritance of class 'A') to public
// CHECK-MESSAGES: :103:10: note: 'A' is inherited as private here
// CHECK-MESSAGES: :5:16: note: function declared here as public
protected:
void prot_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo1' is changed from private (through private inheritance of class 'A') to protected
// CHECK-MESSAGES: :103:10: note: 'A' is inherited as private here
// CHECK-MESSAGES: :9:16: note: function declared here as protected
private:
void priv_foo1() override;
public:
void prot_foo2() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'prot_foo2' is changed from private (through private inheritance of class 'A') to public
// CHECK-MESSAGES: :103:10: note: 'A' is inherited as private here
// CHECK-MESSAGES: :10:16: note: function declared here as protected
void priv_foo2() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'priv_foo2' is changed from private in class 'A' to public
// CHECK-MESSAGES: :14:16: note: function declared here as private
private:
void pub_foo3() override;
void prot_foo3() override;
};
class C: private A {
};
class D: public C {
public:
void pub_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'pub_foo1' is changed from private (through private inheritance of class 'A') to public
// CHECK-MESSAGES: :131:10: note: 'A' is inherited as private here
// CHECK-MESSAGES: :5:16: note: function declared here as public
};
}
namespace test4 {
struct Base1 {
public:
virtual void foo1();
private:
virtual void foo2();
};
struct Base2 {
public:
virtual void foo2();
private:
virtual void foo1();
};
struct A : public Base1, public Base2 {
protected:
void foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'foo1' is changed from private in class 'Base2' to protected
// CHECK-MESSAGES: :158:16: note: function declared here as private
// CHECK-MESSAGES: :[[@LINE-3]]:8: warning: visibility of function 'foo1' is changed from public in class 'Base1' to protected
// CHECK-MESSAGES: :149:16: note: function declared here as public
private:
void foo2() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'foo2' is changed from public in class 'Base2' to private
// CHECK-MESSAGES: :156:16: note: function declared here as public
};
}
namespace test5 {
struct B1: virtual public A {};
struct B2: virtual private A {};
struct B: public B1, public B2 {
public:
void pub_foo1() override;
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'pub_foo1' is changed from private (through private inheritance of class 'A') to public
// CHECK-MESSAGES: :179:12: note: 'A' is inherited as private here
// CHECK-MESSAGES: :5:16: note: function declared here as public
};
}
namespace test_using {
class A {
private:
A(int);
protected:
virtual void f();
};
class B: public A {
public:
using A::A;
using A::f;
};
}
namespace test_template {
template <typename T>
class A {
protected:
virtual T foo();
};
template <typename T>
class B: public A<T> {
private:
T foo() override;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: visibility of function 'foo' is changed from protected in class 'A<int>' to private
// CHECK-MESSAGES: :[[@LINE-8]]:13: note: function declared here as protected
};
template <typename T>
class C: private A<T> {
public:
T foo() override;
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: visibility of function 'foo' is changed from private (through private inheritance of class 'A<int>') to public
// CHECK-MESSAGES: :[[@LINE-4]]:10: note: 'A<int>' is inherited as private here
// CHECK-MESSAGES: :[[@LINE-17]]:13: note: function declared here as protected
};
B<int> fB() {
return B<int>{};
}
C<int> fC() {
return C<int>{};
}
}
namespace test_system_header {
struct SysDerived: public sys::Base {
private:
void publicF();
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: visibility of function 'publicF' is changed from public in class 'Base' to private
};
}
namespace test_destructor {
class A {
public:
virtual ~A();
};
class B: public A {
protected:
~B();
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: visibility of function '~B'
// CHECK-MESSAGES: :[[@LINE-7]]:11: note: function declared here
};
}
namespace test_operator {
class A {
virtual int operator()(int);
virtual A& operator++();
virtual operator double() const;
};
class B: public A {
protected:
int operator()(int);
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: visibility of function 'operator()'
// CHECK-MESSAGES: :[[@LINE-9]]:15: note: function declared here
A& operator++();
// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: visibility of function 'operator++'
// CHECK-MESSAGES: :[[@LINE-11]]:14: note: function declared here
operator double() const;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: visibility of function 'operator double'
// CHECK-MESSAGES: :[[@LINE-13]]:11: note: function declared here
};
}

View File

@ -176,3 +176,11 @@ struct TemplateAssignment {
}
};
}
namespace GH153770 {
struct A;
struct A {
A() = default;
A& operator=(const A&) = default;
};
} // namespace GH153770

View File

@ -10,7 +10,7 @@
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header_alias\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header_alias\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER --allow-empty %s
// Check that `-header-filter` operates on the same file paths as paths in
// diagnostics printed by ClangTidy.

View File

@ -0,0 +1,26 @@
// This test ensures that the --quiet flag only suppresses the "X warnings generated"
// message while keeping all diagnostic information including caret indicators (^).
// RUN: clang-tidy -checks=-*,readability-magic-numbers,clang-diagnostic-sign-compare %s -- \
// RUN: -Wsign-compare 2>&1 | FileCheck %s --check-prefix=CHECK-NORMAL
// RUN: clang-tidy -checks=-*,readability-magic-numbers,clang-diagnostic-sign-compare -quiet %s -- \
// RUN: -Wsign-compare 2>&1 | FileCheck %s --check-prefix=CHECK-QUIET
// CHECK-NORMAL: 2 warnings generated
// CHECK-NORMAL-DAG: warning: 42 is a magic number
// CHECK-NORMAL-DAG: {{[ ]*\^}}
// CHECK-NORMAL-DAG: warning: comparison of integers of different signs
// CHECK-NORMAL-DAG: {{[ ]*~ \^ ~}}
// CHECK-QUIET-NOT: {{[0-9]+}} warning{{s?}} generated
// CHECK-QUIET-DAG: warning: 42 is a magic number
// CHECK-QUIET-DAG: {{[ ]*\^}}
// CHECK-QUIET-DAG: warning: comparison of integers of different signs
// CHECK-QUIET-DAG: {{[ ]*~ \^ ~}}
int main() {
const int CONST_VAL = 10;
int x = 42; // trigger 'readability-magic-numbers' with caret: ^
unsigned int y = CONST_VAL;
return x < y; // trigger 'clang-diagnostic-sign-compare' with caret: ^
}

View File

@ -35,7 +35,7 @@ if(WIN32)
endif()
# The Python FFI interface is broken on AIX: https://bugs.python.org/issue38628.
if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
if("${CMAKE_SYSTEM_NAME}" MATCHES "AIX")
set(RUN_PYTHON_TESTS FALSE)
endif()

View File

@ -60,6 +60,10 @@ only for the linker wrapper will be forwarded to the wrapped linker job.
--v Display the version number and exit
-- The separator for the wrapped linker arguments
The linker wrapper will generate the appropriate runtime calls to register the
generated device binary with the offloading runtime. To do this step manually we
provide the ``llvm-offload-wrapper`` utility.
Relocatable Linking
===================

View File

@ -9,14 +9,14 @@ Introduction
============
Coroutines in C++ were introduced in C++20, and the user experience for
debugging them can still be challenging. This document guides you how to most
debugging them can still be challenging. This document guides you on how to most
efficiently debug coroutines and how to navigate existing shortcomings in
debuggers and compilers.
Coroutines are generally used either as generators or for asynchronous
programming. In this document, we will discuss both use cases. Even if you are
using coroutines for asynchronous programming, you should still read the
generators section, as it will introduce foundational debugging techniques also
generators section, as it introduces foundational debugging techniques also
applicable to the debugging of asynchronous programs.
Both compilers (clang, gcc, ...) and debuggers (lldb, gdb, ...) are
@ -34,15 +34,15 @@ scripting. This guide comes with a basic GDB script for coroutine debugging.
This guide will first showcase the more polished, bleeding-edge experience, but
will also show you how to debug coroutines with older toolchains. In general,
the older your toolchain, the deeper you will have to dive into the
implementation details of coroutines (such as their ABI). The further down in
this document you go, the more low-level, technical the content will become. If
implementation details of coroutines (such as their ABI). The further down you go in
this document, the more low-level, technical the content will become. If
you are on an up-to-date toolchain, you will hopefully be able to stop reading
earlier.
Debugging generators
====================
One of the two major use cases for coroutines in C++ are generators, i.e.,
One of the two major use cases for coroutines in C++ is generators, i.e.,
functions which can produce values via ``co_yield``. Values are produced
lazily, on-demand. For this purpose, every time a new value is requested, the
coroutine gets resumed. As soon as it reaches a ``co_yield`` and thereby
@ -141,7 +141,7 @@ a regular function.
Note the two additional variables ``__promise`` and ``__coro_frame``. Those
show the internal state of the coroutine. They are not relevant for our
generator example, but will be relevant for asynchronous programming described
generator example but will be relevant for asynchronous programming described
in the next section.
Stepping out of a coroutine
@ -174,7 +174,7 @@ Inspecting a suspended coroutine
--------------------------------
The ``print10Elements`` function receives an opaque ``generator`` type. Let's
assume we are suspended at the ``++gen;`` line, and want to inspect the
assume we are suspended at the ``++gen;`` line and want to inspect the
generator and its internal state.
To do so, we can simply look into the ``gen.hdl`` variable. LLDB comes with a
@ -188,7 +188,7 @@ We can see two function pointers ``resume`` and ``destroy``. These pointers
point to the resume / destroy functions. By inspecting those function pointers,
we can see that our ``generator`` is actually backed by our ``fibonacci``
coroutine. When using VS Code + lldb-dap, you can Cmd+Click on the function
address (``0x555...`` in the screenshot) to directly jump to the function
address (``0x555...`` in the screenshot) to jump directly to the function
definition backing your coroutine handle.
Next, we see the ``promise``. In our case, this reveals the current value of
@ -247,12 +247,12 @@ the line number of the current suspension point in the promise:
};
This stores the return address of ``await_suspend`` within the promise.
Thereby, we can read it back from the promise of a suspended coroutine, and map
Thereby, we can read it back from the promise of a suspended coroutine and map
it to an exact source code location. For a complete example, see the ``task``
type used below for asynchronous programming.
Alternatively, we can modify the C++ code to store the line number in the
promise type. We can use a ``std::source_location`` to get the line number of
promise type. We can use ``std::source_location`` to get the line number of
the await and store it inside the ``promise_type``. In the debugger, we can
then read the line number from the promise of the suspended coroutine.
@ -270,7 +270,7 @@ then read the line number from the promise of the suspended coroutine.
};
The downside of both approaches is that they come at the price of additional
runtime cost. In particular the second approach increases binary size, since it
runtime cost. In particular, the second approach increases binary size, since it
requires additional ``std::source_location`` objects, and those source
locations are not stripped by split-dwarf. Whether the first approach is worth
the additional runtime cost is a trade-off you need to make yourself.
@ -285,7 +285,7 @@ provide custom debugging support, so in addition to this guide, you might want
to check out their documentation.
When using coroutines for asynchronous programming, your library usually
provides you some ``task`` type. This type usually looks similar to this:
provides you with some ``task`` type. This type usually looks similar to this:
.. code-block:: c++
@ -479,7 +479,7 @@ One such solution is to store the list of in-flight coroutines in a collection:
};
With this in place, it is possible to inspect ``inflight_coroutines`` from the
debugger, and rely on LLDB's ``std::coroutine_handle`` pretty-printer to
debugger and rely on LLDB's ``std::coroutine_handle`` pretty-printer to
inspect the coroutines.
This technique will track *all* coroutines, also the ones which are currently
@ -498,8 +498,8 @@ LLDB before 21.0 did not yet show the ``__coro_frame`` inside
``coroutine_handle``. To inspect the coroutine frame, you had to use the
approach described in the :ref:`devirtualization` section.
LLDB before 18.0 was hiding the ``__promise`` and ``__coro_frame``
variable by default. The variables are still present, but they need to be
LLDB before 18.0 hid the ``__promise`` and ``__coro_frame``
variables by default. The variables are still present, but they need to be
explicitly added to the "watch" pane in VS Code or requested via
``print __promise`` and ``print __coro_frame`` from the debugger console.
@ -511,9 +511,9 @@ section.
Toolchain Implementation Details
================================
This section covers the ABI, as well as additional compiler-specific behavior.
This section covers the ABI as well as additional compiler-specific behavior.
The ABI is followed by all compilers, on all major systems, including Windows,
Linux and macOS. Different compilers emit different debug information, though.
Linux, and macOS. Different compilers emit different debug information, though.
Ramp, resume and destroy functions
----------------------------------
@ -595,7 +595,7 @@ functions as their first two members. As such, we can read the function
pointers from the coroutine frame and then obtain the function's name from its
address.
The promise is guaranteed to be at a 16 byte offset from the coroutine frame.
The promise is guaranteed to be at a 16-byte offset from the coroutine frame.
If we have a coroutine handle at address 0x416eb0, we can hence reinterpret-cast
the promise as follows:
@ -607,8 +607,8 @@ Implementation in clang / LLVM
------------------------------
The C++ Coroutines feature in the Clang compiler is implemented in two parts of
the compiler. Semantic analysis is performed in Clang, and Coroutine
construction and optimization takes place in the LLVM middle-end.
the compiler. Semantic analysis is performed in Clang, and coroutine
construction and optimization take place in the LLVM middle-end.
For each coroutine function, the frontend generates a single corresponding
LLVM-IR function. This function uses special ``llvm.coro.suspend`` intrinsics
@ -622,7 +622,7 @@ points into the coroutine frame. Most of the heavy lifting to preserve debugging
information is done in this pass. This pass needs to rewrite all variable
locations to point into the coroutine frame.
Afterwards, a couple of additional optimizations are applied, before code
Afterwards, a couple of additional optimizations are applied before code
gets emitted, but none of them are really interesting regarding debugging
information.
@ -636,8 +636,8 @@ However, this is not possible for coroutine frames because the frames are
constructed in the LLVM middle-end.
To mitigate this problem, the LLVM middle end attempts to generate some debug
information, which is unfortunately incomplete, since much of the language
specific information is missing in the middle end.
information, which is unfortunately incomplete, since much of the
language-specific information is missing in the middle end.
.. _devirtualization:
@ -655,7 +655,7 @@ There are two possible approaches to do so:
We can lookup their types and thereby get the types of promise
and coroutine frame.
In gdb, one can use the following approach to devirtualize coroutine type,
In gdb, one can use the following approach to devirtualize a coroutine type,
assuming we have a ``std::coroutine_handle`` is at address 0x418eb0:
::
@ -679,7 +679,7 @@ LLDB comes with devirtualization support out of the box, as part of the
pretty-printer for ``std::coroutine_handle``. Internally, this pretty-printer
uses the second approach. We look up the types in the destroy function and not
the resume function because the resume function pointer will be set to a
nullptr as soon as a coroutine reaches its final suspension point. If we used
``nullptr`` as soon as a coroutine reaches its final suspension point. If we used
the resume function, devirtualization would hence fail for all coroutines that
have reached their final suspension point.
@ -687,10 +687,10 @@ Interpreting the coroutine frame in optimized builds
----------------------------------------------------
The ``__coro_frame`` variable usually refers to the coroutine frame of an
*in-flight* coroutine. This means, the coroutine is currently executing.
*in-flight* coroutine. This means the coroutine is currently executing.
However, the compiler only guarantees the coroutine frame to be in a consistent
state while the coroutine is suspended. As such, the variables inside the
``__coro_frame`` variable might be outdated, in particular when optimizations
``__coro_frame`` variable might be outdated, particularly when optimizations
are enabled.
Furthermore, when optimizations are enabled, the compiler will layout the
@ -731,7 +731,7 @@ despite ``a`` being frequently incremented.
While this might be surprising, this is a result of the optimizer recognizing
that it can eliminate most of the load/store operations.
The above code gets optimized to the equivalent of:
The above code is optimized to the equivalent of:
.. code-block:: c++
@ -1180,5 +1180,5 @@ The authors of the Folly libraries wrote a blog post series on how they debug co
* `Async stack traces in folly: Improving debugging in the developer lifecycle <https://developers.facebook.com/blog/post/2021/10/21/async-stack-traces-folly-improving-debugging-developer-lifecycle/>`_
Besides some topics also covered here (stack traces from the debugger), Folly's blog post series also covers
more additional topics, such as capturing async stack traces in performance profiles via eBPF filters
additional topics, such as capturing async stack traces in performance profiles via eBPF filters
and printing async stack traces on crashes.

View File

@ -635,11 +635,12 @@ C and C++. For example:
return v;
}
Boolean vectors are a Clang extension of the ext vector type. Boolean vectors
are intended, though not guaranteed, to map to vector mask registers. The size
parameter of a boolean vector type is the number of bits in the vector. The
boolean vector is dense and each bit in the boolean vector is one vector
element.
element. Query for this feature with ``__has_feature(ext_vector_type_boolean)``.
The semantics of boolean vectors borrows from C bit-fields with the following
differences:
@ -657,6 +658,16 @@ The size and alignment are both the number of bits rounded up to the next power
of two, but the alignment is at most the maximum vector alignment of the
target.
A boolean vector can be used in a ternary `?:` operator to select vector
elements of a different type.
.. code-block:: c++
typedef int int4 __attribute__((ext_vector_type(4)));
typedef bool bool4 __attribute__((ext_vector_type(4)));
int4 blend(bool4 cond, int4 a, int4 b) { return cond ? a : b; }
Vector Literals
---------------
@ -757,11 +768,12 @@ elementwise to the input.
Unless specified otherwise operation(±0) = ±0 and operation(±infinity) = ±infinity
The integer elementwise intrinsics, including ``__builtin_elementwise_popcount``,
The elementwise intrinsics ``__builtin_elementwise_popcount``,
``__builtin_elementwise_bitreverse``, ``__builtin_elementwise_add_sat``,
``__builtin_elementwise_sub_sat``, ``__builtin_elementwise_max``,
``__builtin_elementwise_min``, and ``__builtin_elementwise_abs``
can be called in a ``constexpr`` context.
``__builtin_elementwise_min``, ``__builtin_elementwise_abs``,
``__builtin_elementwise_ctlz``, ``__builtin_elementwise_cttz``, and
``__builtin_elementwise_fma`` can be called in a ``constexpr`` context.
No implicit promotion of integer types takes place. The mixing of integer types
of different sizes and signs is forbidden in binary and ternary builtins.
@ -870,6 +882,14 @@ T __builtin_elementwise_fshr(T x, T y, T z) perform a funnel shift right. Co
significant bits of the wide value), the combined value is shifted
right by z, and the least significant bits are extracted to produce
a result that is the same size as the original arguments.
T __builtin_elementwise_ctlz(T x[, T y]) return the number of leading 0 bits in the first argument. If integer types
the first argument is 0 and an optional second argument is provided,
the second argument is returned. It is undefined behaviour if the
first argument is 0 and no second argument is provided.
T __builtin_elementwise_cttz(T x[, T y]) return the number of trailing 0 bits in the first argument. If integer types
the first argument is 0 and an optional second argument is provided,
the second argument is returned. It is undefined behaviour if the
first argument is 0 and no second argument is provided.
============================================== ====================================================================== =========================================
@ -922,6 +942,24 @@ Let ``VT`` be a vector type and ``ET`` the element type of ``VT``.
for the comparison.
======================================= ====================================================================== ==================================
*Masked Builtins*
Each builtin accesses memory according to a provided boolean mask. These are
provided as ``__builtin_masked_load`` and ``__builtin_masked_store``. The first
argument is always boolean mask vector.
Example:
.. code-block:: c++
using v8b = bool [[clang::ext_vector_type(8)]];
using v8i = int [[clang::ext_vector_type(8)]];
v8i load(v8b m, v8i *p) { return __builtin_masked_load(m, p); }
void store(v8b m, v8i v, v8i *p) { __builtin_masked_store(m, v, p); }
Matrix Types
============
@ -1725,6 +1763,7 @@ Hexadecimal floating constants (N308) C
Compound literals (N716) C99 C89, C++
``//`` comments (N644) C99 C89
Mixed declarations and code (N740) C99 C89
init-statement in for (N740) C99 C89
Variadic macros (N707) C99 C89
Empty macro arguments (N570) C99 C89
Trailing comma in enum declaration C99 C89
@ -1791,6 +1830,37 @@ __make_integer_seq
This alias returns ``IntSeq`` instantiated with ``IntSeqT = T``and ``Ints`` being the pack ``0, ..., N - 1``.
__builtin_dedup_pack
--------------------
.. code-block:: c++
template <class... Ts>
using __builtin_dedup_pack = ...;
This alias takes a template parameter pack ``Ts`` and produces a new unexpanded pack containing the unique types
from ``Ts``, with the order of the first occurrence of each type preserved.
It is useful in template metaprogramming to normalize type lists.
The resulting pack can be expanded in contexts like template argument lists or base specifiers.
**Example of Use**:
.. code-block:: c++
template <typename...> struct TypeList;
// The resulting type is TypeList<int, double, char>
template <typename ...ExtraTypes>
using MyTypeList = TypeList<__builtin_dedup_pack<int, double, int, char, double, ExtraTypes...>...>;
**Limitations**:
* This builtin can only be used inside a template.
* The resulting pack is currently only supported for expansion in template argument lists and base specifiers.
* This builtin cannot be assigned to a template template parameter.
Type Trait Primitives
=====================
@ -4370,7 +4440,7 @@ fall into one of the specified floating-point classes.
if (__builtin_isfpclass(x, 448)) {
// `x` is positive finite value
...
...
}
**Description**:

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,22 @@ latest release, please see the `Clang Web Site <https://clang.llvm.org>`_ or the
Potentially Breaking Changes
============================
- Clang will now emit a warning if the auto-detected GCC installation
directory (i.e. the one with the largest version number) does not
contain libstdc++ include directories although a "complete" GCC
installation directory containing the include directories is
available. It is planned to change the auto-detection to prefer the
"complete" directory in the future. The warning will disappear if
the libstdc++ include directories are either installed or removed
for all GCC installation directories considered by the
auto-detection; see the output of ``clang -v`` for a list of those
directories. If the GCC installations cannot be modified and
maintaining the current choice of the auto-detection is desired, the
GCC installation directory can be selected explicitly using the
``--gcc-install-dir`` command line argument. This will silence the
warning. It can also be disabled using the
``-Wno-gcc-install-dir-libstdcxx`` command line flag.
C/C++ Language Potentially Breaking Changes
-------------------------------------------
@ -137,10 +153,41 @@ Non-comprehensive list of changes in this release
- ``__builtin_elementwise_max`` and ``__builtin_elementwise_min`` functions for integer types can
now be used in constant expressions.
- A vector of booleans is now a valid condition for the ternary ``?:`` operator.
This binds to a simple vector select operation.
- Added ``__builtin_masked_load`` and ``__builtin_masked_store`` for conditional
memory loads from vectors. Binds to the LLVM intrinsic of the same name.
- Use of ``__has_feature`` to detect the ``ptrauth_qualifier`` and ``ptrauth_intrinsics``
features has been deprecated, and is restricted to the arm64e target only. The
correct method to check for these features is to test for the ``__PTRAUTH__``
macro.
- Added a new builtin, ``__builtin_dedup_pack``, to remove duplicate types from a parameter pack.
This feature is particularly useful in template metaprogramming for normalizing type lists.
The builtin produces a new, unexpanded parameter pack that can be used in contexts like template
argument lists or base specifiers.
.. code-block:: c++
template <typename...> struct TypeList;
// The resulting type is TypeList<int, double, char>
using MyTypeList = TypeList<__builtin_dedup_pack<int, double, int, char, double>...>;
Currently, the use of ``__builtin_dedup_pack`` is limited to template arguments and base
specifiers, it also must be used within a template context.
New Compiler Flags
------------------
- New option ``-fno-sanitize-annotate-debug-info-traps`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).
Lanai Support
^^^^^^^^^^^^^^
- The option ``-mcmodel={small,medium,large}`` is supported again.
Deprecated Compiler Flags
-------------------------
@ -178,6 +225,9 @@ Improvements to Clang's diagnostics
potential misaligned members get processed before they can get discarded.
(#GH144729)
- Fixed false positive in ``-Wmissing-noreturn`` diagnostic when it was requiring the usage of
``[[noreturn]]`` on lambdas before C++23 (#GH154493).
Improvements to Clang's time-trace
----------------------------------
@ -193,6 +243,9 @@ Bug Fixes in This Version
targets that treat ``_Float16``/``__fp16`` as native scalar types. Previously
the warning was silently lost because the operands differed only by an implicit
cast chain. (#GH149967).
- Fixed a crash with incompatible pointer to integer conversions in designated
initializers involving string literals. (#GH154046)
- Fixed scope of typedefs present inside a template class. (#GH91451)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -202,8 +255,8 @@ Bug Fixes to Compiler Builtins
Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- ``[[nodiscard]]`` is now respected on Objective-C and Objective-C++ methods.
(#GH141504)
- ``[[nodiscard]]`` is now respected on Objective-C and Objective-C++ methods
(#GH141504) and on types returned from indirect calls (#GH142453).
- Fixes some late parsed attributes, when applied to function definitions, not being parsed
in function try blocks, and some situations where parsing of the function body
is skipped, such as error recovery and code completion. (#GH153551)
@ -215,6 +268,7 @@ Bug Fixes to C++ Support
- Diagnose binding a reference to ``*nullptr`` during constant evaluation. (#GH48665)
- Suppress ``-Wdeprecated-declarations`` in implicitly generated functions. (#GH147293)
- Fix a crash when deleting a pointer to an incomplete array (#GH150359).
- Fixed a mismatched lambda scope bug when propagating up ``consteval`` within nested lambdas. (#GH145776)
- Fix an assertion failure when expression in assumption attribute
(``[[assume(expr)]]``) creates temporary objects.
- Fix the dynamic_cast to final class optimization to correctly handle
@ -224,6 +278,8 @@ Bug Fixes to C++ Support
"intializing multiple members of union" coincide (#GH149985).
- Fix a crash when using ``explicit(bool)`` in pre-C++11 language modes. (#GH152729)
- Fix the parsing of variadic member functions when the ellipis immediately follows a default argument.(#GH153445)
- Fixed a bug that caused ``this`` captured by value in a lambda with a dependent explicit object parameter to not be
instantiated properly. (#GH154054)
Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
@ -253,6 +309,13 @@ NVPTX Support
X86 Support
^^^^^^^^^^^
- More SSE, AVX and AVX512 intrinsics, including initializers and general
arithmetic can now be used in C++ constant expressions.
- Some SSE, AVX and AVX512 intrinsics have been converted to wrap
generic __builtin intrinsics.
- NOTE: Please avoid use of the __builtin_ia32_* intrinsics - these are not
guaranteed to exist in future releases, or match behaviour with previous
releases of clang or other compilers.
Arm and AArch64 Support
^^^^^^^^^^^^^^^^^^^^^^^
@ -312,6 +375,9 @@ AST Matchers
- Add a boolean member ``IgnoreSystemHeaders`` to ``MatchFinderOptions``. This
allows it to ignore nodes in system headers when traversing the AST.
- ``hasConditionVariableStatement`` now supports ``for`` loop, ``while`` loop
and ``switch`` statements.
clang-format
------------
- Add ``SpaceInEmptyBraces`` option and set it to ``Always`` for WebKit style.

View File

@ -66,17 +66,17 @@ supported. Uninstrumented code simply won't be accounted for in reports.
To compile code with Modified Condition/Decision Coverage (MC/DC) enabled,
pass ``-fcoverage-mcdc`` in addition to the clang options specified above.
MC/DC is an advanced form of code coverage most applicable in the embedded
MC/DC is an advanced form of code coverage most applicable to the embedded
space.
Running the instrumented program
================================
The next step is to run the instrumented program. When the program exits it
The next step is to run the instrumented program. When the program exits, it
will write a **raw profile** to the path specified by the ``LLVM_PROFILE_FILE``
environment variable. If that variable does not exist, the profile is written
to ``default.profraw`` in the current directory of the program. If
``LLVM_PROFILE_FILE`` contains a path to a non-existent directory, the missing
``LLVM_PROFILE_FILE`` specifies a path to a non-existent directory, the missing
directory structure will be created. Additionally, the following special
**pattern strings** are rewritten:
@ -97,7 +97,7 @@ directory structure will be created. Additionally, the following special
* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to
avoid binary signature collisions. To use it, the program should be compiled
with the build ID linker option (``--build-id`` for GNU ld or LLD,
``/build-id`` for lld-link on Windows). Linux, Windows and AIX are supported.
``/build-id`` for lld-link on Windows). Linux, Windows, and AIX are supported.
* "%c" expands out to nothing, but enables a mode in which profile counter
updates are continuously synced to a file. This means that if the
@ -128,7 +128,7 @@ and set bias to the offset between the original and the new counter location,
at which point every subsequent counter access will be to the new location,
which allows updating profile directly akin to the continuous mode.
The advantage of this approach is that doesn't require any special OS support.
The advantage of this approach is that it doesn't require any special OS support.
The disadvantage is the extra overhead due to additional instructions required
for each counter access (overhead both in terms of binary size and performance)
plus duplication of counters (i.e. one copy in the binary itself and another
@ -137,7 +137,7 @@ other platforms by passing the ``-runtime-counter-relocation`` option to the
backend during compilation.
For a program such as the `Lit <https://llvm.org/docs/CommandGuide/lit.html>`_
testing tool which invokes other programs, it may be necessary to set
testing tool, which invokes other programs, it may be necessary to set
``LLVM_PROFILE_FILE`` for each invocation. The pattern strings "%p" or "%Nm"
may help to avoid corruption due to concurrency. Note that "%p" is also a Lit
token and needs to be escaped as "%%p".
@ -149,7 +149,7 @@ token and needs to be escaped as "%%p".
Creating coverage reports
=========================
Raw profiles have to be **indexed** before they can be used to generate
Raw profiles must be **indexed** before they can be used to generate
coverage reports. This is done using the "merge" tool in ``llvm-profdata``
(which can combine multiple raw profiles and index them at the same time):
@ -240,13 +240,13 @@ line-oriented report, try:
TOTAL 13 0 100.00% 3 0 100.00% 13 0 100.00% 12 2 83.33%
The ``llvm-cov`` tool supports specifying a custom demangler, writing out
reports in a directory structure, and generating html reports. For the full
reports in a directory structure, and generating HTML reports. For the full
list of options, please refer to the `command guide
<https://llvm.org/docs/CommandGuide/llvm-cov.html>`_.
A few final notes:
* The ``-sparse`` flag is optional but can result in dramatically smaller
* The ``-sparse`` flag is optional but can produce dramatically smaller
indexed profiles. This option should not be used if the indexed profile will
be reused for PGO.
@ -255,7 +255,7 @@ A few final notes:
information directly into an existing raw profile on disk. The details are
out of scope.
* The ``llvm-profdata`` tool can be used to merge together multiple raw or
* The ``llvm-profdata`` tool can be used to merge multiple raw or
indexed profiles. To combine profiling data from multiple runs of a program,
try e.g:
@ -299,7 +299,7 @@ There are six statistics tracked in a coverage summary:
source code that may each evaluate to either "true" or "false". These
conditions may comprise larger boolean expressions linked by boolean logical
operators. For example, "x = (y == 2) || (z < 10)" is a boolean expression
that is comprised of two individual conditions, each of which evaluates to
comprised of two individual conditions, each of which evaluates to
either true or false, producing four total branch outcomes.
* Modified Condition/Decision Coverage (MC/DC) is the percentage of individual
@ -316,7 +316,7 @@ There are six statistics tracked in a coverage summary:
``-show-mcdc-summary`` option as long as code was also compiled using the
clang option ``-fcoverage-mcdc``.
* Boolean expressions that are only comprised of one condition (and therefore
* Boolean expressions comprised of only one condition (and therefore
have no logical operators) are not included in MC/DC analysis and are
trivially deducible using branch coverage.
@ -366,7 +366,7 @@ By default the compiler runtime uses a static initializer to determine the
profile output path and to register a writer function. To collect profiles
without using static initializers, do this manually:
* Export a ``int __llvm_profile_runtime`` symbol from each instrumented shared
* Export an ``int __llvm_profile_runtime`` symbol from each instrumented shared
library and executable. When the linker finds a definition of this symbol, it
knows to skip loading the object which contains the profiling runtime's
static initializer.
@ -380,7 +380,7 @@ without using static initializers, do this manually:
to ``__llvm_profile_write_file``.
* Forward-declare ``int __llvm_profile_write_file(void)`` and call it to write
out a profile. This function returns 0 when it succeeds, and a non-zero value
out a profile. This function returns 0 on success, and a non-zero value
otherwise. Calling this function multiple times appends profile data to an
existing on-disk raw profile.
@ -418,7 +418,7 @@ Collecting coverage reports for the llvm project
================================================
To prepare a coverage report for llvm (and any of its sub-projects), add
``-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On`` to the cmake configuration. Raw
``-DLLVM_BUILD_INSTRUMENTED_COVERAGE=On`` to the CMake configuration. Raw
profiles will be written to ``$BUILD_DIR/profiles/``. To prepare an html
report, run ``llvm/utils/prepare-code-coverage-artifact.py``.
@ -429,7 +429,7 @@ To specify an alternate directory for raw profiles, use
Drawbacks and limitations
=========================
* Prior to version 2.26, the GNU binutils BFD linker is not able link programs
* Prior to version 2.26, the GNU binutils BFD linker cannot link programs
compiled with ``-fcoverage-mapping`` in its ``--gc-sections`` mode. Possible
workarounds include disabling ``--gc-sections``, upgrading to a newer version
of BFD, or using the Gold linker.

View File

@ -226,8 +226,8 @@ one-phase compilation model is simpler for build systems to implement while the
two-phase compilation has the potential to compile faster due to higher
parallelism. As an example, if there are two module units ``A`` and ``B``, and
``B`` depends on ``A``, the one-phase compilation model needs to compile them
serially, whereas the two-phase compilation model is able to be compiled as
soon as ``A.pcm`` is available, and thus can be compiled simultaneously as the
serially, whereas the two-phase compilation model can be compiled as
soon as ``A.pcm`` is available, and thus can be compiled simultaneously with the
``A.pcm`` to ``A.o`` compilation step.
File name requirements
@ -391,7 +391,7 @@ And the compilation processes for module units are like:
As the diagrams show, we need to compile the BMI from module units to object
files and then link the object files. (However, this cannot be done for the BMI
from header units. See the section on :ref:`header units <header-units>` for
more details.
more details.)
BMIs cannot be shipped in an archive to create a module library. Instead, the
BMIs(``*.pcm``) are compiled into object files(``*.o``) and those object files
@ -403,7 +403,7 @@ clang-cl
``clang-cl`` supports the same options as ``clang++`` for modules as detailed above;
there is no need to prefix these options with ``/clang:``. Note that ``cl.exe``
`options to emit/consume IFC files <https://devblogs.microsoft.com/cppblog/using-cpp-modules-in-msvc-from-the-command-line-part-1/>` are *not* supported.
The resultant precompiled modules are also not compatible for use with ``cl.exe``.
The resulting precompiled modules are also not compatible for use with ``cl.exe``.
We recommend that build system authors use the above-mentioned ``clang++`` options with ``clang-cl`` to build modules.
@ -411,7 +411,7 @@ Consistency Requirements
~~~~~~~~~~~~~~~~~~~~~~~~
Modules can be viewed as a kind of cache to speed up compilation. Thus, like
other caching techniques, it is important to maintain cache consistency which
other caching techniques, it is important to maintain cache consistency, which
is why Clang does very strict checking for consistency.
Options consistency
@ -472,8 +472,8 @@ To overcome these requirements and simplify cases like distributed builds and sa
builds, users can use the ``-fmodules-embed-all-files`` flag to embed all input files
into the BMI so that Clang does not need to open the corresponding file on disk.
When the ``-fmodules-embed-all-files`` flag are enabled, Clang explicitly emits the source
code into the BMI file, the contents of the BMI file contain a sufficiently verbose
When the ``-fmodules-embed-all-files`` flag is enabled, Clang explicitly emits the source
code into the BMI file; the BMI file contains a sufficiently verbose
representation to reproduce the original source file.
.. [1] Input files: The source files which took part in the compilation of the BMI.
@ -578,7 +578,7 @@ handle the dynamic initialization of non-inline variables in the module unit.
The importable module unit has to emit the initializer even if there is no
dynamic initialization; otherwise, the importer may call a nonexistent
function. The initializer function emits calls to imported modules first
followed by calls to all to of the dynamic initializers in the current module
followed by calls to all of the dynamic initializers in the current module
unit.
Translation units that explicitly or implicitly import a named module must call
@ -689,9 +689,9 @@ ensure it is reachable, e.g. ``using N::g;``.
As of Clang 22.x, the Reduced BMI is enabled by default. You may still want to
use Full BMI with ``-fno-modules-reduced-bmi`` in the following case:
1. Your build system uses two-phase compilation but it haven't adjusted the
1. Your build system uses two-phase compilation, but it hasn't adjusted the
implementation for reduced BMI.
2. You meet a regression with Reduced BMI that you cannot work around. Please
2. You encounter a regression with Reduced BMI that you cannot work around. Please
report an issue for this case.
Experimental Non-Cascading Changes
@ -699,7 +699,7 @@ Experimental Non-Cascading Changes
This section is primarily for build system vendors. For end compiler users,
if you don't want to read it all, this is helpful to reduce recompilations.
We encourage build system vendors and end users try this out and bring feedback.
We encourage build system vendors and end users to try this out and bring feedback.
Before Clang 19, a change in BMI of any (transitive) dependency would cause the
outputs of the BMI to change. Starting with Clang 19, changes to non-direct
@ -786,7 +786,7 @@ We encourage build systems to add an experimental mode that
reuses the cached BMI when **direct** dependencies did not change,
even if **transitive** dependencies did change.
Given there are potential compiler bugs, we recommend that build systems
Given that there are potential compiler bugs, we recommend that build systems
support this feature as a configurable option so that users
can go back to the transitive change mode safely at any time.
@ -813,7 +813,7 @@ With reduced BMI, non-cascading changes can be more powerful. For example,
$ md5sum B.pcm
6c2bd452ca32ab418bf35cd141b060b9 B.pcm
And let's change the implementation for ``A.cppm`` into:
And let's change the implementation for ``A.cppm`` to:
.. code-block:: c++
@ -830,7 +830,7 @@ and recompile the example:
$ md5sum B.pcm
6c2bd452ca32ab418bf35cd141b060b9 B.pcm
We should find the contents of ``B.pcm`` remains the same. In this case, the build system is
We should find the contents of ``B.pcm`` remain the same. In this case, the build system is
allowed to skip recompilations of TUs which solely and directly depend on module ``B``.
This only happens with a reduced BMI. With reduced BMIs, we won't record the function body
@ -845,7 +845,7 @@ Reduce duplications
While it is valid to have duplicated declarations in the global module fragments
of different module units, it is not free for Clang to deal with the duplicated
declarations. A translation unit will compile more slowly if there is a lot of
declarations. A translation unit will compile more slowly if there are a lot of
duplicated declarations between the translation unit and modules it imports.
For example:
@ -937,7 +937,7 @@ possible. However, it may be a breaking change for existing code or libraries
to switch to modules. As a result, many existing libraries need to provide
both headers and module interfaces for a while to not break existing users.
This section suggests some suggestions on how to ease the transition process
This section provides some suggestions on how to ease the transition process
for existing libraries. **Note that this information is only intended as
guidance, rather than as requirements to use modules in Clang.** It presumes
the project is starting with no module-based dependencies.
@ -1140,7 +1140,7 @@ module unit which is internal to the module itself.
Providing a header to skip parsing redundant headers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Many redeclarations shared between translation units causes Clang to have
Many redeclarations shared between translation units cause Clang to have
slower compile-time performance. Further, there are known issues with
`include after import <https://github.com/llvm/llvm-project/issues/61465>`_.
Even when that issue is resolved, users may still get slower compilation speed
@ -1408,8 +1408,8 @@ P1857R3 is implemented. This is tracked by
Until then, it is recommended not to mix macros with module declarations.
In consistent filename suffix requirement for importable module units
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Inconsistent filename suffix requirement for importable module units
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Currently, Clang requires the file name of an ``importable module unit`` to
have ``.cppm`` (or ``.ccm``, ``.cxxm``, ``.c++m``) as the file extension.
@ -1484,7 +1484,7 @@ How to build projects using header units
.. warning::
The support for header units, including related command line options, is
experimental. There are still many unanswered question about how tools
experimental. There are still many unanswered questions about how tools
should interact with header units. The details described here may change in
the future.
@ -1881,7 +1881,7 @@ Individual command line options can be specified after ``--``.
options. Note that the path to the compiler executable needs to be specified
explicitly instead of using ``clang++`` directly.
Users may want the scanner to get the transitional dependency information for
Users may want the scanner to get the transitive dependency information for
headers. Otherwise, the project has to be scanned twice, once for headers and
once for modules. To address this, ``clang-scan-deps`` will recognize the
specified preprocessor options in the given command line and generate the
@ -1912,7 +1912,7 @@ Possible Issues: Failed to find system headers
If encountering an error like ``fatal error: 'stddef.h' file not found``,
the specified ``<path-to-compiler-executable>/clang++`` probably refers to a
symlink instead a real binary. There are four potential solutions to the
symlink instead of a real binary. There are four potential solutions to the
problem:
1. Point the specified compiler executable to the real binary instead of the

View File

@ -825,13 +825,6 @@ doesn't know that munl.mu == mutex. The SCOPED_CAPABILITY attribute handles
aliasing for MutexLocker, but does so only for that particular pattern.
ACQUIRED_BEFORE(...) and ACQUIRED_AFTER(...) support is still experimental.
---------------------------------------------------------------------------
ACQUIRED_BEFORE(...) and ACQUIRED_AFTER(...) are currently being developed under
the ``-Wthread-safety-beta`` flag.
.. _mutexheader:
mutex.h

View File

@ -230,6 +230,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
SubstTemplateTypeParmTypes;
mutable llvm::FoldingSet<SubstTemplateTypeParmPackType>
SubstTemplateTypeParmPackTypes;
mutable llvm::FoldingSet<SubstBuiltinTemplatePackType>
SubstBuiltinTemplatePackTypes;
mutable llvm::ContextualFoldingSet<TemplateSpecializationType, ASTContext&>
TemplateSpecializationTypes;
mutable llvm::FoldingSet<ParenType> ParenTypes{GeneralTypesLog2InitSize};
@ -1895,6 +1897,7 @@ public:
QualType getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
unsigned Index, bool Final,
const TemplateArgument &ArgPack);
QualType getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack);
QualType
getTemplateTypeParmType(unsigned Depth, unsigned Index,

View File

@ -359,7 +359,7 @@ class CXXFinalOverriderMap
/// A set of all the primary bases for a class.
class CXXIndirectPrimaryBaseSet
: public llvm::SmallSet<const CXXRecordDecl*, 32> {};
: public llvm::SmallPtrSet<const CXXRecordDecl *, 32> {};
inline bool
inheritanceModelHasVBPtrOffsetField(MSInheritanceModel Inheritance) {

View File

@ -3526,7 +3526,7 @@ protected:
public:
// Low-level accessor. If you just want the type defined by this node,
// check out ASTContext::getTypeDeclType or one of
// ASTContext::getTypedefType, ASTContext::getRecordType, etc. if you
// ASTContext::getTypedefType, ASTContext::getTagType, etc. if you
// already know the specific kind of node this is.
const Type *getTypeForDecl() const {
assert(!isa<TagDecl>(this));

View File

@ -1796,7 +1796,10 @@ public:
}
BuiltinTemplateKind getBuiltinTemplateKind() const { return BTK; }
bool isPackProducingBuiltinTemplate() const;
};
bool isPackProducingBuiltinTemplateName(TemplateName N);
/// Provides information about an explicit instantiation of a variable or class
/// template.

View File

@ -1250,19 +1250,32 @@ public:
SourceLocation EndLoc);
};
// A structure to stand in for the recipe on a reduction. RecipeDecl is the
// 'main' declaration used for initializaiton, which is fixed.
struct OpenACCReductionRecipe {
VarDecl *RecipeDecl;
// TODO: OpenACC: this should eventually have the operations here too.
};
class OpenACCReductionClause final
: public OpenACCClauseWithVarList,
private llvm::TrailingObjects<OpenACCReductionClause, Expr *> {
private llvm::TrailingObjects<OpenACCReductionClause, Expr *,
OpenACCReductionRecipe> {
friend TrailingObjects;
OpenACCReductionOperator Op;
OpenACCReductionClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
OpenACCReductionOperator Operator,
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
ArrayRef<Expr *> VarList,
ArrayRef<OpenACCReductionRecipe> Recipes,
SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Reduction, BeginLoc,
LParenLoc, EndLoc),
Op(Operator) {
setExprs(getTrailingObjects(VarList.size()), VarList);
assert(VarList.size() == Recipes.size());
setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
llvm::uninitialized_copy(Recipes, getTrailingObjects<
OpenACCReductionRecipe > ());
}
public:
@ -1270,12 +1283,26 @@ public:
return C->getClauseKind() == OpenACCClauseKind::Reduction;
}
ArrayRef<OpenACCReductionRecipe> getRecipes() {
return ArrayRef<OpenACCReductionRecipe>{
getTrailingObjects<OpenACCReductionRecipe>(), getExprs().size()};
}
ArrayRef<OpenACCReductionRecipe> getRecipes() const {
return ArrayRef<OpenACCReductionRecipe>{
getTrailingObjects<OpenACCReductionRecipe>(), getExprs().size()};
}
static OpenACCReductionClause *
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
OpenACCReductionOperator Operator, ArrayRef<Expr *> VarList,
SourceLocation EndLoc);
ArrayRef<OpenACCReductionRecipe> Recipes, SourceLocation EndLoc);
OpenACCReductionOperator getReductionOp() const { return Op; }
size_t numTrailingObjects(OverloadToken<Expr *>) const {
return getExprs().size();
}
};
class OpenACCLinkClause final

View File

@ -492,6 +492,8 @@ private:
bool TraverseTemplateArgumentLocsHelper(const TemplateArgumentLoc *TAL,
unsigned Count);
bool TraverseArrayTypeLocHelper(ArrayTypeLoc TL);
bool TraverseSubstPackTypeHelper(SubstPackType *T);
bool TraverseSubstPackTypeLocHelper(SubstPackTypeLoc TL);
bool TraverseRecordHelper(RecordDecl *D);
bool TraverseCXXRecordHelper(CXXRecordDecl *D);
bool TraverseDeclaratorHelper(DeclaratorDecl *D);
@ -1138,9 +1140,10 @@ DEF_TRAVERSE_TYPE(TemplateTypeParmType, {})
DEF_TRAVERSE_TYPE(SubstTemplateTypeParmType, {
TRY_TO(TraverseType(T->getReplacementType()));
})
DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType, {
TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
})
DEF_TRAVERSE_TYPE(SubstTemplateTypeParmPackType,
{ TRY_TO(TraverseSubstPackTypeHelper(T)); })
DEF_TRAVERSE_TYPE(SubstBuiltinTemplatePackType,
{ TRY_TO(TraverseSubstPackTypeHelper(T)); })
DEF_TRAVERSE_TYPE(AttributedType,
{ TRY_TO(TraverseType(T->getModifiedType())); })
@ -1481,9 +1484,26 @@ DEF_TRAVERSE_TYPELOC(TemplateTypeParmType, {})
DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmType, {
TRY_TO(TraverseType(TL.getTypePtr()->getReplacementType()));
})
DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType, {
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseSubstPackTypeLocHelper(
SubstPackTypeLoc TL) {
TRY_TO(TraverseTemplateArgument(TL.getTypePtr()->getArgumentPack()));
})
return true;
}
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseSubstPackTypeHelper(
SubstPackType *T) {
TRY_TO(TraverseTemplateArgument(T->getArgumentPack()));
return true;
}
DEF_TRAVERSE_TYPELOC(SubstTemplateTypeParmPackType,
{ TRY_TO(TraverseSubstPackTypeLocHelper(TL)); })
DEF_TRAVERSE_TYPELOC(SubstBuiltinTemplatePackType,
{ TRY_TO(TraverseSubstPackTypeLocHelper(TL)); })
DEF_TRAVERSE_TYPELOC(ParenType, { TRY_TO(TraverseTypeLoc(TL.getInnerLoc())); })

View File

@ -2210,20 +2210,24 @@ protected:
unsigned PackIndex : 15;
};
class SubstTemplateTypeParmPackTypeBitfields {
class SubstPackTypeBitfields {
friend class SubstPackType;
friend class SubstTemplateTypeParmPackType;
LLVM_PREFERRED_TYPE(TypeBitfields)
unsigned : NumTypeBits;
// The index of the template parameter this substitution represents.
unsigned Index : 16;
/// The number of template arguments in \c Arguments, which is
/// expected to be able to hold at least 1024 according to [implimits].
/// However as this limit is somewhat easy to hit with template
/// metaprogramming we'd prefer to keep it as large as possible.
unsigned NumArgs : 16;
// The index of the template parameter this substitution represents.
// Only used by SubstTemplateTypeParmPackType. We keep it in the same
// class to avoid dealing with complexities of bitfields that go over
// the size of `unsigned`.
unsigned SubstTemplTypeParmPackIndex : 16;
};
class TemplateSpecializationTypeBitfields {
@ -2340,7 +2344,7 @@ protected:
VectorTypeBitfields VectorTypeBits;
TemplateTypeParmTypeBitfields TemplateTypeParmTypeBits;
SubstTemplateTypeParmTypeBitfields SubstTemplateTypeParmTypeBits;
SubstTemplateTypeParmPackTypeBitfields SubstTemplateTypeParmPackTypeBits;
SubstPackTypeBitfields SubstPackTypeBits;
TemplateSpecializationTypeBitfields TemplateSpecializationTypeBits;
DependentTemplateSpecializationTypeBitfields
DependentTemplateSpecializationTypeBits;
@ -6401,6 +6405,9 @@ protected:
bool IsInjected, const Type *CanonicalType);
public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
TagDecl *getOriginalDecl() const { return decl; }
NestedNameSpecifier getQualifier() const;
@ -6466,6 +6473,9 @@ class RecordType final : public TagType {
using TagType::TagType;
public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
RecordDecl *getOriginalDecl() const {
return reinterpret_cast<RecordDecl *>(TagType::getOriginalDecl());
}
@ -6483,6 +6493,9 @@ class EnumType final : public TagType {
using TagType::TagType;
public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
EnumDecl *getOriginalDecl() const {
return reinterpret_cast<EnumDecl *>(TagType::getOriginalDecl());
}
@ -6515,6 +6528,9 @@ class InjectedClassNameType final : public TagType {
bool IsInjected, const Type *CanonicalType);
public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
CXXRecordDecl *getOriginalDecl() const {
return reinterpret_cast<CXXRecordDecl *>(TagType::getOriginalDecl());
}
@ -6980,6 +6996,56 @@ public:
}
};
/// Represents the result of substituting a set of types as a template argument
/// that needs to be expanded later.
///
/// These types are always dependent and produced depending on the situations:
/// - SubstTemplateTypeParmPack is an expansion that had to be delayed,
/// - SubstBuiltinTemplatePackType is an expansion from a builtin.
class SubstPackType : public Type, public llvm::FoldingSetNode {
friend class ASTContext;
/// A pointer to the set of template arguments that this
/// parameter pack is instantiated with.
const TemplateArgument *Arguments;
protected:
SubstPackType(TypeClass Derived, QualType Canon,
const TemplateArgument &ArgPack);
public:
unsigned getNumArgs() const { return SubstPackTypeBits.NumArgs; }
TemplateArgument getArgumentPack() const;
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID,
const TemplateArgument &ArgPack);
static bool classof(const Type *T) {
return T->getTypeClass() == SubstTemplateTypeParmPack ||
T->getTypeClass() == SubstBuiltinTemplatePack;
}
};
/// Represents the result of substituting a builtin template as a pack.
class SubstBuiltinTemplatePackType : public SubstPackType {
friend class ASTContext;
SubstBuiltinTemplatePackType(QualType Canon, const TemplateArgument &ArgPack);
public:
bool isSugared() const { return false; }
QualType desugar() const { return QualType(this, 0); }
/// Mark that we reuse the Profile. We do not introduce new fields.
using SubstPackType::Profile;
static bool classof(const Type *T) {
return T->getTypeClass() == SubstBuiltinTemplatePack;
}
};
/// Represents the result of substituting a set of types for a template
/// type parameter pack.
///
@ -6992,7 +7058,7 @@ public:
/// that pack expansion (e.g., when all template parameters have corresponding
/// arguments), this type will be replaced with the \c SubstTemplateTypeParmType
/// at the current pack substitution index.
class SubstTemplateTypeParmPackType : public Type, public llvm::FoldingSetNode {
class SubstTemplateTypeParmPackType : public SubstPackType {
friend class ASTContext;
/// A pointer to the set of template arguments that this
@ -7018,21 +7084,17 @@ public:
/// Returns the index of the replaced parameter in the associated declaration.
/// This should match the result of `getReplacedParameter()->getIndex()`.
unsigned getIndex() const { return SubstTemplateTypeParmPackTypeBits.Index; }
unsigned getIndex() const {
return SubstPackTypeBits.SubstTemplTypeParmPackIndex;
}
// This substitution will be Final, which means the substitution will be fully
// sugared: it doesn't need to be resugared later.
bool getFinal() const;
unsigned getNumArgs() const {
return SubstTemplateTypeParmPackTypeBits.NumArgs;
}
bool isSugared() const { return false; }
QualType desugar() const { return QualType(this, 0); }
TemplateArgument getArgumentPack() const;
void Profile(llvm::FoldingSetNodeID &ID);
static void Profile(llvm::FoldingSetNodeID &ID, const Decl *AssociatedDecl,
unsigned Index, bool Final,
@ -7267,9 +7329,7 @@ public:
TemplateSpecializationTypeBits.NumArgs};
}
bool isSugared() const {
return !isDependentType() || isCurrentInstantiation() || isTypeAlias();
}
bool isSugared() const;
QualType desugar() const {
return isTypeAlias() ? getAliasedType() : getCanonicalTypeInternal();

View File

@ -989,12 +989,22 @@ class SubstTemplateTypeParmTypeLoc :
SubstTemplateTypeParmType> {
};
/// Wrapper for substituted template type parameters.
class SubstTemplateTypeParmPackTypeLoc :
public InheritingConcreteTypeLoc<TypeSpecTypeLoc,
SubstTemplateTypeParmPackTypeLoc,
SubstTemplateTypeParmPackType> {
};
/// Abstract type representing delayed type pack expansions.
class SubstPackTypeLoc
: public InheritingConcreteTypeLoc<TypeSpecTypeLoc, SubstPackTypeLoc,
SubstPackType> {};
/// Wrapper for substituted template type parameters.
class SubstTemplateTypeParmPackTypeLoc
: public InheritingConcreteTypeLoc<SubstPackTypeLoc,
SubstTemplateTypeParmPackTypeLoc,
SubstTemplateTypeParmPackType> {};
/// Wrapper for substituted template type parameters.
class SubstBuiltinTemplatePackTypeLoc
: public InheritingConcreteTypeLoc<SubstPackTypeLoc,
SubstBuiltinTemplatePackTypeLoc,
SubstBuiltinTemplatePackType> {};
struct AttributedLocInfo {
const Attr *TypeAttr;

View File

@ -820,6 +820,12 @@ let Class = PackExpansionType in {
}]>;
}
let Class = SubstPackType in {
def : Property<"replacementPack", TemplateArgument> {
let Read = [{ node->getArgumentPack() }];
}
}
let Class = SubstTemplateTypeParmPackType in {
def : Property<"associatedDecl", DeclRef> {
let Read = [{ node->getAssociatedDecl() }];
@ -827,12 +833,7 @@ let Class = SubstTemplateTypeParmPackType in {
def : Property<"Index", UInt32> {
let Read = [{ node->getIndex() }];
}
def : Property<"Final", Bool> {
let Read = [{ node->getFinal() }];
}
def : Property<"replacementPack", TemplateArgument> {
let Read = [{ node->getArgumentPack() }];
}
def : Property<"Final", Bool> { let Read = [{ node->getFinal() }]; }
def : Creator<[{
return ctx.getSubstTemplateTypeParmPackType(
@ -840,6 +841,12 @@ let Class = SubstTemplateTypeParmPackType in {
}]>;
}
let Class = SubstBuiltinTemplatePackType in {
def : Creator<[{
return ctx.getSubstBuiltinTemplatePack(replacementPack);
}]>;
}
let Class = BuiltinType in {
def : Property<"kind", BuiltinTypeKind> {
let Read = [{ node->getKind() }];

View File

@ -5661,8 +5661,8 @@ AST_POLYMORPHIC_MATCHER_P(hasInitStatement,
return Init != nullptr && InnerMatcher.matches(*Init, Finder, Builder);
}
/// Matches the condition expression of an if statement, for loop,
/// switch statement or conditional operator.
/// Matches the condition expression of an if statement, for loop, while loop,
/// do-while loop, switch statement or conditional operator.
///
/// Example matches true (matcher = hasCondition(cxxBoolLiteral(equals(true))))
/// \code
@ -5739,16 +5739,29 @@ AST_POLYMORPHIC_MATCHER_P(equalsBoundNode,
return Builder->removeBindings(Predicate);
}
/// Matches the condition variable statement in an if statement.
/// Matches a declaration if it declares the same entity as the node previously
/// bound to \p ID.
AST_MATCHER_P(Decl, declaresSameEntityAsBoundNode, std::string, ID) {
return Builder->removeBindings([&](const internal::BoundNodesMap &Nodes) {
return !clang::declaresSameEntity(&Node, Nodes.getNodeAs<Decl>(ID));
});
}
/// Matches the condition variable statement in an if statement, for loop,
/// while loop or switch statement.
///
/// Given
/// \code
/// if (A* a = GetAPointer()) {}
/// for (; A* a = GetAPointer(); ) {}
/// \endcode
/// hasConditionVariableStatement(...)
/// matches 'A* a = GetAPointer()'.
AST_MATCHER_P(IfStmt, hasConditionVariableStatement,
internal::Matcher<DeclStmt>, InnerMatcher) {
/// matches both 'A* a = GetAPointer()'.
AST_POLYMORPHIC_MATCHER_P(hasConditionVariableStatement,
AST_POLYMORPHIC_SUPPORTED_TYPES(IfStmt, ForStmt,
WhileStmt,
SwitchStmt),
internal::Matcher<DeclStmt>, InnerMatcher) {
const DeclStmt* const DeclarationStatement =
Node.getConditionVariableDeclStmt();
return DeclarationStatement != nullptr &&

View File

@ -19,14 +19,35 @@
#define LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/ADT/ImmutableMap.h"
#include "llvm/ADT/ImmutableSet.h"
#include "llvm/ADT/StringMap.h"
#include <memory>
namespace clang::lifetimes {
/// Enum to track the confidence level of a potential error.
enum class Confidence {
None,
Maybe, // Reported as a potential error (-Wlifetime-safety-strict)
Definite // Reported as a definite error (-Wlifetime-safety-permissive)
};
class LifetimeSafetyReporter {
public:
LifetimeSafetyReporter() = default;
virtual ~LifetimeSafetyReporter() = default;
virtual void reportUseAfterFree(const Expr *IssueExpr, const Expr *UseExpr,
SourceLocation FreeLoc,
Confidence Confidence) {}
};
/// The main entry point for the analysis.
void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC);
void runLifetimeSafetyAnalysis(AnalysisDeclContext &AC,
LifetimeSafetyReporter *Reporter);
namespace internal {
// Forward declarations of internal types.
@ -53,6 +74,7 @@ template <typename Tag> struct ID {
IDBuilder.AddInteger(Value);
}
};
template <typename Tag>
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, ID<Tag> ID) {
return OS << ID.Value;
@ -78,7 +100,8 @@ using ProgramPoint = const Fact *;
/// encapsulates the various dataflow analyses.
class LifetimeSafetyAnalysis {
public:
LifetimeSafetyAnalysis(AnalysisDeclContext &AC);
LifetimeSafetyAnalysis(AnalysisDeclContext &AC,
LifetimeSafetyReporter *Reporter);
~LifetimeSafetyAnalysis();
void run();
@ -87,7 +110,7 @@ public:
LoanSet getLoansAtPoint(OriginID OID, ProgramPoint PP) const;
/// Returns the set of loans that have expired at a specific program point.
LoanSet getExpiredLoansAtPoint(ProgramPoint PP) const;
std::vector<LoanID> getExpiredLoansAtPoint(ProgramPoint PP) const;
/// Finds the OriginID for a given declaration.
/// Returns a null optional if not found.
@ -110,6 +133,7 @@ public:
private:
AnalysisDeclContext &AC;
LifetimeSafetyReporter *Reporter;
std::unique_ptr<LifetimeFactory> Factory;
std::unique_ptr<FactManager> FactMgr;
std::unique_ptr<LoanPropagationAnalysis> LoanPropagation;
@ -118,4 +142,25 @@ private:
} // namespace internal
} // namespace clang::lifetimes
namespace llvm {
template <typename Tag>
struct DenseMapInfo<clang::lifetimes::internal::ID<Tag>> {
using ID = clang::lifetimes::internal::ID<Tag>;
static inline ID getEmptyKey() {
return {DenseMapInfo<uint32_t>::getEmptyKey()};
}
static inline ID getTombstoneKey() {
return {DenseMapInfo<uint32_t>::getTombstoneKey()};
}
static unsigned getHashValue(const ID &Val) {
return DenseMapInfo<uint32_t>::getHashValue(Val.Value);
}
static bool isEqual(const ID &LHS, const ID &RHS) { return LHS == RHS; }
};
} // namespace llvm
#endif // LLVM_CLANG_ANALYSIS_ANALYSES_LIFETIMESAFETY_H

View File

@ -42,6 +42,18 @@ struct ContextSensitiveOptions {
unsigned Depth = 2;
};
/// A simple representation of essential elements of the logical context used in
/// environments. Designed for import/export for applications requiring
/// serialization support.
struct SimpleLogicalContext {
// Global invariant that applies for all definitions in the context.
const Formula *Invariant;
// Flow-condition tokens in the context.
llvm::DenseMap<Atom, const Formula *> TokenDefs;
// Dependencies between flow-condition definitions.
llvm::DenseMap<Atom, llvm::DenseSet<Atom>> TokenDeps;
};
/// Owns objects that encompass the state of a program and stores context that
/// is used during dataflow analysis.
class DataflowAnalysisContext {
@ -140,6 +152,15 @@ public:
/// Adds `Constraint` to the flow condition identified by `Token`.
void addFlowConditionConstraint(Atom Token, const Formula &Constraint);
/// Adds `Deps` to the dependencies of the flow condition identified by
/// `Token`. Intended for use in deserializing contexts. The formula alone
/// doesn't have enough information to indicate its deps.
void addFlowConditionDeps(Atom Token, const llvm::DenseSet<Atom> &Deps) {
// Avoid creating an entry for `Token` with an empty set.
if (!Deps.empty())
FlowConditionDeps[Token].insert(Deps.begin(), Deps.end());
}
/// Creates a new flow condition with the same constraints as the flow
/// condition identified by `Token` and returns its token.
Atom forkFlowCondition(Atom Token);
@ -207,6 +228,14 @@ public:
return {};
}
/// Export the logical-context portions of `AC`, limited to the given target
/// flow-condition tokens.
SimpleLogicalContext
exportLogicalContext(llvm::DenseSet<dataflow::Atom> TargetTokens) const;
/// Initializes this context's "logical" components with `LC`.
void initLogicalContext(SimpleLogicalContext LC);
private:
friend class Environment;
@ -228,6 +257,11 @@ private:
DataflowAnalysisContext(Solver &S, std::unique_ptr<Solver> &&OwnedSolver,
Options Opts);
/// Computes the transitive closure of dependencies of (flow-condition)
/// `Tokens`. That is, the set of flow-condition tokens reachable from
/// `Tokens` in the dependency graph.
llvm::DenseSet<Atom> collectDependencies(llvm::DenseSet<Atom> Tokens) const;
// Extends the set of modeled field declarations.
void addModeledFields(const FieldSet &Fields);

View File

@ -157,10 +157,18 @@ public:
};
/// Creates an environment that uses `DACtx` to store objects that encompass
/// the state of a program.
/// the state of a program. `FlowConditionToken` sets the flow condition
/// associated with the environment. Generally, new environments should be
/// initialized with a fresh token, by using one of the other
/// constructors. This constructor is for specialized use, including
/// deserialization and delegation from other constructors.
Environment(DataflowAnalysisContext &DACtx, Atom FlowConditionToken)
: DACtx(&DACtx), FlowConditionToken(FlowConditionToken) {}
/// Creates an environment that uses `DACtx` to store objects that encompass
/// the state of a program. Populates a fresh atom as flow condition token.
explicit Environment(DataflowAnalysisContext &DACtx)
: DACtx(&DACtx),
FlowConditionToken(DACtx.arena().makeFlowConditionToken()) {}
: Environment(DACtx, DACtx.arena().makeFlowConditionToken()) {}
/// Creates an environment that uses `DACtx` to store objects that encompass
/// the state of a program, with `S` as the statement to analyze.

View File

@ -85,21 +85,17 @@ public:
}
using AtomNames = llvm::DenseMap<Atom, std::string>;
// Produce a stable human-readable representation of this formula.
// For example: (V3 | !(V1 & V2))
// If AtomNames is provided, these override the default V0, V1... names.
/// Produces a stable human-readable representation of this formula.
/// For example: (V3 | !(V1 & V2))
/// If AtomNames is provided, these override the default V0, V1... names.
void print(llvm::raw_ostream &OS, const AtomNames * = nullptr) const;
// Allocate Formulas using Arena rather than calling this function directly.
/// Allocates Formulas using Arena rather than calling this function directly.
static const Formula &create(llvm::BumpPtrAllocator &Alloc, Kind K,
ArrayRef<const Formula *> Operands,
unsigned Value = 0);
private:
Formula() = default;
Formula(const Formula &) = delete;
Formula &operator=(const Formula &) = delete;
/// Count of operands (sub-formulas) associated with Formulas of kind `K`.
static unsigned numOperands(Kind K) {
switch (K) {
case AtomRef:
@ -116,6 +112,11 @@ private:
llvm_unreachable("Unhandled Formula::Kind enum");
}
private:
Formula() = default;
Formula(const Formula &) = delete;
Formula &operator=(const Formula &) = delete;
Kind FormulaKind;
// Some kinds of formula have scalar values, e.g. AtomRef's atom number.
unsigned Value;

View File

@ -0,0 +1,40 @@
//=== FormulaSerialization.h - Formula De/Serialization support -*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_FORMULA_SERIALIZATION_H
#define LLVM_CLANG_ANALYSIS_FLOWSENSITIVE_FORMULA_SERIALIZATION_H
#include "clang/Analysis/FlowSensitive/Arena.h"
#include "clang/Analysis/FlowSensitive/Formula.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
#include <string>
namespace clang::dataflow {
/// Prints `F` to `OS` in a compact format, optimized for easy parsing
/// (deserialization) rather than human use.
void serializeFormula(const Formula &F, llvm::raw_ostream &OS);
/// Parses `Str` to build a serialized Formula.
/// @returns error on parse failure or if parsing does not fully consume `Str`.
/// @param A used to construct the formula components.
/// @param AtomMap maps serialized Atom identifiers (unsigned ints) to Atoms.
/// This map is provided by the caller to enable consistency across
/// multiple formulas in a single file.
llvm::Expected<const Formula *>
parseFormula(llvm::StringRef Str, Arena &A,
llvm::DenseMap<unsigned, Atom> &AtomMap);
} // namespace clang::dataflow
#endif

View File

@ -17,6 +17,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/Type.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Debug.h"
#include <cassert>
@ -152,6 +153,11 @@ public:
return {SyntheticFields.begin(), SyntheticFields.end()};
}
/// Add a synthetic field, if none by that name is already present.
void addSyntheticField(llvm::StringRef Name, StorageLocation &Loc) {
SyntheticFields.insert({Name, &Loc});
}
/// Changes the child storage location for a field `D` of reference type.
/// All other fields cannot change their storage location and always retain
/// the storage location passed to the `RecordStorageLocation` constructor.
@ -164,6 +170,11 @@ public:
Children[&D] = Loc;
}
/// Add a child storage location for a field `D`, if not already present.
void addChild(const ValueDecl &D, StorageLocation *Loc) {
Children.insert({&D, Loc});
}
llvm::iterator_range<FieldToLoc::const_iterator> children() const {
return {Children.begin(), Children.end()};
}

View File

@ -23,20 +23,20 @@
#include "clang/Basic/DiagnosticInstallAPI.h"
#include "clang/Basic/DiagnosticLex.h"
#include "clang/Basic/DiagnosticParse.h"
#include "clang/Basic/DiagnosticRefactoring.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Basic/DiagnosticSerialization.h"
#include "clang/Basic/DiagnosticRefactoring.h"
namespace clang {
template <size_t SizeOfStr, typename FieldType>
class StringSizerHelper {
template <size_t SizeOfStr, typename FieldType> class StringSizerHelper {
static_assert(SizeOfStr <= FieldType(~0U), "Field too small!");
public:
enum { Size = SizeOfStr };
};
} // end namespace clang
#define STR_SIZE(str, fieldTy) clang::StringSizerHelper<sizeof(str)-1, \
fieldTy>::Size
#define STR_SIZE(str, fieldTy) \
clang::StringSizerHelper<sizeof(str) - 1, fieldTy>::Size
#endif

View File

@ -1632,6 +1632,13 @@ def DeviceKernel : DeclOrTypeAttr {
}];
}
def SYCLExternal : InheritableAttr {
let Spellings = [CXX11<"clang", "sycl_external">];
let Subjects = SubjectList<[Function], ErrorDiag>;
let LangOpts = [SYCLHost, SYCLDevice];
let Documentation = [SYCLExternalDocs];
}
def SYCLKernelEntryPoint : InheritableAttr {
let Spellings = [CXX11<"clang", "sycl_kernel_entry_point">];
let Args = [

View File

@ -476,6 +476,47 @@ The SYCL kernel in the previous code sample meets these expectations.
}];
}
def SYCLExternalDocs : Documentation {
let Category = DocCatFunction;
let Heading = "sycl_external";
let Content = [{
The ``sycl_external`` attribute indicates that a function defined in another
translation unit may be called by a device function defined in the current
translation unit or, if defined in the current translation unit, the function
may be called by device functions defined in other translation units.
The attribute is intended for use in the implementation of the ``SYCL_EXTERNAL``
macro as specified in section 5.10.1, "SYCL functions and member functions
linkage", of the SYCL 2020 specification.
The attribute only appertains to functions and only those that meet the
following requirements:
* Has external linkage
* Is not explicitly defined as deleted (the function may be an explicitly
defaulted function that is defined as deleted)
The attribute shall be present on the first declaration of a function and
may optionally be present on subsequent declarations.
When compiling for a SYCL device target that does not support the generic
address space, the function shall not specify a raw pointer or reference type
as the return type or as a parameter type.
See section 5.10, "SYCL offline linking", of the SYCL 2020 specification.
The following examples demonstrate the use of this attribute:
.. code-block:: c++
[[clang::sycl_external]] void Foo(); // Ok.
[[clang::sycl_external]] void Bar() { /* ... */ } // Ok.
[[clang::sycl_external]] extern void Baz(); // Ok.
[[clang::sycl_external]] static void Quux() { /* ... */ } // error: Quux() has internal linkage.
}];
}
def SYCLKernelEntryPointDocs : Documentation {
let Category = DocCatFunction;
let Content = [{

Some files were not shown because too many files have changed in this diff Show More