[PowerPC] Update MIR syntax for INSERT_SUBREG in tests (#219523)
Use names instead of numbers for the subreg index operands in
INSERT_SUBREG instructions.
[PowerPC] Remove assumptions about subreg index values. NFC. (#219524)
Use subreg index names instead of hard coded values in a few places in
the backend.
[SROA] Reject illegal vector memset promotion (#216772)
SROA can select vector promotion for an `alloca` partition containing a
memset and vector accesses whose element type is an unstable pointer.
We discovered this while building Julia with LLVM 21 and assertions
enabled. SROA crashed in `convertValue` because `canConvertValue`
rejected converting an integer splat to a non-integral pointer:
```
Assertion `canConvertValue(DL, OldTy, NewTy, VScale) &&
"Value not convertable to type"' failed.
```
Current main no longer asserts because `convertValue` was replaced by
`CreateBitPreservingCastChain`. However, the underlying unsupported
transformation remains.
For example:
[33 lines not shown]
[CIR] Drop call-conv-lowering opt-out from coro-task.cpp (#218990)
coro-task.cpp opted out of CallConvLowering because the pass did not
handle parameters of an empty or tag class. CallConvLowering handles
them now, so the test can run the pass and pin what it produces.
complex_co_await has one non-empty value in the modified CHECK lines. We
now lower complex correctly as well.
Assisted-by: Cursor / claude-opus-5
[AMDGPU][NFC] Unify getImmOrMaterializedImm and getFoldableImm (#219522)
`getImmOrMaterializedImm` and `getFoldableImm` both determine if an
operand has a constant value. Make a unified implementation that
supports the interfaces of both using the `getImmOrMaterializedImm`
name.
Signed-off-by: John Lu <John.Lu at amd.com>
[AMDGPU] Add the 3-dword image_gather4 variant for packed D16 + TFE (#215972)
MIMG_Gather only defined V2/V4/V5 destination-dword variants, so a d16
gather4 with tfe (which needs 3 dwords on packed-D16 targets) hit
"Cannot select" on gfx10+
[RISCV] Move combineANDOfSETCCToCZERO to isel patterns. (#219318)
This allows us to reuse RISCVDAGToDAGISel::selectSETCC to pick
the best instruction when comparing against a constant.
[lldb] Fix SBAPI breakage in SBFrame::GetValueForVariablePath (#218565)
SBFrame::GetValueForVariablePath added new parameters in commit
80fffd527c20ac8970fbffc37c674caa17faa815.
This caused an ABI break because
the ABI is based on the function's mangled name, which changes when
parameters are added. Existing users depend on the original symbol being
present in the library.
changing the ABI from:
```cpp
// _ZN4lldb7SBFrame23GetValueForVariablePathEPKcNS_16DynamicValueTypeE
lldb::SBFrame::GetValueForVariablePath(char const*, lldb::DynamicValueType)
```
to
```cpp
// _ZN4lldb7SBFrame23GetValueForVariablePathEPKcNS_16DynamicValueTypeENS_7DILModeE`
lldb::SBFrame::GetValueForVariablePath(char const*, lldb::DynamicValueType, lldb::DILMode)
```
[45 lines not shown]
[clang-format] Add BraceWrapping.AfterRequiresExpression option (#216465)
Thir PR adds a `BraceWrapping.AfterRequiresExpression` sub-option that
wraps the opening brace of requires expressions, and enable it in the
`Allman`, `Whitesmiths`, and `GNU` presets of `BreakBeforeBraces`.
The brace is only wrapped if the requires expression doesn't fit on a
single line, matching the behavior of `BeforeLambdaBody`. The wrapped
brace is aligned with its closing brace:
```cpp
template <typename T>
concept Uart = requires(T a)
{
{ a.write() } -> std::convertible_to<std::size_t>;
a.flush();
};
```
Closes: #202901
[llvm] Change the implementation of isValidFeatureListFormat (#219266)
This is mostly to change the function-local static variable because some
programs are having static initialization order problems. Also the
coding standard states statics with ctor/dtor should be avoided. The new
implementation also does not use Regex anymore.
[CIR] Flush the type cache when an enum completes differently
An enum that is still incomplete converts to a guessed !u32i, since it has no
CIR type of its own to complete later the way a record does. If the definition
disagrees with the guess, everything already converted from it is wrong.
We now flush the cache when the definition contradicts the guess, so anything
derived from it is rebuilt.
A signature converted while the enum was incomplete keeps the guess, so a
declaration can still name the wrong width where classic leaves it
unprototyped. Nothing emitted reads that signature, since call sites bitcast
the callee to the type the definition gave the enum, and a definition of the
function gets a fresh signature.
Assisted-by: Cursor / claude-opus-5
[libc] Add placeholder for sys/mount.h Linux header. (#219127)
Provide `<sys/mount.h>` header on Linux platforms. This header doesn't
yet contain the entrypoints (mount, unmount, unmount2), but has a
collection of `MS_` symbolic constants that should be passed as
arguments to `mount` syscall wrapper.
This is an interesting case, since header is a non-POSIX, and contains
different information on Linux and on BSD systems (macro are named
differently, functions have different prototypes, etc.). We may decide
how to approach this at the point when we add function prototypes. For
macro, we're in a slightly better shape, as there's existing support for
OS-specific macro definitions that we're using here.
Assisted by: automated tooling, human-reviewed
[CIR] Implement indirect-field accesses (#219505)
Anonymous structs/unions cause an 'indirect field' declaration, which
contains the path with how to get through it. We were missing handling
in 2 places:
1- At emitTopLevelDecl, which we just need to ignore it (as the global
itself handles the emit)
2- When generating the get-member pointer value. This just requires us
to properly follow the 'field' chain.
[CIR] Fix materialize-temporary-expr for non scalar/aggregates (#219514)
The reproducer I added came from a test suite, and identified that our
MaterializeTemporaryExpr handling used cir::ZeroAttr::get, which only
handles aggregates, but we needed a double. This fairly simple change
just replaces that with a call to builder.getZeroInitAttr.
Update clang/include/clang/ScalableStaticAnalysis/Analyses/EntityPointerLevel/EntityPointerLevel.h
Co-authored-by: Balázs Benics <benicsbalazs at gmail.com>
[SSAF] Remove useless anchor variable from test plugin (#219081)
The plugin code defines the extern variable
SSAFTestTransformationAnchorSource, which is supposed to be used to
force static linking, so not needed here.
The variable definition should undoubtedly be removed, as doing so
solves the build issue locally. The explanation below regarding why this
variable causes the issue was provided by Claude. I repeatedly asked
Claude questions, and he revised his reasoning several times until it
became consistent. However, we should still take the following
explanation with a grain of salt:
ASan created a private alias symbol for the extern variable
SSAFTestTransformationAnchorSource. The linker, when in
'-flat_namespace' mode, treated the symbol as a name-based bind, which
later failed to be resolved through name searching by the loader.
rdar://185749574
Assisted by Claude
Improve metadirective loop test
Existing checks could miss duplicate loop operations, match operations outside
the intended region, or overlook incorrect loop-IV data flow.
Add region boundaries and negative checks for unexpected loop operations.
Verify private and linear IV usage across static, runtime, ENTRY, NOTHING, and
nested-loop lowering paths.
RuntimeLibcalls: Introduce LibcallLibrary schema (#217592)
Currently the set of system libraries calls is flat and
disorganized. Begin organizing this per-provider library.
The goal is to organize groups of functions by named sets,
corresponding to the underlying library which will be linked.
A LibcallLibrary is a named runtime library whose impls are made
available as a unit; its members use the same dag vocabulary as
LibcallImpls. The emitter emits one setAvailableLibFuncs_<name>
per distinct library name, merging same-named libraries under their
per-variant availability predicates. isLibraryAvailable()
is added as a stub for a future dispatch driver. No target
defines a LibcallLibrary, so generated output is mostly unchanged
(there are some incidental enum reorderings).
Reorganizing all of the library functions require a good bit more
infrastructure to be practical, but this is a minimally functional
piece to start the review.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[SCEV] Consider IVMayOverflow to use cheap BE-count formula. (#218694)
If !IVMayOverflow, we proven RHS + stride - 1 does not wrap. This means
adding the `Stride - 1` part of `RHS - (Start - Stride) - 1` does not
wrap.
Together with the other condition `Start - Stride < RHS`, this should
guarantee `RHS - (Start - Stride) - 1` does not wrap and the cheap
formula can be used.
This triggers in a number of real-world cases, mostly resulting in
simpler SCEV expansions/checks, and extra unrolling. In a small number
of cases, expansion is slightly worse.
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1043
Alive2 Proof: https://alive2.llvm.org/ce/z/u_KUx5
Depends on https://github.com/llvm/llvm-project/pull/218251
PR: https://github.com/llvm/llvm-project/pull/218694
[clang][Modules] Restore module search on the MODULE_MAP_FILE relocation check (#219521)
cf8597bd3b87 (#181836) refactored the two relocation-check call sites in
ASTReader into `getModuleForRelocationChecks` with the `DirectoryCheck`
flag passed to `lookupModule`. The change did not preserve the original
functionality for `ASTReader::ReadModuleMapFileBlock`
(https://github.com/llvm/llvm-project/commit/cf8597bd3b87aeed6696454f22311e86ed70138f#diff-c61a3cce4bfa099b5af032fa83cbf1563f0af4bf58dc112b39571d74b6b681c1L4586).
`ASTReader::ReadModuleMapFileBlock`'s `lookupModule` relied on the
default value of `AllowSearch`, which is `true`. Passing `false` to
`getModuleForRelocationChecks` changes how module lookup works, and
clang can prematurely stop looking when a `MODULE_DIRECTORY` record is
not present in the pcm (e.g. when `-fmodule-file-home-is-cwd` is in
effect).
Assisted-by: Claude (Claude-Opus-5)
[libc] Add redirecting headers sys/vfs.h and sys/syslog.h on Linux. (#219118)
* `<sys/vfs.h>` is a Linux header for providing `statfs` function, and
can be used interchangeably with `<sys/statfs.h>`
(https://man7.org/linux/man-pages/man2/statfs.2.html). Simply redirect
the former to the latter, as `statfs` is already implemented.
* `<sys/syslog.h>` is frequently used instead of POSIX-specified
`<syslog.h>` header, so create the redirecting alias for it as well.
This would fix one of the problems in issue #97191 (building Clang
against LLVM-libc), since `<sys/vfs.h>` is actually used by LLVM
Support.
[libc] Fix types provided by fcntl.h header. (#219121)
According to POSIX, `<fcntl.h>` header should provide definitions for
`f_owner_ex` structure, `flock` structure, as well as `mode_t`, `off_t`,
and `pid_t` types. Reflect that in the YAML definition to ensure
generated `<fcntl.h>` indeed provide them. The type definitions
themselves were already present in the LLVM-libc.
This fixes another problem while building Clang on Linux against
LLVM-libc (issue #97191)