560185 Commits

Author SHA1 Message Date
Daniel Sanders
6ff15f4b71
[lldb] Configure pyright to the documented minimum python version (#162952)
Pyright is an MIT-licensed static type checker and can be found at
    https://github.com/microsoft/pyright
there are also various integrations to use it as an LSP server in
various editors which is the main way I use it.

It's useful on our python scripts to detect issues such as where
functions are called with unexpected types or it's possible to access
obj.attr on an object that doesn't have that attribute. It can be used
without any configuration this config setting causes it to also report
issues with type hints that do not meet our python 3.8 minimum such as
this one from dap_server.py:
```
        init_commands: list[str],
```
subscripting the builtin type like that requires python 3.9 while the
3.8 equivalent is:
```
from typing import List
...
        init_commands: List[str],
```
In practice these scripts still work on 3.8 because type hints aren't
normally evaluated during normal execution but since we have a minimum,
we should fully comply with it.

Note: The error pyright reports for this particular issue isn't great:
```
error: Subscript for class "list" will generate runtime exception; enclose type expression in quotes
```
This is technically correct as it is possible to evaluate type hints at
runtime but I believe anything that would do so would also evaluate the
string form as well and still hit the runtime exception. A better
suggestion in this case would have been the 3.8 compatible `List[str]`.
However, it is better than silently passing code that doesn't confirm to
the minimum.
2025-11-20 10:30:22 -08:00
Mehdi Amini
4100845126 [MLIR] Apply clang-tidy fixes for llvm-qualified-auto in ValueBoundsOpInterface.cpp (NFC) 2025-11-20 10:27:39 -08:00
David Stone
bfbd191f35
[mlir] Replace llvm::OwningArrayRef with std::vector (#168803)
There are several places where we use `llvm::OwningArrayRef`. The
interface to this requires us to first construct temporary storage, then
allocate space and set the allocated memory to 0, then copy the values
we actually want into that memory, then move the array into place.
Instead we can just do it all inline in a single pass by using
`std::vector`. In one case we actually allocate a completely separate
container and then allocate + copy the data over because
`llvm::OwningArrayRef` does not (and can't) support `push_back`.

Note that `llvm::SmallVector` is not a suitable replacement here because
we rely on reference stability on move construction: when the outer
container reallocates, we need the the contents of the inner containers
to be fixed in memory, and `llvm::SmallVector` does not give us that
guarantee.
2025-11-20 11:23:12 -07:00
Craig Topper
01e5e4fd00
[DAGCombiner] Remove unneeded m_BitReverse from visitBITREVERSE. NFC (#168918)
We already know we're looking at BITREVERSE, we can match on the source
operand.
2025-11-20 18:20:47 +00:00
Aiden Grossman
6d52efca67
[Github] Error on HTTP 4xx Errors (#168919)
When downloading bazelisk/buildifier, we use curl, which still returns
exit code zero on HTTP 4xx errors unless we pass --fail. This patch adds
--fail flags so that error messages are more clear.
2025-11-20 10:16:09 -08:00
Matt Arsenault
e79c7c18d6
AMDGPU: Handle invariant loads when considering if a load can be scalar (#168787) 2025-11-20 13:07:23 -05:00
Jacob Lalonde
62deee4159
[LLDB] Add a child property to compliment the existing parent property (#168619)
I've been working on some scripts that evaluate the parent and child
frame. It's been very annoying that the parent frame has a property but
not the child. So I've added this to the extensions, I would've
preferred to return None, but because the existing impl returns an
invalid SBFrame, so I'm conforming to that API.

```
(lldb) script
Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
>>> lldb.frame
frame #0: 0x0000555555555200 fib.out`main
>>> lldb.frame.parent
frame #1: 0x00007ffff782a610 libc.so.6`__libc_start_call_main + 128
>>> lldb.frame.parent.child
frame #0: 0x0000555555555200 fib.out`main
```
2025-11-20 18:05:19 +00:00
Michael Buch
f1630814ad
[llvm][dsymutil][test] Create dedicated AArch64 directory (#168895)
Currently the tests for LLVM targets `AArch64` and `ARM` were in the
same directory. But if you only configured LLVM for one target (e.g.,
just `AArch64`, which is how I ran into this), then all tests under the
ARM directory are marked `UNSUPPORTED`.

This patch moves all the tests that are capable of running on
`AArch64`-only targets into a dedicated `AArch64` directory. The tests
that expected a plain `ARM` target were kept in the `ARM` directory.

Drive-by:
* Rename the `dummy-debug-map-amr64.map` to `dummy-debug-map-arm64.map`
(note the typo in `amr64`)
2025-11-20 17:53:34 +00:00
Michael Buch
e96cc99687
[llvm][DebugInfo] Unwrap template parameters that are typedefs when reconstructing DIE names (#168734)
Depends on: 
* https://github.com/llvm/llvm-project/pull/168725

When compiling with `-glldb`, we repoint the `DW_AT_type` of a DIE to be
a typedef that refers to the `preferred_name`. I.e.,:
```
template <typename T> structure t7;
using t7i = t7<int>;
template <typename T> struct __attribute__((__preferred_name__(t7i))) t7 {};
template <typename... Ts> void f1()

int main() { f1<t7i>(); }
```
would produce following (minified) DWARF:
```
DW_TAG_subprogram
  DW_AT_name      ("_STN|f1|<t7<int> >")
  DW_TAG_template_type_parameter
    DW_AT_type  (0x0000299c "t7i")
...
DW_TAG_typedef
  DW_AT_type      (0x000029a7 "t7<int>")
  DW_AT_name      ("t7i")
```

Note how the `DW_AT_type` of the template parameter is a typedef itself
(instead of the canonical type). The `DWARFTypePrinter` would take the
`DW_AT_name` of this typedef when reconstructing the name of `f1`, so we
would end up with a verifier failure:
```
error: Simplified template DW_AT_name could not be reconstituted:
         original: f1<t7<int> >
    reconstituted: f1<t7i>
```

Fixing this allows us to un-XFAIL the `simplified-template-names.cpp`
test in `cross-project-tests`. Unfortunately this is only tested on
Darwin, where LLDB tuning is the default. AFAIK, there is no other case
where the template parameter type wouldn't be canonical.
2025-11-20 17:49:53 +00:00
Igor Kudrin
ccdb71932a
[lldb] Fix a test if hardware breakpoints are not supported (#168813)
If `HardwareBreakpointTestBase.supports_hw_breakpoints()` returns False,
`SimpleHWBreakpointTest.does_not_support_hw_breakpoints()` returns None,
so the test runs and fails. However, it should be skipped instead.

The test was added in #146602, while `supports_hw_breakpoints()` was
changed in #146609, which was landed earlier despite having a bigger
number.
2025-11-20 09:45:54 -08:00
Alex Duran
66ddc9b3e7
[OFFLOAD] Add support for more fine grained debug messages control (#165416)
This PR introduces new debug macros that allow a more fined control of
which debug message to output and introduce C++ stream style for debug
messages.

Changing existing messages (except a few that I changed for testing)
will come in subsequent PRs.

I also think that we should make debug enabling OpenMP agnostic but, for
now, I prioritized maintaing the current libomptarget behavior for now,
and we might need more changes further down the line as we we decouple
libomptarget.
2025-11-20 18:39:56 +01:00
Jordan Rupprecht
a07024080a
[bazel][LoongArch] Port #168129: tablegen for sdnode (#168907) 2025-11-20 11:29:00 -06:00
Nico Weber
4aee501b0e [gn] port c9f573463ebd (TargetLibraryInfo.inc) 2025-11-20 12:24:18 -05:00
Matt Arsenault
0e1cb2de90
Reapply "DAG: Allow select ptr combine for non-0 address spaces" (#168292) (#168786)
This reverts commit 6d5f87fc4284c4c22512778afaf7f2ba9326ba7b.

Previously this failed due to treating the unknown MachineMemOperand
value as known uniform.
2025-11-20 12:13:46 -05:00
Eugene Epshteyn
7ca737d632
[flang] Switch select-case-statement.f90 to new lowering (#168754)
test/Lower/select-case-statement.f90 was still using the old lowering.
Modified the test with FIR generated using the new lowering. Changed the
test to use flang_fc1 instead of bbc and added testing for -O0 and -O1,
since character comparison lowering is done differently at -O0 (uses
runtime function) and -O1 (inlines some cases). Use different FileCheck
prefixes for different optimization levels (CHECK-O0 for -O0, CHECK-O1
for -O1, CHECK for both).
2025-11-20 11:44:58 -05:00
Ramkumar Ramachandra
602fa0c7ce
[SDAG] Fix whitespace errors (NFC) (#168897)
To make life easier for future contributors. Note that formatting
changes are due to git clang-format on the touched whitespace-error
lines.
2025-11-20 16:44:31 +00:00
Jay Foad
6ce4794c54
[AMDGPU] Precommit tests for V_CVT_PK_[IU]16_F32 (#168893) 2025-11-20 16:43:00 +00:00
Kavin Gnanapandithan
6c79cc7ff7
[X86] Lower mathlib call ldexp into scalef when avx512 is enabled (#166839)
Resolves #165694
2025-11-20 16:39:45 +00:00
Mircea Trofin
b9d98110e1
[profcheck] Exclude naked, asm-only functions from profcheck (#168447)
We can't do anything meaningful to such functions: they aren't optimizable, and even if inlined, they would bring no code open to optimization.
2025-11-20 08:32:57 -08:00
Amr Hesham
5b8656ccb1
[CIR] ExtVectorElementExpr with rvalue base (#168260)
Upstream ExtVectorElementExpr with rvalue base
2025-11-20 17:13:49 +01:00
Matt Arsenault
d3c3c6bab5
AMDGPU: Fix treating divergent loads as uniform (#168785)
Avoids regression which caused the revert 6d5f87fc42.

This is a hack on a hack. We currently have isUniformMMO,
which improperly treats unknown source value as known uniform.
This is hack from before we had divergence information in the
DAG, and should be removed. This is the minimum change to avoid
the regression; removing the aggressive handling of the unknown
case (or dropping isUniformMMO entirely) are more involved fixes.
2025-11-20 11:10:24 -05:00
Mikhail Gudim
53b26971f5
[RISCV] Do not write .s file in a test (#168865) 2025-11-20 11:08:56 -05:00
Florian Hahn
67e35bbebb
[LV] Check full partial reduction chains in order. (#168036)
https://github.com/llvm/llvm-project/pull/162822 added another
validation step to check if entries in a partial reduction chain have
the same scale factor. But the validation was still dependent on the
order of entries in PartialReductionChains, and would fail to reject
some cases (e.g. if the first first link matched the scale of the second
link, but the second link is invalidated later).

To fix that, group chains by their starting phi nodes, then perform the
validation for each chain, and if it fails, invalidate the whole chain
for the phi.

Fixes https://github.com/llvm/llvm-project/issues/167243.
Fixes https://github.com/llvm/llvm-project/issues/167867.

PR: https://github.com/llvm/llvm-project/pull/168036
2025-11-20 15:54:57 +00:00
Aiden Grossman
b725bdba1f
Reapply "[compiler-rt] Default to Lit's Internal Shell (#168232)" (#168760)
This reverts commit eb20b5392599996ce94e4c0392095cacaa33687c.

This relands the compiler-rt internal shell after XRay and Darwin tests
that were failing under the internal shell have been fixed.
2025-11-20 07:51:33 -08:00
Joel E. Denny
21fedcbf89
[LoopPeel] Fix BFI when peeling last iteration without guard (#168250)
LoopPeel sometimes proves that, when reached, the original loop always
executes at least two iterations. LoopPeel then unconditionally executes
both the remaining loop's initial iteration and the peeled final
iteration. But that increases the latter's frequency above its frequency
in the original loop. To maintain the total frequency, this patch
compensates by decreasing the remaininng loop's latch probability.

This is another step in issue #135812 and was discussed at
<https://github.com/llvm/llvm-project/pull/166858#discussion_r2528968542>.
2025-11-20 10:45:53 -05:00
Kai Nacke
0c085c43a1
Fix build breakage when using modules (#168883)
Commit c9f573463ebd7b4e46da4877802f2364f700e54a removed the file
TargetLibraryInfo.def but did not remove it from the module map.
2025-11-20 10:40:19 -05:00
Sergei Barannikov
b5812c0cf7
[LoongArch] TableGen-erate SDNode descriptions (#168129)
This allows SDNodes to be validated against their expected type profiles
and reduces the number of changes required to add a new node.

I had to split `VSHUF4I` into two variants (`VSHUF4I` and `VSHUF4I_D`)
since `loongarch_vshuf4i` and `loongarch_vshuf4i_d` have different
number of operands, and this prevented the node from being imported.

There is just one node that currently fails validation, see
`LoongArchSelectionDAGInfo::verifyTargetNode()`.

Part of #119709.

Pull Request: https://github.com/llvm/llvm-project/pull/168129
2025-11-20 15:29:46 +00:00
David Tenty
bb0a95d5b1 [CMake] handle the AIX form of the lto cache dir option (#168868)
This handles the AIX form of the thinLTO cache dir option, which get's
turned on when thinLTO is enabled.
2025-11-20 15:27:45 +00:00
Igor Wodiany
891b3cf63e
[mlir][spirv] Add support for SwitchOp (#168713)
The dialect implementation mostly copies the one of `cf.switch`, but
aligns naming to the SPIR-V spec.
2025-11-20 15:19:10 +00:00
Craig Topper
0e54667672
[CodeGen] Use MCRegister in MachineBasicBlock::liveout_iterator. NFC (#168834)
MachineBasicBlock::liveout_begin() calls this constructor with
MCRegisters so this removes an implicit cast.
2025-11-20 07:09:00 -08:00
Nicolai Hähnle
0b6a74ced0
VectorCombine/AMDGPU: Cleanup a test and add a new one (#168817)
The existing, recently added test contains a whole lot of noise in the
form of dead instructions. Also, prefer named values.

The new test isolates a separate issue with concatenating i8 vectors.
2025-11-20 06:59:14 -08:00
Nicolai Hähnle
07e893205a
AMDGPU: Expand cost model shufflevector test (#168816)
Add a few corner cases of the "simplified" shuffle kinds.
2025-11-20 06:58:33 -08:00
lntue
aa3f930931
[libc][math] Add float-only implementation for atanf. (#167004)
Algorithm:
```
  1)  atan(x) = sign(x) * atan(|x|)

  2)  If |x| > 1 + 1/32, atan(|x|) = pi/2 - atan(1/|x|)

  3)  For 1/16 < |x| < 1 + 1/32, we find k such that: | |x| - k/16 | <= 1/32.
      Let y = |x| - k/16, then using the angle summation formula, we have:
    atan(|x|) = atan(k/16) + atan( (|x| - k/16) / (1 + |x| * k/16) )
              = atan(k/16) + atan( y / (1 + (y + k/16) * k/16 )
              = atan(k/16) + atan( y / ((1 + k^2/256) + y * k/16) )

  4)  Let u = y / (1 + k^2/256), then we can rewritten the above as:
    atan(|x|) = atan(k/16) + atan( u / (1 + u * k/16) )
              ~ atan(k/16) + (u - k/16 * u^2 + (k^2/256 - 1/3) * u^3 +
                              + (k/16 - (k/16)^3) * u^4) + O(u^5)
```

With all the computations are done in single precision (float), the
total of approximation errors and rounding errors is bounded by 4 ULPs.
2025-11-20 09:42:13 -05:00
Luke Hutton
a74bfc06e8
[mlir][tosa] Fix select folder when operands are broadcast (#165481)
This commit addresses a crash in the dialects folder. The currently
folder assumes no broadcasting of the input operand happens and
therefore the folder can complain that the returned value was not the
same
shape as the result.

For now, this commit ensures no folding happens when broadcasting is
involved. In the future, folding with a broadcast could likely be
supported by inserting a `tosa.tile` operation before returning the
operand. This type of transformation is likely better suited for a
canonicalization pass. This commit only aims to avoid the crash.
2025-11-20 14:39:28 +00:00
jeanPerier
364fe55c42
[flang] simplify pointer assignments (#168732)
Pointer assignment lowering was done in different ways depending on
contexts and types, sometimes still using runtime calls when this is not
needed and the complexity of doing this inline is very limited (the
pointer and target descriptors were already prepared inline, the runtime
is just doing the descriptor assignment and ensuring the pointer
descriptor keep its pointer flag).

Slightly extent the inline version that was used for Forall and use it
for all cases.
When lowering without HLFIR is removed, this will allow removing more
code.
2025-11-20 15:37:53 +01:00
Carlos Seo
a9a14d64d2
[flang-rt] Fix TypeCategory for quad-precision COMPLEX (#168090)
Modify the TypeCategory for quad-precision COMPLEX to
CFI_type_float128_Complex so it matches the TypeCode returned
by SELECT TYPE lowering.

Fixes #134565
2025-11-20 11:34:43 -03:00
Abid Qadeer
0e8222b84b
[flang][debug] Make common blocks data extraction more robust. (#168752)
Our current implementation for extracting information about common block
required traversal of FIR which was not ideal but previously there was
no other way to obtain that information. The `[hl]fir.declare` was
extended in commit https://github.com/llvm/llvm-project/pull/155325 to
include storage and storage_offset. This commit adds these operands in
`fircg.ext_declare` and then use them in `AddDebugInfoPass` to create
debug data for common blocks.
2025-11-20 14:28:56 +00:00
Shashi Shankar
5d0bfd1bf8
[MLIR][SCFToGPU] Guard operands before AffineApplyOp::create to avoid crash (#167959)
This fixes a crash in SCF→GPU when building the per‑dim index for mapped
scf.parallel.

**Change**:
- Map step/lb through cloningMap, then run ensureLaunchIndependent.
- If either is still unavailable at launch scope, emit a match‑failure;
otherwise build the affine.apply.

**Why this is correct:**
- Matches how the pass already handles launch bounds; avoids creating an
op with invalid operands and replaces a segfault with a clear
diagnostic.

**Tests**:
- Added two small regressions that lower to gpu.launch and exercise the
affine.apply path.

Fixes :  #167654

Signed-off-by: Shashi Shankar <shashishankar1687@gmail.com>
2025-11-20 22:20:34 +08:00
Anatoly Trosinenko
4bb4ad477d
[AArch64][PAC] Use enum to describe LR signing condition (NFC) (#168548)
Express the condition of signing the return address in a function using
an `enum class` instead of a pair of `bool`s. Define `enum class
SignReturnAddress` with the values corresponding to the three possible
modes that can be requested via "sign-return-address" function
attribute.

Previously, there were two overloads of `shouldSignReturnAddress`
accepting either `const MachineFunction &` or `bool` argument. Due to
pointer-to-bool conversion, when `shouldSignReturnAddress` was
incorrectly called with `const MachineFunction *` argument, the latter
overload was used instead of reporting a compile-time error.
2025-11-20 17:16:37 +03:00
Simone Pellegrini
e0850825cc
[mlir][memref] Generalize dead store detection to all view-like ops (#168507)
The dead alloc elimination pass previously considered only subviews when
checking for dead stores. This change generalizes the logic to support
all view-like operations, ensuring broader coverage.
2025-11-20 14:10:03 +00:00
Kelvin Li
4544ff68dc
[OpenMP][AIX] Not to create symbolic links to libomp.so in install step (NFC) (#168585)
Commit bb563b1 handles the links in the build directory but 
misses the case in the install step. This patch is to link only 
the libomp.a on AIX.
2025-11-20 09:08:57 -05:00
GrumpyPigSkin
aeba7a8ade
[clang][diagnostics] added warning for possible enum compare typo (#168445)
Added diagnosis and fixit comment for possible accidental comparison
operator in an enum.

Closes: #168146
2025-11-20 09:05:03 -05:00
mitchell
150d9b7a77
[clang-tidy][NFC] Add clang-tidy formatting commit to .git-blame-ignore-revs (#167126)
Co-authored-by: Baranov Victor <bar.victor.2002@gmail.com>
2025-11-20 21:42:10 +08:00
Andrzej Warzyński
cfda27d0fb
[mlir][Vector] Add support for scalable vectors to ScanToArithOps (#123117)
Note, scalable reductions dims are left as a TODO.
2025-11-20 13:39:52 +00:00
Alexander Johnston
76f1949cfa
[HLSL] Implement the fwidth intrinsic for DXIL and SPIR-V target (#161378)
Adds the fwidth intrinsic for HLSL.
The DXIL path only requires modification to the hlsl headers.
The SPIRV path implements the OpFwidth builtin in Clang and instruction
selection for the OpFwidth instruction in LLVM.
Also adds shader stage tests to the ddx_coarse and ddy_coarse
instructions used by fwidth.

Closes #99120

---------

Co-authored-by: Alexander Johnston <alexander.johnston@amd.com>
2025-11-20 07:38:32 -05:00
Paul Walker
21c4c1502e
[LLVM][CodeGen][SVE] Only use unpredicated bfloat instructions when all lanes are in use. (#168387)
While SVE support for exception safe floating point code generation is
bare bones we try to ensure inactive lanes remiain inert. I mistakenly
broke this rule when adding support for SVE-B16B16 by lowering some
bfloat operations of unpacked vectors to unpredicated instructions.
2025-11-20 12:01:04 +00:00
Mehdi Amini
3da82af83f [MLIR] Apply clang-tidy fixes for bugprone-argument-comment in SparseBufferRewriting.cpp (NFC) 2025-11-20 03:35:18 -08:00
Mehdi Amini
9e86c0d5da [MLIR] Apply clang-tidy fixes for readability-container-size-empty in LinalgOps.cpp (NFC) 2025-11-20 03:35:18 -08:00
Mehdi Amini
c6a79a55ff [MLIR] Apply clang-tidy fixes for readability-identifier-naming in LLVMToLLVMIRTranslation.cpp (NFC) 2025-11-20 03:35:18 -08:00
sskzakaria
a2b4c0fbe0
[X86][Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow AVX512 mask predicate intrinsics to be used in constexpr (#165054)
Enables constexpr evaluation for the following AVX512 Instrinsics:
```
_mm_movepi8_mask _mm256_movepi8_mask _mm512_movepi8_mask
_mm_movepi16_mask _mm256_movepi16_mask _mm512_movepi16_mask
_mm_movepi32_mask _mm256_movepi32_mask _mm512_movepi32_mask
_mm_movepi64_mask _mm256_movepi64_mask _mm512_movepi64_mask
```
Part of #162072
2025-11-20 11:25:23 +00:00