527508 Commits

Author SHA1 Message Date
Michael Kruse
b55f7512a7
[Flang] LLVM_ENABLE_RUNTIMES=flang-rt (#110217)
Extract Flang's runtime library to use the LLVM_ENABLE_RUNTIME
mechanism. It will only become active when
`LLVM_ENABLE_RUNTIMES=flang-rt` is used, which also changes the
`FLANG_INCLUDE_RUNTIME` to `OFF` so the old runtime build rules do not
conflict. This also means that unless `LLVM_ENABLE_RUNTIMES=flang-rt` is
passed, nothing changes with the current build process.

Motivation:
* Consistency with LLVM's other runtime libraries (compiler-rt, libc,
libcxx, openmp offload, ...)
* Allows compiling the runtime for multiple targets at once using the
LLVM_RUNTIME_TARGETS configuration options
* Installs the runtime into the compiler's per-target resource directory
so it can be automatically found even when cross-compiling

Also see RFC discussion at
https://discourse.llvm.org/t/rfc-use-llvm-enable-runtimes-for-flangs-runtime/80826
2025-02-16 15:39:52 +01:00
Andreas Jonson
17d508f30d [InstCombine] Test foldSelectICmpAnd with cast. (NFC) 2025-02-16 15:27:38 +01:00
hstk30-hw
c01c3cf7d7
[ARM] Fix MRC cp10 and cp11 warning (#126407)
The MRC format is 
    MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, 
        c_imm:$CRn, c_imm:$CRm, 0, pred:$p
The $cop is the second operand.
Patch for
b7d41a11cd.
2025-02-16 22:09:05 +08:00
Oleksandr "Alex" Zinenko
79d8a34bc5
[mlir] add some FP classification ops and their lowering to libdevice (#127322)
Introduce a subset of floating point classification ops to the Math
dialect. These ops mirror functions provided by the C math library and,
similarly to the existing `math.copysign`, belong to the math dialect.
Add a lowering of those ops to Nvidia libdevice calls when possible as
the first mechanism to exercise them.
2025-02-16 14:51:21 +01:00
GS-GOAT
552e4659d3
[Clang][NFCI] Fix a logic issue in TransformDesignatedInitExpr (#127211)
It was clearly a typo regarding whether the array index expression has changed in its transforming.

This doesn't appear to be a functional change in practice, so no test case or release note provided.

Fixes #126113
2025-02-16 21:34:56 +08:00
Andreas Jonson
9c4ef23126 [InstCombine] Test foldSelectICmpAnd with extra uses. (NFC) 2025-02-16 14:01:05 +01:00
Michael Kruse
81c85ea30f [flang-rt] Fix aarch64-libcxx build failure
There seems to be multiple declarations of __libcpp_verbose_abort, some
with noexcept and some without. Reverting to the previous
forward-declaration (without noexcept) which seemes to have worked
before.
2025-02-16 13:46:30 +01:00
Ramkumar Ramachandra
8ac5d2d180
ConstRange: test edge-cases of makeAllowedICmpRegion (#127080)
Exhaustively test signed-unsigned min-max edge-cases of
makeAllowedICmpRegion.
2025-02-16 12:40:03 +00:00
Jeffrey Byrnes
a1120c9b79
[AMDGPU] NFC: Fix some details for lit test (#127141)
Addressed comments in https://github.com/llvm/llvm-project/pull/126976
2025-02-16 19:34:20 +07:00
Michael Kruse
54f37133b7
[Flang][NFC] Move runtime library files to flang-rt (#110298)
Mostly mechanical changes in preparation of extracting the Flang-RT
"subproject" in #110217. This PR intends to only move pre-existing files
to the new folder structure, with no behavioral change. Common files
(headers, testing, cmake) shared by Flang-RT and Flang remain in
`flang/`.

Some cosmetic changes and files paths were necessary:
* Relative paths to the new path for the source files and
`add_subdirectory`.
 * Add the new location's include directory to `include_directories`
* The unittest/Evaluate directory has unitests for flang-rt and Flang. A
new `CMakeLists.txt` was introduced for the flang-rt tests.
 * Change the `#include` paths relative to the include directive
 * clang-format on the `#include` directives
* Since the paths are part if the copyright header and include guards, a
script was used to canonicalize those
* `test/Runtime` and runtime tests in `test/Driver` are moved, but the
lit.cfg.py mechanism to execute the will only be added in #110217.
2025-02-16 13:25:31 +01:00
Yingwei Zheng
29f3a35206
[InstCombine] Do not keep samesign when speculatively executing icmps (#127007)
Closes https://github.com/llvm/llvm-project/issues/126974.
2025-02-16 20:18:29 +08:00
Phoebe Wang
dab9156923
[X86] Add missing explicit conversion for AMXAVX512 and SHA (#127385)
Address the X86 part of #126491
2025-02-16 19:35:09 +08:00
Timm Baeder
e8d848824b
[clang][bytecode] Fix dynamic array allocation return values (#127387)
We need to return a pointer to the first element, not the array itself.
2025-02-16 12:24:35 +01:00
Timm Baeder
d64cf19983
[clang][bytecode] Add Descriptor::dumpFull (#127386)
This is useful to print all (or most) of the valid offsets into a block
of the given descriptor.
2025-02-16 12:15:43 +01:00
Andreas Jonson
a422bc773f [InstCombine] Test for trunc to i1 in foldSelectICmpAndBinOp. (NFC) 2025-02-16 12:01:55 +01:00
MagentaTreehouse
538b8f8008
[Clang] [NFC] Remove outdated FIXME (#126978) 2025-02-16 10:08:30 +01:00
Michał Górny
dbc98cfa46
[libclc] [cmake] Fix per-target *_convert.cl dependencies (#127315)
Fix `add_libclc_builtin_set` to add an appropriate dependency to either
`clspv-generate_convert.cl` or `generate_convert.cl` based on the `ARCH`
argument, rather than to both unconditionally. This fixes build failures
due to missing dependencies when `clspv*` targets are not enabled.

The added check mirrors the one from `libclc/CMakeLists.txt`.

Fixes: #127378
2025-02-16 08:48:52 +01:00
Vitaly Buka
c6d95c441a
[libc++] Fix initialization-order-fiasco with iostream.cpp constructors (#126995)
Asan reports it after #124103.

It's know case of false positive for Asan.

https://github.com/google/sanitizers/wiki/AddressSanitizerInitializationOrderFiasco#false-positives

It's can be avoided with `constexpr` constructors.

In general order global constructors in different
modules is undefined. If global constructor uses
external global, they can be not constructed yet.

However, implementation may contain workaround for
that, or the state of non-constructed global can
be still valid.

Asan will still falsely report such cases, as it
has no machinery to detect correctness of such
cases.

We need to fix/workaround the issue in libc++, as
it will affect many libc++ with Asan users.
2025-02-15 19:54:23 -08:00
Roland McGrath
2157aecfe4
[libc] Produce standard-compliant header guard macros in hdrgen (#127356)
Macros starting with alphabetic characters such as "LLVM" are in
the application name space and cannot be defined or used by a
conforming implementation's headers.  This fixes the headers that
are entirely generated, and the __llvm-libc-common.h header to
use a conforming macro name for the header guard.  That is, it
starts with "_LLVM_LIBC_" instead of "LLVM_LIBC_", as identifiers
starting with an underscore followed by a capital letter are in
the name space reserved for the implementation.

The remaining headers either will be fixed implicitly by removal
of their custom template files, or will need to be fixed by hand.
2025-02-15 17:36:44 -08:00
vporpo
3e3af861b4
[SandboxVec][DAG] Add MemDGNode::MemSuccs (#127253)
This patch adds Memory successors to the memory nodes of the DAG. This
will help maintain the memory dependencies when nodes get removed.
2025-02-15 17:09:51 -08:00
Roland McGrath
ed48398431
[libc] Fill out generated malloc.h and related stdlib.h extensions (#127293)
This updates the generated stdlib.h and malloc.h headers to
include the subsets of extenion functions declared by glibc that
are also supported by Scudo and that use only simple types.
Scudo's extensions not declared by glibc are omitted.  glibc's
extensions not implemented by Scudo are omitted.  The mallinfo
and mallinfo2 functions are omitted (at least for now) since they
need struct definitions for their return types.
2025-02-15 16:32:30 -08:00
Oleksandr "Alex" Zinenko
963ff1c305
[mlir] lower min/maxnum to libdevice calls (#127323)
Introduce lowering from arith.minnum/maxxnum operations to the
corresponding Nvidia libdevice calls. This requires to reorder pattern
population methods so that the libdevice-targeting patterns are
prioritized over default patterns targeting LLVM IR intrinsics from the
Arith dialect. The tests are placed into a separate file as the existing
gpu-to-nvvm.mlir files has a mode that forces Arith dialect operations
to be preserved as is without using a separate FileCheck tag to
differentiate.

Co-authored-by: William Moses <gh@wsmoses.com>
2025-02-15 17:53:36 -05:00
Craig Topper
256145b4b0
[PowerPC] Use getSignedTargetConstant in SelectOptimalAddrMode. (#127305)
Fixes #127298.
2025-02-15 14:13:32 -08:00
Florian Hahn
e5f5517f91 [VPlan] Create IR basic block for middle.block in VPlan.
Create a IR BB directly for the middle.block, instead of creating the IR
BB during skeleton creation and then replacing the middle VPBB with a
VPIRBB.

This moves another part of skeleton creation to VPlan and simplififes
the code slightly by removing code to disconnect the middle block and
vector preheader + the corresponding DT update.

NFC modulo IR block naming and block creation order, which changes the
IR names for the blocks.
2025-02-15 21:54:16 +01:00
David Green
e5f4019f69 [AArch64] Add extending reduction costs for addlv and dot
This adds some basic getExtendedReductionCost and getMulAccReductionCost to
account for add reduction (uaddlv/saddlv) and mla reductions with dotprod.
2025-02-15 20:33:03 +00:00
Chris Bieneman
50581ef1ee [NFC] Fix warning in recent commit 2025-02-15 14:19:31 -06:00
Andrzej Warzyński
ad948fa028
[mlir][vector] Document ConvertVectorStore + unify var names (nfc) (#126422)
1. Documents `ConvertVectorStore`. As the generated output is rather complex, I
  have refined the comments + variable names in:
    * "vector-emulate-narrow-type-unaligned-non-atomic.mlir",
  to serve as reference for this pattern.

2. As a follow-on for #123527, renames `isAlignedEmulation` to `isFullyAligned`
  and `numSrcElemsPerDest` to `emulatedPerContainerElem`.
2025-02-15 20:16:25 +00:00
Andrzej Warzyński
02fb976941
[mlir] Improve GreedyPatternRewriteDriver logging (#127314)
Currently, when `GreedyPatternRewriteDriver` fails, the log output
contains nested failure messages:

```bash
   } -> failure : pattern failed to match
} -> failure : pattern failed to match
```

This may seem redundant, but these messages refer to different aspects
of the pattern application logic. This patch clarifies the distinction
by separately logging:

* Success/failure for a specific pattern (e.g., "_this pattern_ failed
  to match on the Op currently being processed").
* Success/failure for an operation as a whole (e.g., "_all patterns_
  failed to match the Op currently being processed").

Before (example with success):
```bash
Processing operation : (...) {

  * Pattern (...) -> ()' {
Trying to match "..."
    ** Match Failure : (...)
  } -> failure : pattern failed to match

  * Pattern (...) -> ()' {
Trying to match "..."
  } -> success : pattern applied successfully
} -> success : pattern matched
```

After (example with success):
```bash
Processing operation : (...) {

  * Pattern (...) -> ()' {
Trying to match "..."
    ** Match Failure : (...)
  } -> failure : pattern failed to match

  * Pattern (...) -> ()' {
Trying to match "..."
  } -> success : pattern applied successfully
} -> success : at least one pattern matched
```

This improves log clarity, making it easier to distinguish pattern-level
failures from operation-level outcomes.
2025-02-15 20:06:32 +00:00
Michał Górny
07b0665d28
[Flang] Support overriding LLVM_LIT_ARGS in standalone builds (#127340)
Declare `LLVM_LIT_ARGS` as a cache variable in standalone builds to
permit overriding it. This mirrors the logic used in Clang.
2025-02-15 19:50:14 +00:00
Chris B
761d422441
[HLSL] Implement HLSL intialization list support (#123141)
This PR implements HLSL's initialization list behvaior as specified in
the draft language specifcation under

[*Decl.Init.Agg*](https://microsoft.github.io/hlsl-specs/specs/hlsl.html#Decl.Init.Agg).

This behavior is a bit unusual for C/C++ because intermediate braces in
initializer lists are ignored and a whole array of additional
conversions occur unintuitively to how initializaiton works in C.

The implementaiton in this PR generates a valid C/C++ initialization
list AST for the HLSL initializer so that there are no changes required
to Clang's CodeGen to support this. This design will also allow us to
use Clang's rewrite to convert HLSL initializers to valid C/C++
initializers that are equivalent. It does have the downside that it will
generate often redundant accesses during codegen. The IR optimizer is
extremely good at eliminating those so this will have no impact on the
final executable performance.

There is some opportunity for optimizing the initializer list generation
that we could consider in subsequent commits. One notable opportunity
would be to identify aggregate objects that occur in the same place in
both initializers and do not require converison, those aggregates could
be initialized as aggregates rather than fully scalarized.

Closes #56067

---------

Co-authored-by: Finn Plummer <50529406+inbelic@users.noreply.github.com>
Co-authored-by: Helena Kotas <hekotas@microsoft.com>
Co-authored-by: Justin Bogner <mail@justinbogner.com>
2025-02-15 13:21:36 -06:00
Mark de Wever
248716f814
[libc++] Fixes (|multi)_set spaceship operator. (#127326)
The operators did not have a _Compare template arguement. The fix
updates the generic container test to use allocators for all types used.
No other issues were found.

Fixes: #127095
2025-02-15 20:15:32 +01:00
Nikolas Klauser
2472d38338
[libc++] Move unused basic_string function definition to the dylib sources (#126219)
`__init(const value_type*, size_type, size_type)` is part of our ABI,
but we don't actually use the function anymore in the dylib. THis moves
the definition to the `src/` directory to make it clear that the code is
unused. This also allows us to remove it entirely in the unstable ABI.
2025-02-15 20:11:48 +01:00
Ryosuke Niwa
c17df0af23
[webkit.UncountedLambdaCapturesChecker] Fix a crash in declProtectsThis (#127309)
Add a missing nullptr check to declProtectsThis.
2025-02-15 11:04:06 -08:00
Florian Hahn
e60de25c4e [LAA] Replace symbolic strides for translated pointers earlier (NFC).
Move up replaceSymbolicStrideSCEV before isNoWrap. It needs to be called
after hasComputableBounds, as this may create an AddRec via PSE, which
replaceSymbolicStrideSCEV will look up.

This is in preparation for simplifying isNoWrap.
2025-02-15 19:44:39 +01:00
Michał Górny
948e97a40e
[flang] Revert MLIR_MAIN_SRC_DIR override (#127337)
This change is no longer necessary after #125842. Thanks to @nikic for
letting me know.
2025-02-15 18:36:20 +00:00
Ramkumar Ramachandra
b403004035
ConstRange: factor and introduce splitPosNeg (NFC) (#126528)
Factor out some code that splits a ConstantRange into positive and
negative components, introducing ConstantRange::splitPosNeg.
2025-02-15 17:25:03 +00:00
David Green
bfdf30e9b3 [AArch64] Add patterns for addv(sext) and addv(zext)
This adds patterns for v8i8->i16 vaddlv and v4i16->i32 vaddlv, for both signed
and unsigned extends.
2025-02-15 17:04:32 +00:00
Florian Hahn
4664a4c66b [LAA] Use getPointer/setPointer in createCheckForAccess (NFC).
Use getPointer/setPointer to clarify we are accessing/modifying the
rurrent value.
2025-02-15 16:17:42 +01:00
Michael Liao
21e956df9b [CodeGen] Remove two dead pass initializer decls. NFC
- After #97727 and #101652, `LowerConstantIntrinsics` and
  `ExpandVectorPredicationPass` are no longer dedicated passes.
2025-02-15 09:39:39 -05:00
realqhc
88284e4efc
[RISCV] Support Zb*/P Shared Instructions (#127160)
This enables shared instructions between Zb* and Base-P extension.

Documentation:
https://jhauser.us/RISCV/ext-P/RVP-baseInstrs-014.pdf
https://jhauser.us/RISCV/ext-P/RVP-instrEncodings-014.pdf
2025-02-15 22:26:02 +08:00
Louis Dionne
a6093d3034
[libc++] Explicitly mention vector_bool in the name of benchmarks (#127313)
We have some benchmarks that were benchmarking very specific
functionality, namely the optimizations in vector<bool>::iterator. Call
this out in the benchmarks by renaming them appropriately. In the future
we will also increase the coverage of these benchmarks to test other
containers.
2025-02-15 14:56:19 +01:00
Simon Pilgrim
42ff31aea5
[X86] combineTargetShuffle - fold VPERMV3(HI,MASK,LO) -> VPERMV(COMMUTE(MASK),CONCAT(LO,HI)) (#127199)
We already handle the simpler VPERMV3(LO,MASK,HI) fold which can reuse
the (widened) mask, this attempts to match the flipped concatenation,
and commutes the mask to handle the flip.

I've limited this to cases where we can extract the constant mask for
commutation, a more general solution would XOR the MSB of the shuffle
mask indices to commute, but this almost never constant folds away after
lowering so the benefit was minimal.
2025-02-15 11:59:52 +00:00
Edgar
2db262886f
[MLIR] Fix mlirExecutionEngineLookup throwing assert on lookup fail (#123924)
Apparently trying to lookup a function pointer using the C api
`mlirExecutionEngineLookup` will throw an assert instead of just
returning a nullptr on builds with asserts.

The docs itself says it returns a nullptr when no function is found so
it should be sensible to not throw an assert in this case.
2025-02-15 12:21:20 +01:00
lntue
70b95ca6db
[libc][math] Fix sqrtf128 implicit conversions. (#127154)
This fixes rv32 buildbot failure from
https://github.com/llvm/llvm-project/pull/122578
2025-02-15 05:11:54 -05:00
Corentin Jabot
8f3a070db9 [Clang] Add new WG21 papers(Hagenberg) papers to the C++ status page 2025-02-15 10:54:14 +01:00
Louis Dionne
cffc1ac349
[libc++] Avoid including <features.h> on arbitrary platforms (#125587)
This partially reverts commit 5f2389d4. That commit started checking
whether <features.h> was a valid include unconditionally, however codebases
are free to have such a header on their search path, which breaks compilation.
LLVM libc now provides a more standard way of getting configuration macros
like __LLVM_LIBC__.

After this patch, we only include <features.h> when we're on Linux or
when we're compiling for GPUs.
2025-02-15 10:54:00 +01:00
Nikolas Klauser
4887e41055
[libc++][NFC] Make enable_ifs in <optional> consistent (#127184)
We've documented the preferred `enable_if` style in the coding
guidelines. This updates `<optional>` to conform to them
2025-02-15 10:38:59 +01:00
Kazu Hirata
7e7a3623b4
[Hexagon] Avoid repeated map lookups (NFC) (#127304) 2025-02-15 01:38:00 -08:00
Kazu Hirata
05209f1e59
[ExecutionEngine] Avoid repeated hash lookups (NFC) (#127303) 2025-02-15 01:37:02 -08:00
Kazu Hirata
9453b38ac7
[clang-offload-packager] Avoid repeated hash lookups (NFC) (#127302) 2025-02-15 01:36:39 -08:00