[LV][VPlan] Print VPlan after construction and initial optimizations. NFC (#187443)
This patch add a helper pass `printOptimizedVPlan` to print the plan at
the end of the VPlan construction and optimize pipeline.
This patch enables the opportunity that we can further clamp and attach
VF range after `VPlanTransforms::optimize` and not changing the test
printing (#172799).
[CMake] Pass ZLIB_LIBRARY_* to runtimes bootstrap (#191555)
Runtimes external project (compiler-rt / combined runtimes) reconfigures
with an initial cache that did not propagate `ZLIB_LIBRARY_RELEASE`.
CMake 4.x `FindZLIB` may leave `ZLIB_LIBRARY` unset while finding
headers, leading to:
```
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "...")
```
and later when loading LLVM exports from the main build:
```
The link interface of target "LLVMSupport" contains: ZLIB::ZLIB
but the target was not found.
```
This was found by building the Windows installer with:
```
llvm\utils\release\build_llvm_release.bat --x64 --version 23.0.0 --skip-checkout --local-python
```
[flang][CodeGen] Fix address space mismatch for CUF globals in AddrOfOpConversion (#190408)
AddrOfOpConversion in CodeGen.cpp only handled `LLVM::GlobalOp` when
determining the address space for `llvm.mlir.addressof`. When the global
was still a `fir::GlobalOp` (not yet converted), it fell back to address
space 0, breaking CUF constant globals (addr_space 4) and AMDGPU targets
(global addr_space 1).
This extends the upstream fix (#192111, which only covered Constant) to
also handle Shared and Managed CUF data attributes, and returns
`std::nullopt` instead of 0 for non-CUF globals so the target's default
address space is preserved.
[lldb][debugserver] Fix lldb testsuite routine parsing logs (#192157)
I changed how lldb and debugserver fetch binaries when attaching to a
process (only fetching the addresses of binaries, not the detailed
information) but a utility function was parsing the log file and
expected the detailed information in the initial response. Updated it to
expect detailed information in the initial response, or in the
subsequent query when the first response is addresses-only.
[CIR] Implement array-to-incomplete-array cast (#192138)
This is a noop cast that is allowed in some situations in C++20, and is
validated with one of the test suites. This patch adds a very defensive
NYI diagnostic to replace the other one, plus implements the array decay
case.
[lld][llvm-objcopy] Enable Xbox subsystem for PE images. (#191779)
This patch enables selecting the Xbox subsystem (IMAGE_SUBSYSTEM_XBOX)
for PE images. Certain existing tools used in the Xbox homebrew scene
expect images to use the Xbox subsystem, so it's nice to be able to set
this within the LLVM toolchain instead of invoking yet another tool or
manually patching the binaries.
[flang] Recognize generic allocations in Flang LICM. (#191923)
Instead of matching particular operations like `fir.alloca`
we can use `MemoryEffectOpInterface` to figure out if a location
is a new allocation.
[analyzer] Fix alignment of entries in -analyzer-help (#190570)
Fix a formatting bug in `AnalyzerOptions::printFormattedEntry` (used by
`clang -cc1 -print-analyzer-options`), which led to misalignment of a
checker description.
This commit ensures that `printFormattedEntry` inserts a newline in the
corner case when the length of the name of a checker is exactly equal to
`EntryWidth`. (In this situation the old code inserted a space between
the name and the description, so this description was not aligned with
the other descriptions.)
Additionally this commit also fixes the corner case where the pad before
the checker name (specified by `InitialPad`) is 0. Before the fix, due
to `llvm::raw_formatted_ostream::PadToColumn` logic, `InitialPad = 0`
still added one space character as padding before the checker name.
Fortunately `InitialPad = 0` was never used in the program, so this bug
was not visible to the user.
These changes are both tested by the freshly added unit tests.
[RISCV][P-ext] Support plui.h/w in generateInstSeqImpl. (#192137)
There's some overlap in the pli/plui encodings. I've modified the code
to prefer pli.b over pli.h and to prefer pli.h over plui.h. This matches
what we do in the splat_vector path in RISCVISelDAGToDAG.
[sanitizer] Generalize FD closing in StartSubprocess (#192114)
Use internal_close_range with a fallback to the sysconf(_SC_OPEN_MAX)
loop. This removes the platform-specific #if and lets all platforms
benefit from close_range when supported.
Follow-up to #191971.
Make Passes Required - func-properties-stats and instcount (#192130)
These passes count different types of instructions and we want to see
them even though optnone is enabled
Added better datalayout incompatible error message (#191862)
The existing datalayout incompatible error assert does not help with
debugging, as it does not print the datalayouts in question.
This change makes this failure give more useful information.
[flang][OpenACC] Propagate acc.declare attribute to fir.global for USEd module variables (#192141)
When a module with `!$acc declare` is compiled separately from the
program that USEs it, `declareGlobal()` creates `fir.global` without the
`acc.declare` attribute. This causes implicit data mappings to override
device data that should already be present via `acc declare`.
The fix reads the symbol's `AccDeclare`/`AccCreate`/`AccCopyIn`/etc.
flags (already set from the `.mod` file by semantics) and attaches the
`acc.declare` attribute to the `fir.global`.
[CIR] Fix heap-use-after-free in IndirectBrOp lowering (#191949)
The previous code called op->getBlock()->eraseArgument(0) to remove a
block argument when the poison attribute was set (unreachable block with
no predecessors). This directly mutated the IR, freeing the
BlockArgument while the MLIR dialect conversion framework still held
references to it. When the framework later replayed changes in
applyRewrites(), it dereferenced the freed BlockArgument, causing a
heap-use-after-free detected by ASAN.
Found by running check-clang-cir under ASAN
(test: clang/test/CIR/CodeGen/label-values.c).
The fix removes the eraseArgument call entirely. The MLIR conversion
framework tracks block arguments and handles their lifecycle. A block
with no predecessors naturally produces no PHI node in LLVM IR, so
manual removal was unnecessary.
Additional cleanup:
[4 lines not shown]
[AArch64] Cleanup of fptosi costs. NFC (#192144)
This contains some minor formatting changes, along with moving some code
closer
to where it belongs - keeping fixed length costs together, moving a
WideTy
block before the definition and use of ConversionTbl.
[GlobalISel] use constexpr LLT types when creating ISel data (#191574)
The GlobalISel uses a lookup table to map LLTs which is constructed
prior to initialization of extended LLT functionality, resulting in
ANY_SCALAR entries. During instruction selection, a hash-based
lookup is done on actual INTEGER/FLOAT LLTs. But hash values of
ANY_SCALAR do not match those of INTEGER/FLOAT, causing a failure.
Workaround is the use constexpr LLT, which encodes INTEGER/FLOAT LLT.
Assisted-by: Claude Opus 4.6
[flang] Fixed issues in nested LICM. (#192117)
First change is to check the hoisting safety for all nested
operations of the candidate. This prevents hoistings of
region operations as in the added test.
When hoisting operations from nested regions we have to
check every parent region for `canMoveOutOf`, otherwise,
illegal hoisting may happen. This second change is NFC,
because all operations that support `OperationMoveOpInterface`
currently also support `LoopLikeOpInterface` and their regions
are not considered for nested hoisting. Anyway, it is worth
fixing it.
[NFC][VPlan] Split `makeMemOpWideningDecisions` into subpasses
The idea is to have handling of strided memory operations (either from
https://github.com/llvm/llvm-project/pull/147297 or for VPlan-based
multiversioning for unit-strided accesses) done after some mandatory
processing has been performed (e.g., some types **must** be scalarized)
but before legacy CM's decision to widen (gather/scatter) or scalarize
has been committed.
And in longer term, we can uplift all other memory widening decision to
be done here directly at VPlan level. I expect this structure would also
be beneficial for that.
[clang] Fix assertion crash in CTAD for alias templates with non-dependent type (#191885)
When building deduction guides, clang assumes that the return type of
the deduction guide would always be a dependent type
(`TemplateSpecializationType`), but this is not true for invalid case,
where the alias RHS is a non-dependent class template specialization, it
is represented as a `RecordType` instead.
Fixes #190517.