537535 Commits

Author SHA1 Message Date
Fangyi Zhou
baf2cfa299
Revert "[clang][analyzer] Fix a nullptr dereference when -ftime-trace is used" (#139936)
Reverts llvm/llvm-project#139820

Reverting due to buildbot failures in asan
2025-05-14 13:45:05 -04:00
Vladislav Dzhidzhoev
47144a0dc1
[CloneFunction][DebugInfo] Ensure DILocalVariables of inlined functions are not cloned (NFC) (#138590)
This change was separated from
https://github.com/llvm/llvm-project/pull/119001.

When cloning functions, use IdentityMDPredicate to ensure that if
DISubprogram is not cloned, then its DILocalVariables are not cloned
either.

This is currently expected to be an NFC, as DILocalVariables only
reference their subprograms (via DILocalScopes) and types, and inlined
DISubprograms and DITypes are not cloned. Thus, DILocalVariables are
mapped to self in ValueMapper (in mapTopLevelUniquedNode).

However, it will be needed for the original PR
https://github.com/llvm/llvm-project/pull/119001, where a
DILocalVariable may refer to a local type of a DISubprogram that is
being cloned. In that case, ValueMapper will clone DILocalVariable even
if it belongs to an inlined DISubprogram that is not cloned, which
should be avoided.
I'm making this change into a separate PR to make the original PR a bit
smaller, and because this has more to do with variables than with types.
2025-05-14 19:41:56 +02:00
Deric C.
80fa621482
[DirectX] Set shader feature flags MinimumPrecision and NativeLowPrecision, and refactor the logic for setting low-precision-related flags (#139623)
Fixes #138997 and does refactoring for low-precision-related flags.

The shader feature flags MinimumPrecision and NativeLowPrecision were
not being set, leading to validation errors.
This PR sets these shader feature flags [as in
DXC](377c4ca6d8/lib/DXIL/DxilShaderFlags.cpp (L58-L63))
and adds tests for them.

This PR also performs some refactoring of low-precision-related flags to
make it less confusing.
- The `UseNativeLowPrecision` DXIL module flag has been renamed to
`NativeLowPrecisionMode` to imply that it is setting some execution
state which the module should be interpreted with
- The LLVM module flag `dx.nativelowprec` is now read only once and sets
a bool to be used by `updateFunctionFlags()` and for setting the DXIL
module flag `NativeLowPrecisionMode`
- The `MinimumPrecision`, `NativeLowPrecision`, and
`LowPrecisionPresent` shader feature flags are all set together under
`updateFunctionFlags()`
- Moved the logic for setting DXIL module flags `NativeLowPrecisionMode`
and `ResMayNotAlias` out of the per-function loop and placed it
alongside the logic for setting other DXIL module flags
(`DisableOptimizations`, `Max64UAVs`, and `UAVsAtEveryStage` flags)

---------

Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-05-14 10:37:27 -07:00
Craig Topper
bf0655f208
[RISCV] Improve casting between i1 scalable vectors and i8 fixed vectors for -mrvv-vector-bits (#139190)
For i1 vectors, we used an i8 fixed vector as the storage type.

If the known minimum number of elements of the scalable vector type is
less than 8, we were doing the cast through memory. This used a load or
store from a fixed vector alloca. If  is less than 8, DataLayout
indicates that the load/store reads/writes vscale bytes even if vscale
is known and vscale*X is less than or equal to 8. This means the load or
store is outside the bounds of the fixed size alloca as far as
DataLayout is concerned leading to undefined behavior.

This patch avoids this by widening the i1 scalable vector type with zero
elements until it is divisible by 8. This allows it be bitcasted to/from
an i8 scalable vector. We then insert or extract the i8 fixed vector
into this type.

Hopefully this enables #130973 to be accepted.
2025-05-14 10:27:00 -07:00
Helena Kotas
a3ba00a3db
[HLSL][NFC] Simplify resource constructors codegen tests (#139842)
Verification of the local allocas and load/store is not that useful and
it makes the test fragile.
2025-05-14 10:08:24 -07:00
Sean Fertile
0afa62c169
[NFC] Reduce number of run steps in ppc rop-protect test. (#139607)
Test was running both -mcpu=pwrN and -mcpu=powerN compile steps for
power N = 8, 9 and 10. Reduce to one run step for each form using power8
for one instance and power 10 for the other.
2025-05-14 13:03:04 -04:00
Peng Liu
f1ecff8f88
[libc++] Improve test coverage and readability for swap_ranges (#133752)
This patch enhances the test coverage of `{std,ranges}::swap_ranges` by
adding larger test cases with 100 elements across different containers.
It also inlines standalone tests for better readability, avoiding
unnecessary navigation.

This patch addresses a follow-up suggestion from PR #121138 to extend
test coverage beyond 3 elements.
2025-05-14 13:02:01 -04:00
Sean Fertile
4ac8e90df7
[PPC] Disable rop-protect for 32-bit OS targets. (#139619)
The instructions are not supported on either 32-bit ELF (due to no
redzone) or 32-bit AIX due to the instructions always using the full
64-bit width of the register inputs.
2025-05-14 13:00:15 -04:00
John Harrison
441d382f93
[lldb-dap] Adding unit tests for Transport. (#139926)
This adds basic support for testing the Transport class and includes
tests for 'Read' and 'Write'.
2025-05-14 10:00:01 -07:00
Craig Topper
bcf3654847
[RISCV] Lower i64 load/stores to ld/sd with Zilsd. (#139808)
Don't split i64 load/store when we have Zilsd.

In the future, we should enhanced the LoadStoreOptimizer pass to do
this, but this is a good starting point. Even if we support it in
LoadStoreOptimizer, we might still want this for volatile loads/stores
to guarantee the use of Zilsd.
2025-05-14 09:54:07 -07:00
Kazu Hirata
2422b1795f
[DebugInfo] Simplify a string comparison (NFC) (#139918)
Note that the lambda function we are in returns bool, so
FileZero.compare(FileOne) is equivalent to FileZero != FileOne in this
context.
2025-05-14 09:52:48 -07:00
Donát Nagy
31e981ca1d
[NFC][analyzer] Clarify that ExplodedGraph has only one root (#139903)
Previously the class `ExplodedGraph` had a data member called `Roots`
which could (in theory) store multiple root nodes -- but in practice
exploded graphs always had at most one root node (zero was possible for
empty and partially copied graphs) and introducing a graph with multiple
roots would've caused severe malfuncitons (e.g. in code that used the
pattern `*roots_begin()` to refer to _the_ root node).

I don't see any practical use case for adding multiple root nodes in a
single graph (this seems to be yet another of the "generalize for the
sake of generalization" decisions which were common in the early history
of the analyzer), so this commit replaces the vector `Roots` with
`ExplodedNode *Root` (which may be null when the graph is empty or under
construction).

Note that the complicated logic of `ExplodedGraph::trim` deserves a
through cleanup, but I left that for a follow-up commit.
2025-05-14 18:47:50 +02:00
Amir Ayupov
9d5d715330
[BOLT][heatmap] Add synthetic hot text section (#139824)
In heatmap mode, report samples and utilization of the section(s)
between hot text markers `[__hot_start, __hot_end)`.

The intended use is with multi-way splitting where there are several
sections that contain "hot" code (e.g. `.text.warm` with CDSplit).

Addresses the comment on #139193

https://github.com/llvm/llvm-project/pull/139193#pullrequestreview-2835274682

Test Plan: updated heatmap-preagg.test
2025-05-14 09:47:14 -07:00
Rahul Joshi
26fbbfd98f
[NFC][Clang] Simplify getTrailingObjects for OpenACC/OpenMP Clause (#139838)
Simplify usage of `getTrailingObjects` for OpenACC/OpenMP Clause by
using either the non-templated form for single trailing types or using
the single argument form that returns an ArrayRef/MutableArrayRef.
2025-05-14 09:40:32 -07:00
Andrew Rogers
9a0e1c7988
Revert "[llvm] properly guard dump methods in Support lib classes" (#139927)
Reverts llvm/llvm-project#139804
2025-05-14 09:35:19 -07:00
Andi Drebes
ba23eedc68
[MLIR][parser] Add token type and parser methods for forward slashes (#125056)
This adds a token for a forward slash to the token definition list and
the methods to `AsmParser::parseSlash()` and
`AsmParser::parseOptionalSlash()`, similar to other tokens used as
operators (e.g., star, plus, etc.). This allows implementations of
attributes that contain arithmetic expressions to support operators with
a forward slash, e.g., a division.

The newly added check tests trigger the parsing of a slash in an
attribute.
2025-05-14 09:33:21 -07:00
Donát Nagy
899f26315c
[NFC][analyzer] Document configuration options (#135169)
This commit documents the process of specifying values for the analyzer
options and checker options implemented in the static analyzer, and adds
a script which includes the documentation of the analyzer options (which
was previously only available through a command-line flag) in the
RST-based web documentation.
2025-05-14 18:28:44 +02:00
Pavel Labath
5fb9dca14a Revert "[lldb] Call Target::ClearAllLoadedSections earlier (#138892)"
This reverts commit 97aa01bef770ec651c86978d137933e09221dd00 and
7e7871d3f58b9da72ca180fcd7f0d2da3f92ec4a due to failures on windows.
2025-05-14 18:22:02 +02:00
Jonas Devlieghere
998dca4235
[lldb-dap] Add unit test for protocol enum types (#139848)
Add dedicated unit tests for the protocol enum types.
2025-05-14 09:10:49 -07:00
Kazu Hirata
93f19cb009 [mlir] Fix a warning
This patch fixes:

  mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp:1544:14: error:
  unused variable 'destType' [-Werror,-Wunused-variable]
2025-05-14 09:04:33 -07:00
Andrew Rogers
c9d05f3bcb
[llvm] properly guard dump methods in Support lib classes (#139804)
## Purpose
Add proper preprocessor guards for all `dump()` methods in the LLVM
support library. This change ensures these methods are not part of the
public ABI for release builds.

## Overview
* Annotates all `dump` methods in Support and ADT source with the
`LLVM_DUMP_METHOD` macro.
* Conditionally includes all `dump` method definitions in Support and
ADT source so they are only present on debug/assert builds and when
`LLVM_ENABLE_DUMP` is explicitly defined.

NOTE: For many of these `dump` methods, the implementation was already
properly guarded but the declaration in the header file was not.

## Background
This issue was raised in comments on #136629. I am addressing it as a
separate change since it is independent from the changes being made in
that PR.

According to [this
documentation](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/Compiler.h#L637),
`dump` methods should be annotated with `LLVM_DUMP_METHOD` and
conditionally included as follows:
```
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void dump() const;
#endif
```

## Validation
* Local release build succeeds.
* CI
2025-05-14 08:54:12 -07:00
Yingwei Zheng
aa054c6810
[ConstraintElim] Simplify and/or instead of replacing its operand (#139874)
In `checkOrAndOpImpliedByOther`, replacing an operand of a disjoint or
is unsafe: https://alive2.llvm.org/ce/z/4R4hxN
This patch performs the simplification directly, to avoid miscompilation
and unnecessary canonicalization.

Closes https://github.com/llvm/llvm-project/issues/137937.
2025-05-14 23:37:41 +08:00
Alexey Karyakin
eac7466448
[LTO] Fix a crash with thin LTO caching and asm output (#138203)
The `CacheStream::commit()` function (defined in Caching.cpp) deletes
the underlying raw stream. Some output streamers may hold a pointer
to it, which then will outlive the stream object.
In particular, MCAsmStreamer keeps the pointer to the raw stream
though a separate `formatted_raw_stream` object, which buffers data and
there is no path to explicitly flush this data. Before this change,
the buffered data was flushed during the MCAsmStreamer destructor.
After #136121, this happened after the `commit()` function is called.
Therefore, it caused a crash because the `formatted_raw_stream` object
tries to write the buffered data into a deleted raw stream. Even if
we don't delete the stream to avoid the crash, it would be too late
as the output stream cannot accept data after commit().

Fixes: #138194.
2025-05-14 10:33:57 -05:00
Andrzej Warzyński
ee47454bb8
[mlir][vector] Refactor createWriteOrMaskedWrite (#138137)
This patch updates `createWriteOrMaskedWrite` to make it consistent with
`createReadOrMaskedRead`.

Before diving into the details: note that these utilities are currently
implemented in different files — "VectorUtils.cpp" (Vector) and
"Vectorization.cpp" (Linalg). In a subsequent patch, I plan to move
`createWriteOrMaskedWrite` into "VectorUtils.cpp".

SUMMARY OF CHANGES:

The main change is to remove the logic that creates the destination
tensor, which previously looked like:
```cpp
  Value dest = builder.create<tensor::EmptyOp>(loc, destSizes,
                                               inputType.getElementType());
```

With this patch, createWriteOrMaskedWrite now simply generates:
```mlir
  %res = vector.transfer_write %vectorToStore into %dest
```

This replaces the previous form:
```mlir
  %dest = tensor.empty(%destSizes)
  %res = vector.transfer_write %vectorToStore into %dest
```

In other words, the destination value `%dest` is now passed as an input
parameter. This makes `createWriteOrMaskedWrite` re-usable in contexts
where the destination tensor is already known — for example, in
`vectorizeAsInsertSliceOp`, which I will update in a follow-up patch.

OTHER CHANGES:

* Added comments and clarified TODOs.

* Updated tests: since destination sizes are now computed independently
  inside `createWriteOrMaskedWrite`, some additional `tensor.dim` ops
  appear. These will be cleaned up by CSE + canonicalization.
2025-05-14 16:32:35 +01:00
Alexey Bataev
c632ac3506 [SLP][NFC]Add a test with the gather operand in phi node in gathered loads 2025-05-14 08:18:23 -07:00
Mircea Trofin
c2b9aa0e72
[docs][mlgo] Fix list formatting (#139922)
Fix after #139205
2025-05-14 08:17:40 -07:00
Fangyi Zhou
440e510b89
[clang][analyzer] Fix a nullptr dereference when -ftime-trace is used (#139820)
Fixes #139779.

The bug was introduced in #137355 in `SymbolConjured::getStmt`, when
trying to obtain a statement for a CFG initializer without an
initializer. This commit adds a null check before access.
2025-05-14 16:35:57 +02:00
Shafik Yaghmour
7e690db515
[Clang][NFC] Introduce no local variable to avoid use after move (#139784)
Static analysis flagged the use of Left.size() because we just moved out
of Left and that would be undefined behavior. Fix is to take the size
and store it in a local variable instead.
2025-05-14 07:31:14 -07:00
Aaron Ballman
3302f9f63d Move release note to a better spot; NFC 2025-05-14 10:22:36 -04:00
Aaron Ballman
0eb8a92ce9
[OpenMP] Fix tentative parsing crash with metadirective (#139901)
There were two crashes that have the same root cause: not correctly
handling unexpected tokens. In one case, we were failing to return early
which caused us to parse a paren as a regular token instead of a special
token, causing an assertion. The other case was failing to commit or
revert the tentative parse action when not getting a paren when one was
expected.

Fixes #139665
2025-05-14 10:19:24 -04:00
Kazu Hirata
c5229e92ce
[libc] Fix typos in documentation (#139852) 2025-05-14 07:14:43 -07:00
Timm Baeder
9ca8248a91
[clang] Save ShuffleVectorExpr args as ConstantExpr (#139709)
The passed indices have to be constant integers anyway, which we verify
before creating the ShuffleVectorExpr. Use the value we create there and
save the indices using a ConstantExpr instead. This way, we don't have
to evaluate the args every time we call getShuffleMaskIdx().
2025-05-14 16:13:01 +02:00
Nikolas Klauser
edc9d91ca4
[libc++] Enable the GDB pretty printers for Clang (#135484)
The GDB pretty printer test works just fine with Clang in the CI now,
except that it breaks (not exactly unexpectedly) with optimizations
enabled.
2025-05-14 10:12:01 -04:00
Asher Mancinelli
f486cc4417
[flang] Add loop annotation attributes to the loop backedge (#126082)
Flang currently adds loop metadata to a conditional branch in the loop
preheader, while clang adds it to the loop latch's branch instruction.
Langref says:

> Currently, loop metadata is implemented as metadata attached to the
branch instruction in the loop latch block.
>
> https://llvm.org/docs/LangRef.html#llvm-loop

I misread langref a couple times, but I think this is the appropriate
branch op for the LoopAnnotationAttr. In a couple examples I found that
the metadata was lost entirely during canonicalization. This patch makes
the codegen look more like clang's and the annotations persist through
codegen.

* current clang: https://godbolt.org/z/8WhbcrnG3
* current flang: https://godbolt.org/z/TrPboqqcn
2025-05-14 07:07:57 -07:00
erichkeane
65a9a3d5b1 [OpenACC] Fix asserts when checking clauses after invalid directive
When implementing the parsing for OpenACC I ensured that we could always
continue to do diagnostics/etc.  For the most part, I was consistent
with that assumption throughout clause Sema, but in 3 cases I left in
some unreachables for cases where this would happen. I've now properly
handled all 3 in a reasonable way.

Fixes: #139894
2025-05-14 07:03:16 -07:00
Graham Hunter
5b9246517f
[LV] Fix ScalarIVSteps vplan pattern matcher, remove m_CanonicalIV() (#138298)
783a846 changed VPScalarIVStepsRecipe to take 3 arguments (adding
VF explicitly) instead of 2, but didn't change the corresponding
pattern matcher.

This matcher was only used in vputils::isHeaderMask, and no test
ever reached that function with a ScalarIVSteps recipe for the
value being matched -- it was always a WideCanonicalIV. So the
matcher bailed out immediately before checking arguments and
asserting that the number of arguments in the recipe was the
same provided by the matcher.

Since the constructors for ScalarIVSteps take 3 values, we should
be safe to update the matcher and guard it with a dedicated gtest.

m_CanonicalIV() on the other hand is removed; as a phi recipe it
may not have a consistent number of arguments to match, only
requiring one (the start value) when being constructed with the
assumption that a second incoming value is added for the backedge
later. In order to keep the matcher we would need to add multiple
matchers with different numbers of arguments for it depending on
what phase of vplan construction we were in, and ensure that we
never reorder matcher usage vs. vplan transformation. Since the
main IR PatternMatch.h doesn't contain any matchers for PHI nodes,
I think we can just remove it and match via m_Specific() using the
VPValue we get from Plan.getCanonicalIV().
2025-05-14 15:01:03 +01:00
OverMighty
6a125afdd5
[libc] Fix DyadicFloat::generic_as() using FPBits<float16> not FPBits<T> (#139899) 2025-05-14 15:59:24 +02:00
Florian Hahn
7a9fd62278
[VPlan] Use VPlan operand order for VPBlendRecipes. (#139475)
Don't use the order of incoming values of IR phis when creating 
VPBlendRecipes. Instead, simply use the incoming operands and
blocks from the VPWidenPHIRecipe.

Note that this changes the order of the incoming operands/masks for some
blends.

PR: https://github.com/llvm/llvm-project/pull/139475
2025-05-14 14:56:35 +01:00
Pavel Labath
7e7871d3f5 [lldb] Clear loaded sections even earlier
Follow-up to #138892 fixing breakage on windows. Calling
ClearAllLoadedSections earlier is necessary to avoid throwing out the
work done by the windows process plugin.
2025-05-14 15:38:10 +02:00
Marina Taylor
1914184e5c
Reland "[ObjCARC][Contract] Optimize bundled RetainRV to ClaimRV" (#139889)
This teaches ObjCARCContract to transform attachedcall bundles
referencing objc_retainAutoreleasedReturnValue to instead reference
objc_claimAutoreleasedReturnValue.

The only distinction between the two is that the latter is required to
be guaranteed to immediately follow the call it's attached to, and, by
construction, the bundles always achieve that by:
- not being separable from the call through IR and the backend
- not getting the marker emitted when claimARV is the attachedcall.

This is enabled only for arm64, arm64e, and arm64_32 on macOS13/iOS16
and related operating systems.

Co-authored-by: Ahmed Bougacha <ahmed@bougacha.org>
2025-05-14 14:21:52 +01:00
Juan Manuel Martinez Caamaño
a31d7d1a24
[NFC] Typo in __clang_hip_cmath.h (#139892)
ambibuity -> ambiguity
2025-05-14 15:19:06 +02:00
Steven Perron
8732d0f389
[SPIRV] Don't add CPacked and Alignement decorations for Vulkan (#138711)
Packed structs get a different layout than a struct that is not packed.
This is handled by assigning different offset decoration when
appropriate. The `CPacked` decoration is not required, and is in fact
not valid when creating a shader.

Similaraly the alignment decoration is not allows when creating a
shader. We must avoid generating that decoration.

Fixes https://github.com/llvm/llvm-project/issues/138268
2025-05-14 09:18:15 -04:00
Rahul Joshi
7c57e82456
[NFC][TableGen] Code cleanup in Record.h/cpp (#138876)
- Use range for loops in several places.
- Change some variable names to conform to LLVM coding standard.
- Use ListSeparator instead of manual code to generate comma interleaved
strings.
- Remove unnecessary copies in SETDAGOP evaluation in BinOpInit::Fold.
- Eliminate duplicated code in the 2 overloads of RecordVal::setValue.
- Use explicit type in some range for loops.
- Tested by verifying that all the .inc files generated by building all
the *CommonTableGen targets stay unchanged.
2025-05-14 06:10:00 -07:00
Rahul Joshi
2f2c327017
[NFC][TableGen] Use StringRef in X86RecognizableInstr (#139648)
- Use `StringRef` instead of `std::string` in several functions.
- Fix some variable names to conform to LLVM coding standard.
- Use llvm::function_ref instead of function pointer for `handleOperand`
argument.
2025-05-14 06:06:08 -07:00
Vadim Curcă
cdabce0c1b
[MLIR] Remove extra 'any' from CompositePass inner pipeline string (#139877)
When a `CompositePass` is created programmatically, it incorrectly
prepends an extra `any` to the inner pipeline string. For example:
```c++
passManager.nestAny().addPass(createCompositeFixedPointPass(
  "Pass1AndPass2",
  [](OpPassManager &nestedPassManger) {
    nestedPassManger.addPass(createPass1());
    nestedPassManger.addPass(createPass2());
  },
```
This would result in the following pipeline string:
```
any(composite-fixed-point-pass{max-iterations=3 name=Pass1AndPass2
pipeline=any(pass1,pass2)})
```

This commit fixes this issue, resulting in the pipeline string:
```
any(composite-fixed-point-pass{max-iterations=3 name=Pass1AndPass2
pipeline=pass1,pass2})
```
2025-05-14 15:00:29 +02:00
Simon Pilgrim
fb07683bc2
[NVPTX] Add baseline srl-shl-zext tests from #138290 (#139878) 2025-05-14 13:20:21 +01:00
Simon Pilgrim
8c67d25681 [X86] combineGatherScatter - pull out repeated variables. NFC. 2025-05-14 13:12:20 +01:00
Krzysztof Parzyszek
e06363f80f
[flang][OpenMP] Verify uses of OmpCancellationConstructTypeClause (#139743)
Some directive names can be used as clauses, for example in "cancel". In
case where a directive name is misplaced, it could be interpreted as a
clause.

Verify that such uses are valid, and emit a diagnostic message if not.

Fixes https://github.com/llvm/llvm-project/issues/138224
2025-05-14 07:07:14 -05:00
Krzysztof Parzyszek
3abd77ac15
[clang][OpenMP] Treat "workshare" as unknown OpenMP directive (#139793)
The "workshare" construct is only present in Fortran. The common OpenMP
code does treat it as any other directive, but in clang we need to
reject it, and do so gracefully before it encounters an internal
assertion.

Fixes https://github.com/llvm/llvm-project/issues/139424
2025-05-14 07:06:11 -05:00
yingopq
b96c5df04e
[Mips] Add support of MipsInstrInfo::getNop() (#139863)
Fix compile crash when using __builtin_unreachable. 
Fix #134913.
2025-05-14 19:52:31 +08:00