[clang][Sema] Fix false-positive -Wshadow for friend functions (#221249)
A friend function defined inline in a class body has no implicit `this`,
so a parameter with the same name as a field cannot actually shadow it.
`CheckShadow` only exempted static members and members with an explicit
object parameter, it never handled the case where the enclosing function
isn't a member function at all, which fell through to the generic
diagnostic. In this PR I extend the exemption to cover that case and
added the regression test.
In this PR, I used Claude to help navigate the codebase and explain key
functions.
Fixes #221190
[Profcheck] Exclude two new tests (#223690)
Exclude these tests for now. We haven't gotten to AtomicExpand/ARM yet,
and the AggressiveInstCombine change is overlapping.
PowerPC: Remove LiveVariables dependency from PPCMIPeephole
PPCMIPeephole only used LiveVariables to keep kill/dead flags valid after its
transforms, and made no real use of the analysis.
A later LiveVariables run recomputes those flags from scratch anyway, so
just clear possbly stale kill/dead flags on changed registers.
PPCMIPeephole was the only user of LiveVariables at this point in the
pipeline, so also drop the explicit LiveVariables run before
PPCTLSDynamicCallPass, whose comment references a > 10 year old build
bot failure.
Co-authored-by: Claude (Claude-Opus-4.8)
RegisterPressure: Remove dead defs correctly
When an instruction has overlapping register defs where only some carry the
dead flag (for example a dead super-register def alongside a live sub-register
def), the collector left the shared register units in both the live and dead def
sets. That produced a PressureDiff decrement with no matching increment and tripped
the "PSet overflow/underflow" assertion in getUpwardPressureDelta.
A register unit is dead if any def covering it is dead, regardless of operand
order. Reconcile by subtracting the dead defs from the live defs instead of the
reverse: removeRegLanes only clears the overlapping units, so a def keeps any
units a dead def does not cover.
Fixes #155807.
Fixes #149144.
Fixes #76416.
Fixes #205272.
Co-authored-by: XChy <xxs_chy at outlook.com>
Co-authored-by: Claude claude-opus-4.8 <noreply at anthropic.com>
[SCEV] Return a SCEVUse from getAddRecExpr and propagate use flags. (#221606)
Same as https://github.com/llvm/llvm-project/pull/220007 but for
getAddRecExpr:
Pass both expression and use specific flags to getAddRecExpr and
propagate the use flags, if valid conservatively. That is, the final expression
forms an AddRec with the same operands. For example, it is not valid to
propagate the use flags if other (sub-)expressions have been inlined.
It also includes a few mechanical changes, to update users that still
expected const SCEV *.
PR: https://github.com/llvm/llvm-project/pull/221606
AMDGPU: Maintain LiveIntervals when removing blocks in SILowerControlFlow
removeMBBifRedundant removed a redundant block's instructions from the
LiveIntervals maps but not the block itself, leaving a stale idx2MBBMap entry
that crashed getMBBFromIndex in the verifier.
Add SlotIndexes::removeMBBFromMaps to drop the erased block's slot range, and
recompute the intervals that spanned it.
Co-authored-by: Claude claude-opus-4.8 <noreply at anthropic.com>
[AMDGPU] Model the cost of the expanded integer to/from floating point casts
No instruction converts to or from a 64 bit integer, and narrow vector
lanes are converted one at a time. Price these expansions by the FP64
rate, sdwa and 16 bit instruction support, and price i33 to i63 like
i64 and bf16 like f32 plus rounding.
Assisted-by: Claude Code Opus 5
[NFC][AMDGPU] Add cost tests for integer to/from floating point casts (#223571)
Cover i48, i64, i128, bf16, fp128 and narrow vector lanes across FP64
rates, 16 bit instructions, sdwa and both cost kinds.
Assisted-by: Claude Code Opus 5
[NFC][AMDGPU] Fix two code quality issues in AMDGPUSwLowerLDS
- NumStaticLDS is always a positive number, so it was always true
- Potential `Changed = true` was dropped in the loop
[MSVC][Demangling] Respect MSDF_NoCallingConvention for function pointers (#209113)
The goal is to update MSVC demangling so that we control whether we
display a function pointer as `void (__cdecl *funcPtr)(void)` or `void
(*funcPtr)(void)`, by abiding by the `MSDF_NoCallingConvention` flag.
It is not a one-liner because function pointers used to use a trick
where it would unconditionally drop all the flags and pass
`OF_NoCallingConvention` to output the calling convention inside the
parentheses. In order to respect `MSDF_NoCallingConvention`, we need to
get rid of this trick.
A side effect of the trick was that OF_NoReturnType was also lost, which
is actually good because dropping the return type of a named function is
unambiguous, but dropping the return type of a function pointer loses
important information. The fix enforces that behavior explicitly.
This change can have impact for end-users who always passed
MSDF_NoCallingConvention, but I believe that this new behavior is the
[2 lines not shown]
[MISched] Fix pre-RA pickOnlyChoice tracing (#223182)
Add missing tracePick calls. Now GenericScheduler and
PostGenericScheduler tracing coverage is complete. Add a stable only1
test for pre-RA scheduling.
[AggressiveInstCombine] Guard memset with length in [0, 1] (#213240)
Use computeKnownBits to identify nonconstant memset lengths whose
possible values are limited to zero and one. The check is integrated
into the existing instruction loop in foldUnusualPatterns via the
dedicated helper foldMemSetZeroOrOneLength.
Insert a conditional branch around the memset and specialize the
executed path to a constant length of one. A following InstCombine
pass can then replace it with a byte store, including for a
nonconstant fill value.
Do not transform wider ranges such as [0, 2].
Fixes #213027.
Assisted by GPT-5
[ARM] Emit llvm.clear_cache for __clear_cache() (#223398)
It looks like the ARM-specific __clear_cache() builtin emits different
IR than the generic __builtin___clear_cache() builtin (added later),
which uses the llvm.clear_cache intrinsic (which will typically lower to
a __clear_cache libcall, of course).
Use llvm.clear_cache for __clear_cache() as well, for consistency and to
slightly simplify the code.
[ARM] Add Neon costs for vrev shuffles (#223310)
This, like for AArch64 and MVE, allows some of the legal vrev shuffle
masks to be costed as if they are a single instruction, which can help
prevent the mid end from deoptimizing the code.
[CMake] Prune dead and unnecessary try_compiles from config.h (#223600)
Several config-ix checks either have no consumer or can be performed
directly by the source that needs the feature. Remove six compiler
invocations from a typical Linux configure:
* HAVE_PTHREAD_MUTEX_LOCK has been unused since LLVM switched its mutex
implementation to std::recursive_mutex in 2019.
* The Linux magic-header results have never been propagated to config.h,
so CMake builds already use Path.inc's fallback constants.
* FE_ALL_EXCEPT and FE_INEXACT can be tested directly after including
cfenv.
* The Valgrind and CrashReporter headers can be detected with
__has_include in their only consuming translation units.
Also remove the obsolete definitions from the GN and Bazel
configurations.
In a fresh minimal LLVM configure, CMake profiling attributed 2067.1 ms
[3 lines not shown]