Commit Graph

543579 Commits

Author SHA1 Message Date
Thomas Hashem
18a0675082 [bazel] Add gdb-scripts filegroup in llvm and mlir (#146358)
This would be useful if downstream projects want to use the provided
pretty printers
2025-06-30 09:06:58 -07:00
Jonas Devlieghere
16dc6f64de [lldb] Document MCP support in LLDB (#145935)
Document how to use MCP support in LLDB. I expect this to change
significantly as the feature matures. For now it covers configuring the
server and two example clients.
2025-06-30 09:01:15 -07:00
James Y Knight
25e5010a30 [lldb] Delete unused variables in TestLoongArchEmulator.cpp.
These were introduced by d7e23bef6a
"[lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server"
2025-06-30 11:54:36 -04:00
Eric
4aaab69314 [libc++] Fix wait_on_destruct.pass.cpp hanging sometimes (#146240)
This test was deadlocking on my machine. 

It seems to me the intention of `in_async.wait(...)` was to wait for the
value to be set to true, which requires a call of `wait(false)` (waits
if value matches argument).

~As a drive by change scoped_lock to unique_lock, since there shouldn't
be any functional difference between the two in this test.~

I've addressed the issues with the `in_async` by switching to a
condition variable instead, since my first attempt at fixing this with
`in_async` wasn't sufficient.
2025-06-30 11:54:12 -04:00
Philip Reames
199c6ecb5c [RISCV] Add coverage for missed scalarization of gather/scatter base pointers 2025-06-30 08:42:52 -07:00
Chuanqi Xu
8a5b97a720 Revert "[clang] [modules] Add err_main_in_named_module (#146247)"
This reverts commit 473769ec9b.

It breaks test in libc++

See https://github.com/llvm/llvm-project/pull/146247
2025-06-30 23:22:31 +08:00
Nikita Popov
545cdca488 [SCCP] Improve worklist management (#146321)
SCCP currently stores instructions whose lattice value has changed in a
worklist, and then updates their users in the main loop. This may result
in instructions unnecessarily being visited multiple times (as an
instruction will often use multiple other instructions). Additionally,
we'd often redundantly visit instructions that were already visited when
the containing block first became executable.

Instead, change the worklist to directly store the instructions that
need to be revisited. Additionally, do not add instructions to the
worklist that will already be covered by the main basic block walk.

This change is conceptually NFC, but is expected to produce minor
differences in practice, because the visitation order interacts with the
range widening limit.
2025-06-30 17:17:30 +02:00
Luke Lau
6f7370ced6 [InstCombine] Pull vector reverse through fneg (#146349)
This follows on from
https://github.com/llvm/llvm-project/pull/144933#issuecomment-2992372627,
and allows us to remove the reverse (fneg (reverse x)) combine.

A separate patch will handle the case for fabs. I haven't checked if we
perform this canonicalization for either unops or binops for vp.reverse
2025-06-30 16:15:04 +01:00
Mircea Trofin
425359a83d [experimental] Ask copilot to check perf profile degradation (#146271)
We can optionally add copilot as a reviewer. As per
[documentation](https://docs.github.com/en/copilot/how-tos/agents/copilot-code-review/using-copilot-code-review#customizing-copilots-reviews-with-custom-instructions),
we can customize the review. This PR asks it to pay attention to the
kind of code that might corrupt performance data, or, in the case of
sample profiling, result in poor profiles by dropping debug info.
2025-06-30 08:09:28 -07:00
Timm Baeder
00cdaa5c39 [clang][bytecode] Add Descriptor::hasTrivialDtor() (#146286)
We sometimes used to have a long list of 

```
  GetLocalPtr
  PopPtr
  [...]
```

ops at the end of scopes, because we first got a pointer to a local
variable and only then did we figure out that we didn't actually want to
call the destructor for it. Add a new function that allows us to just
ask the `Descriptor` whether we need to call its destructor.
2025-06-30 16:59:57 +02:00
Prajwal Nadig
53102a395f [ExtractAPI] Format pointer types correctly (#146182)
Pointer types in function signatures must place the asterisk before the
identifier without a space in between. This patch removes the space and
also ensures that pointers to pointers are formatted correctly.

rdar://131780418
rdar://154533037
2025-06-30 08:55:35 -06:00
Devon Loehr
5ab3114bd1 Expand annotation check for -Wunique-object-duplication on Windows. (#145944)
Since dllexport/dllimport annotations don't propagate the same way as
visibility, the unique object duplication warning needs to check both
the object in question and its containing class. Previously, we
restricted this check to static data members, but it applies to all
objects inside a class, including functions. Not checking functions
leads to false positives, so remove that restriction.
2025-06-30 10:51:04 -04:00
Simon Pilgrim
c00c5a3898 [X86] Add test coverage to show failure to push freeze through CTLZ/CTTZ nodes (+ZERO_UNDEF variants)
Helps with nvtpx regression #145939
2025-06-30 15:48:40 +01:00
Jonathan Marriott
44ec3e8f9c [clang][AST] Fix AST IgnoreUnlessSpelledInSource traversal nullptr dereference (#146103)
In summary dumping a `catch(...)` statement using
IgnoreUnlessSpelledInSource AST traversal causes a seg fault, as the
variable declaration of the catch is `nullptr`.

Diagnosed the cause by attaching the debugger to `clang-query`, this PR
adds a fix to check for `nullptr` before accessing the `isImplicit()`
method of the `Decl` pointee in the AST node traverser visitor

Fixes #146101
2025-06-30 10:48:26 -04:00
Samarth Narang
1cdc7f8724 [clang] [Sema] Suggest [[noreturn]] for void functions that always throw (#146234)
Implements https://github.com/llvm/llvm-project/issues/146223.
2025-06-30 10:46:51 -04:00
Rahul Joshi
d1ba2692ee [LLVM][Clang] Enable strict mode for getTrailingObjects (#144930)
Disallow calls to templated `getTrailingObjects` if there is a single
trailing type (strict mode). Add `getTrailingObjectsNonStrict` for cases
when it's not possible to know statically if there will be a single or
multiple trailing types (like in OpenMPClause.h) to bypass the struct
checks.

This will ensure that future users of TrailingObjects class do not
accidently use the templated `getTrailingObjects` when they have a
single trailing type.
2025-06-30 07:23:34 -07:00
Rahul Joshi
b0ff473340 [LLVM] Change ModulePass::skipModule to take a const reference (#146168)
Change `ModulePass::skipModule` to take const Module reference.
Additionally, make `OptPassGate::shouldRunPass` const as well as for
most implementations it's a const query. For `OptBisect`, make
`LastBisectNum` mutable so it could be updated in `shouldRunPass`.

Additional minor cleanup: Change all StringRef arguments to simple
StringRef (no const or reference), change `OptBisect::Disabled` to
constexpr.
2025-06-30 07:23:04 -07:00
Ross Brunton
67e73ba605 [Offload] Refactor device/platform info queries (#146345)
This makes several small changes to how the platform and device info
queries are handled:
* ReturnHelper has been replaced with InfoWriter which is more explicit
  in how it is invoked.
* InfoWriter consumes `llvm::Expected` rather than values directly, and
  will early exit if it returns an error.
* As a result of the above, `GetInfoString` now correctly returns errors
  rather than empty strings.
* The host device now has its own dedicated "getInfo" function rather
  than being checked in multiple places.
2025-06-30 15:00:43 +01:00
Ramkumar Ramachandra
619f7afd71 [LAA] Clean up APInt-overflow related code (#140048)
Co-authored-by: Florian Hahn <flo@fhahn.com>
2025-06-30 14:48:56 +01:00
AZero13
8c77191835 [InstCombine] smin(smax(X, -1), 1) -> scmp(X, 0) and smax(smin(X, 1), -1) -> scmp(X, 0) (#145736)
Motivating case: https://godbolt.org/z/Wxcc51jcj

Alive2: https://alive2.llvm.org/ce/z/-bPPAg
2025-06-30 15:44:37 +02:00
Joseph Huber
10445acfa6 [libc] Efficiently implement 'realloc' for AMDGPU devices (#145960)
Summary:
Now that we have `malloc` we can implement `realloc` efficiently. This
uses the known chunk sizes to avoid unnecessary allocations. We just
return nullptr for NVPTX. I'd remove the list for the entrypoint but
then the libc++ code would stop working. When someone writes the NVPTX
support this will be trivial.
2025-06-30 08:39:40 -05:00
dlav-sc
d7e23bef6a [lldb][RISCV] fix LR/SC atomic sequence handling in lldb-server (#146072)
lldb-server had limited support for single-stepping through the lr/sc
atomic sequence. This patch enhances that support for all possible
atomic sequences.

The previous version contained an incorrect regex pattern in the test,
causing the riscv-specific test to run on other platforms. This reland
fixes the regex (see lldb/test/API/riscv/step/TestSoftwareStep.py)
2025-06-30 16:27:44 +03:00
Erich Keane
a99fee6989 [OpenACC][CIR] Implement 'exit data' construct + clauses (#146167)
Similar to 'enter data', except the data clauses have a 'getdeviceptr'
operation before, so that they can properly use the 'exit' operation
correctly. While this is a touch awkward, it fits perfectly into the
existing infrastructure.

Same as with 'enter data', we had to add some add-functions for async
and wait.
2025-06-30 06:19:43 -07:00
Matheus Izvekov
51dfe28f87 [clang] odr-checker fix for conversion operators (#146153)
This fixes an issue with the ODR checker not using the as-written type
of conversion operators.

The odr-checker in general should not have to deal with canonical types,
as its purpose is to compare same definitions across TUs, and these need
to be same as written, with few exceptions.

Using canonical types is specially problematic when expressions are
involved, as the types which refer to them generally pick an arbitrary
representative expression, and this can lead to false mismatches.

This patch makes sure that when hashing the names of declarations, if a
DeclarationNameInfo is available, its type source info is used, instead
of the type contained in the DeclarationName, which otherwise is always
canonical.

This patch supersedes #144796, as it fixes the problem without weakening
the ODR checker.

Fixes https://github.com/llvm/llvm-project/issues/143152
2025-06-30 10:19:29 -03:00
Ramkumar Ramachandra
d4fdfc3aa7 [DA] Improve code in getSplitIteration (NFC) (#146137)
Prefer early-continue over deeply nested loops.
2025-06-30 13:50:19 +01:00
Nikita Popov
183acdd279 [GlobalOpt] Revert global widening transform (#144652)
Partially reverts e37d736def.

The transform has a number of correctness and code quality issues, and
will benefit from a from-scratch re-review more than incremental fixes.

The correctness issues are hinted at in
https://github.com/llvm/llvm-project/pull/144641, but I think it needs a
larger rework to stop working on ArrayTypes and the implementation could
use some other improvements (like callInstIsMemcpy should just be
`dyn_cast<MemCpyInst>`). I can comment in more detail on a resubmission
of the patch.
2025-06-30 14:48:37 +02:00
Luke Lau
f01a7936be [VPlan] Replace all uses of VF when EVL tail folding. NFCI (#146339)
With EVL tail folding, any use of the VF live in should be replaced by
the EVL. Otherwise, it should likely be directly emitted as a constant
via VPTransformState::VF.

This strengthens the EVL transformation by replacing all uses of VF with
EVL and asserting that the only users are VPVectorEndPointerRecipe and
VPScalarIVStepsRecipe, the latter of which is new.

This should be NFC because even though we didn't previously replace the
EVL of VPScalarIVStepsRecipe, it's only used when unrolling which we
don't allow with EVL tail folding yet.
2025-06-30 13:47:38 +01:00
Ramkumar Ramachandra
652630b3c9 [ISel/RISCV] Fix fixed-vector [l]lrint lowering (#145898)
Make the fixed-vector lowering of ISD::[L]LRINT use the custom-lowering
routine, lowerVectorXRINT, and fix issues in lowerVectorXRINT related to
this new functionality.
2025-06-30 13:44:34 +01:00
Simon Pilgrim
b9e4679976 [DAG] canCreateUndefOrPoison - add handling for ADD/SUB/MUL overflow nodes (#146322)
Neither the arithmetic value or overflow result can create undef/poison from regular operands values.

We have complete test coverage for all ADDO/SUBO nodes, 32-bit codegen handles the _CARRY variants but until #145939 lands AND DAGCombiner::visitFREEZE handles multiple results we can't see any codegen change.

Pulled out of #145939
2025-06-30 13:26:57 +01:00
zhaohui
eb1a80bfd3 [DAG] Implement SDPatternMatch m_SpecificScalarVT and m_SpecificVectorElementVT matchers (#144996)
Resolves https://github.com/llvm/llvm-project/issues/144477

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-06-30 13:26:00 +01:00
Shilei Tian
749c7c5dc4 [AMDGPU] Add support for v_cvt_f16_bf8 on gfx1250 (#146305)
Co-authored-by: Mekhanoshin, Stanislav <Stanislav.Mekhanoshin@amd.com>
2025-06-30 07:54:55 -04:00
Shilei Tian
a99c964d7f [AMDGPU] Add support for v_cvt_f16_fp8 on gfx1250 (#146302)
Co-authored-by: Mekhanoshin, Stanislav <Stanislav.Mekhanoshin@amd.com>
2025-06-30 07:51:00 -04:00
LLVM GN Syncbot
e810c639fe [gn build] Port f8cb7987c6 2025-06-30 11:31:31 +00:00
Nico Weber
a4647b21f2 [gn] port b42c8831d5 2025-06-30 13:31:17 +02:00
Orlando Cazalet-Hyams
b29fea6eeb [KeyInstr][Clang][NFC] Don't set -dwarf-use-key-instructions (#144115)
Now PR 144104 has landed the flag is true by default (each DISubprogram tracks
whether or not it's using key instructions).
2025-06-30 12:30:35 +01:00
Orlando Cazalet-Hyams
be75ded3fe [KeyInstr][Clang] Copy ctor/assignment operator source atoms (#144346) 2025-06-30 12:27:44 +01:00
Ross Brunton
003145d0c8 [Offload] Implement olShutDown (#144055)
`olShutDown` was not properly calling deinit on the platforms, resulting
in random segfaults on AMD devices.

As part of this, `olInit` and `olShutDown` now alloc and free the
offload context rather than it being static. This
allows `olShutDown` to be called within a destructor of a static object
(like the tests do) without having to worry about destructor ordering.
2025-06-30 12:14:00 +01:00
Nikita Popov
6e6c61d696 [InstCombine] Add explicit data layout to test
To avoid the dependence on the SystemZ target. What is relevant here
is a data layout with preferred alignment for i8.
2025-06-30 13:09:18 +02:00
Yanzuo Liu
7a3e555353 [Clang][Sema] Require BaseClass:: (not other classes) in member using-declaration in C++98 mode (#143492)
[CWG400](https://wg21.link/cwg400) rejects member using-declaration
whose nested-name-specifier doesn't refer to a base class of the current
class.

```cpp
struct A {};
struct B {
  using B::A; // error
};
```

Clang didn't reject this case in C++98 mode. This patch fixes this
issue.
2025-06-30 19:00:52 +08:00
Donát Nagy
c3f8dd1228 [NFC][analyzer] Use %clang_analyze_cc1 consistently (#145895)
A large majority of the LIT tests of the clang static analyzer use RUN
lines with the placeholder `%clang_analyze_cc1` which expands to
`%clang_cc1 -analyze -setup-static-analyzer` where the only effect of
`-setup-static-analyzer` is that it ensures that the macro
`__clang_analyzer__` is defined. However, there were some tests that
used `%clang_cc1 -analyze` directly; this commit changes those to using
`%clang_analyze_cc1` for the sake of consistency.

Previously `%clang_analyze_cc1` did not work within the directory
`exploded-graph-rewriter` (because that directory has its own custom
`lit.local.cfg`) but this problem was eliminated by the recent commit
40cc4379cd, so it was possible to resolve
and delete the FIXME comments asking for this change.

There are a few tests that use `%clang --analyze` or other command-line
flags (e.g. help flags), those are not affected by this change.

This cleanup was discussed in the discourse thread
https://discourse.llvm.org/t/taking-ownership-of-clang-test-analysis/84689/11
2025-06-30 12:59:51 +02:00
Nikita Popov
3a7d60860d [FatLTO] Relax checks for fatlto pipeline test
EmbedBitcodePass now reports that it modified the IR, so there
are more analysis invalidations in between. Convert CHECK-NEXT
to CHECK.
2025-06-30 12:59:25 +02:00
Chuanqi Xu
5186d4aeee [NFC] [clang] Fix a test regression 2025-06-30 18:56:29 +08:00
Kerry McLaughlin
33c8d5c686 [Clang][AArch64] Add FP8 variants of Neon store intrinsics (#145346)
Adds FP8 variants for existing VST1, VST2, VST3 & VST4 intrinsics.
2025-06-30 11:30:46 +01:00
amilendra
a72a0f415d [Clang][AArch64] Add mfloat8_t variants of Neon load intrinsics (#145666)
Add mfloat8_t support for the following Neon load intrinsics.

- VLD1
- VLD1_X2
- VLD1_X3
- VLD1_X4
- VLD1_LANE
- VLD1_DUP
- VLD2
- VLD3
- VLD4
- VLD2_DUP
- VLD3_DUP
- VLD4_DUP
- VLD2_LANE
- VLD3_LANE
- VLD4_LANE
2025-06-30 11:19:14 +01:00
amilendra
5e732c09b2 [CLANG][AArch64] Add mfloat8_t support for more SVE load intrinsics (#145383)
Add mfloat8_t support for the following SVE load intrinsics.

- SVLD1RO
- SVLD1RQ
- SVLDFF1
- SVLDFF1_VNUM
- SVLDNF1
- SVLDNF1_VNUM
2025-06-30 11:18:50 +01:00
Nikita Popov
d7a3bdffb9 [PassBuilder][FatLTO] Expose FatLTO pipeline via pipeline string (#146048)
Expose the FatLTO pipeline via `-passes="fatlto-pre-link<Ox>"`, similar
to all the other optimization pipelines. This is to allow reproducing it
outside clang. (Possibly also useful for C API users.)
2025-06-30 12:04:42 +02:00
Guy David
f4128428af [PHIElimination] Fix bug around $noreg assignment (#146320)
PR which introduced the bug:
https://github.com/llvm/llvm-project/pull/131837.
Fixes a crash around dead registers which started in f5c62ee0fa by
verifying that the reused incoming register is also virtual.
2025-06-30 12:59:12 +03:00
Nikita Popov
de6b8cdc41 [EarlyCSE] Add support for writeonly call CSE (#145474)
Add support for CSE of writeonly calls, similar to the existing support
for readonly calls.
2025-06-30 11:56:32 +02:00
Garvit Gupta
f8cb7987c6 [RISCV] Integrate RISCV target in baremetal toolchain object and deprecate RISCVToolchain object (#121831)
This patch:
- Adds CXXStdlib, runtimelib defaults for riscv target to
  BareMetal toolchain object.
- Set the unwindlib to None for riscv target to match the
   behavior of RISCVToolChain.
- Removes call to RISCVToolChain object from llvm.

This PR is last patch in the series of patches of merging RISCVToolchain
object into BareMetal toolchain object.

RFC:
https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524
2025-06-30 15:18:21 +05:30
Michael Buch
24fd3437c3 [lldb][test] TestMetadataRegisters.py: add missing include
The macOS Clang-17 matrix bot was failing with:
```
07:33:28  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/macosx/lc-note/additional-registers/add-lcnote.cpp:79:12: error: implicit instantiation of undefined template 'std::vector<unsigned char>'
07:33:28     79 |     payload.resize(payload_str->size(), 0);
07:33:28        |            ^
07:33:28  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1706_build/include/c++/v1/iosfwd:133:28: note: template is declared here
07:33:28    133 | class _LIBCPP_TEMPLATE_VIS vector;
07:33:28        |                            ^
07:33:28  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/macosx/lc-note/additional-registers/add-lcnote.cpp:80:19: error: implicit instantiation of undefined template 'std::vector<unsigned char>'
07:33:28     80 |     memcpy(payload.data(), payload_str->c_str(), payload_str->size());
07:33:28        |                   ^
07:33:28  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1706_build/include/c++/v1/iosfwd:133:28: note: template is declared here
07:33:28    133 | class _LIBCPP_TEMPLATE_VIS vector;
07:33:28        |                            ^
07:33:28  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/llvm-project/lldb/test/API/macosx/lc-note/additional-registers/add-lcnote.cpp:87:12: error: implicit instantiation of undefined template 'std::vector<unsigned char>'
07:33:28     87 |     payload.resize(sb.st_size, 0);
07:33:28        |            ^
07:33:28  /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-matrix/clang_1706_build/include/c++/v1/iosfwd:133:28: note: template is declared here
07:33:28    133 | class _LIBCPP_TEMPLATE_VIS vector;
```
2025-06-30 10:46:17 +01:00