[flang][Lower] Admit opaque terms to real sum reassociation
First part of follow-ups for generalisations requested in #207377.
The split-sum eligibility check rejected any RHS containing explicit
parentheses or subtraction, even though the Add flattener already
preserves every non-Add subtree as one opaque term.
Remove those blanket guards and their unused predicates. Document the
opaque-term invariant and extend the test to cover parenthesized
additions and subtractions, whole-RHS parentheses, and subtraction
terms.
Assisted-by: Codex
[lldb] Fix Unicode code point formatting to use proper notation (#211131)
- use uppercase hex digits
- only emit "U+" notation for valid code points (<= U+10FFFF),
zero-padded to a minimum of four digits.
rdar://173817553
Assisted-by: claude
[flang][cuda] Fix cuf-alloc-delay for host-associated allocatables (#211103)
`cuf-alloc-delay` sinks a managed descriptor's `cuf.alloc` group
(`{cuf.alloc, fir.store, fir.declare}`) to just before its first use, to
defer the managed allocation. It special-cased the store of the descriptor
into a host-association tuple slot (`fir.store` to a `fir.llvm_ptr`): it did
not count that store (nor the call that consumes the tuple) as a use, and moved
the store along with the group. As a result, when a managed allocatable descriptor
is stored into a host-association tuple and passed to an internal procedure, the group
could be sunk **past** the internal-procedure call that reads the tuple, so the
callee observed an uninitialized descriptor. On more complex tuples, moving the
host-association store also broke SSA dominance, producing
`operand #1 does not dominate this use`.
With this PR, `findDelayTarget` now treats **every** use of the
descriptor as a real use, including the host-association store. The group is only ever sunk to
*before* the first use, and the host-association store is never moved (it reads
its own `fir.coordinate_of` slot). This keeps the descriptor initialized before
the tuple is consumed and is dominance-safe by construction.
[Flang] Return APInt from getIntIfConstant (#211233)
Preserve the full bit width of integer attributes when extracting
constants from FIR values. Return llvm::APInt directly and update
fixed-width consumers to use checked signed extraction.
This avoids truncating or asserting on constants wider than 64 bits
while retaining existing fallback behavior at int64_t boundaries.
This should be NFC everywhere we didn't have a latent overflow bug. I
didn't go so far as updating the interfaces of every function built on
top of getIntIfConstant: this is mostly to make an APInt version
available because it looks useful for another PR. Fixing the builder API
to use APInt would be a larger change - let me know if anyone wants to
see that.
Assisted-by: Codex
[lldb][test] Skip more WebAssembly-unsupported API tests (#211305)
Skip tests that exercise features WebAssembly does not provide:
expression evaluation, registers, an ABI plugin, and unmapped memory
pages.
[AMDGPU] Move SGPR Count Queries into TargetParser (#209848)
Relocated SGPR queries from AMDGPU backend into the public TargetParser.
Part of resolving a comgr issue
(https://github.com/ROCm/llvm-project/issues/3298) to reduce
comgr-isa-metadata.def duplication.
Assisted by: Claude Code
[LLVM] Remove 'LLVM_LIBC_GPU_BUILD' logic (#211265)
Summary:
This is a holdover from how we used to handle this stuff. We should just
dirctly check the triple for setting the cross-compiling emulator and we
can directly introspect into the build tree for the lit config like we
already do for flang-rt.
[MC][NFC] Share some code between MasmParser and AsmParser
Factor out printIncludeStackForDiagnostic() to SourceMgr in preparation
for a follow-up commit that changes the output here. This avoids needing
to update both of them. Also add two more tests for the current output.
Pull Request: https://github.com/llvm/llvm-project/pull/210731
[Flang][OpenMP] Add support for interop construct (#203959)
This adds support for the OpenMP interop construct, which enables
interoperability with foreign runtime environments (e.g., CUDA, HIP).
The init, use, and destroy action clauses are lowered from the Fortran
parse tree to MLIR interop ops and translated to the appropriate runtime
calls. The omp_lib module is extended with interop query API interfaces,
property constants, and return code constants. A semantics fix relaxes
the depend/targetsync constraint for use/destroy directives where the
interop type was established at a separate init site. Unsupported depend
clauses and prefer_type selector-list forms emit explicit diagnostics
instead of being silently dropped.
Assisted-by: Claude Opus 4.6
[MLIR][Python] Remove stale NumPy detection message (#211235)
NumPy stopped being requested as a CMake Python component when its
unused build-time dependency was removed in #108465 . Remove the
remaining status message, which now prints empty version and include
directory values.
[MLIR][Python] Remove stale Python module naming status message (#211243)
`PYTHON_MODULE_PREFIX`, `PYTHON_MODULE_SUFFIX`, and
`PYTHON_MODULE_EXTENSION` are remnants of the previous pybind11-based
Python discovery path and are no longer populated or used by the
nanobind build.
The relevant Python SOABI is already reported through `Python3_SOABI`,
so we can remove the redundant status message, which currently prints
only empty values.
[flang][PFT-to-MLIR] Default wrap-unstructured-constructs-in-execute-region to off
Flip the default of `-wrap-unstructured-constructs-in-execute-region`
from true to false while further miscompiles under the wrap path are
investigated. The flag is still available; lit tests that exercise the
wrap path now pass it explicitly on their RUN lines.
Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
[CIR] Convert byval/sret/byref arg-attr types when lowering to LLVM (#210764)
The CallConvLowering pass lowers an indirectly-passed aggregate to a pointer argument and records the pointee record type on the `llvm.byval`, `llvm.sret`, or `llvm.byref` argument attribute. That type payload is still a CIR record after the pass runs, so once the module reaches the LLVM dialect and is translated to LLVM IR, the translation hits a CIR type inside the attribute and fails.
LowerToLLVM already routes every operand and result type through the type converter. It now does the same for the type carried by those three argument attributes, in the attribute lowering shared by the function definition and by the call and invoke sites. With the conversion in place, a byval or sret parameter translates to `byval(%struct.X)` / `sret(%struct.X)` carrying the lowered LLVM struct type, and byref does the same. CallConvLowering does not classify `cir.try_call` yet, so no invoke carries these attributes today, but the shared path already covers the invoke once it is classified.
The test injects the three attributes directly, lowers to the LLVM dialect, and translates to LLVM IR, checking the emitted attributes carry the LLVM struct type. It uses no aggregate classifier, so it stands alone from the x86_64 classifier stack.
[libc++] Don't add #pragma clang attribute with GCC (#206989)
GCC doesn't support `#pragma clang attribute`, which causes a bunch of
diagnostics. Since we have it behind a macro anyways we can simply
define the macro as empty with GCC.
clang/AMDGPU: Stop passing redundant -target-cpu to cc1
Now that the exact target is encoded in the triple's subarch field,
-target-cpu is redundant. This avoids polluting the resultant IR with
unwanted "target-cpu" attributes. The net result is the desired codegen
when compiling libraries for a major subarch and linking it into a
program compiled for a specific arch. e.g., compiling for "gfx9-generic"
would pollute the IR with "target-cpu"="gfx9-generic", so codegen
would ultimately be performed for the generic target even after
linking into the concrete gfx9 cpu. The specialization will now be
achieved by merging the triples without the linker or optimization
passes needing to fixup function attributes.
clang: Start using new amdgpu subarch triples
Fixup invocations using --target=amdgcn + -mcpu to introduce
the subarch in the triple.
For offload toolchains, a single toolchain is constructed for the
top level amdgpu architecture, and the effective triple is used for
target specific tool invocations.
The specifics of the resource directory layout are tbd. This does
try to find resources in the subarch named directory. The paths
are searched at toolchain creation time, so that does not work
when there are multiple subarches.
Fixes #154925