Attributor: Don't report a change when no functions are internalized
internalizeFunctions returned true for an empty set, so this reported
a change for every module and invalidated all function analyses even
when it did nothing.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
OpenMPOpt: Invalidate function analyses individually
Avoid discarding analyses that never need to be invalidated, such as
TargetLibraryInfo.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Attributor: Decide which instructions access memory in the opcode switch (#241115)
initializeInformationCache already switches over the opcode of every
instruction, and then called mayReadOrWriteMemory out of line for each
one. Decide in the switch instead, where only calls need to check their
memory effects.
Instruction counts (callgrind) with other pending attributor-light
changes applied: attributor-light sqlite3 -0.79%, kimwitu++ k -0.32%,
SPASS cnf -0.31%, consumer-typeset z08 -8.59%; the full attributor
-0.02% to -0.08%.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
ExpandVariadics: Report a change when rewriting a function without calls
This only reported a change if it rewrote a call, but it always
rewrites the function itself. In lowering mode a variadic function
without callers was changed without being reported.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[X86][MC] Fold parenthesized register scale expressions (#237899)
Fix incorrect scales in Intel memory operands such as `rbx*(1+1)` and
`rbx*(4/2)`, which currently use scales 1 and 8 instead of 2.
Evaluate parenthesized constants with the existing intel expression
parser, preserving named operators. Validate the full-width scale and
diagnose division/modulo by zero, signed division overflow, and invalid
shift counts.
Validation:
- 713 selected X86 MC and llvm-ml tests passed with assertions enabled.
- 537 supplementary local checks passed across 16/32/64-bit modes.
Partially addresses #150427. Expressions such as `(rax+1)*2` remain
outside this change.
[X86] Fix spill folding of zero-extending mask moves (#240833)
`KMOVBkk`, `KMOVDkk` and, with BWI, `KMOVWkk` zero the mask bits above
their width, but `X86InstrInfo::isCopyInstrImpl` reports them as copies.
Since 4d42e8b5 (D150388), spill folding then replaces such a move with a
spill of its source, so the zero extension is lost (#240463).
Spill folding is correct for real copies, so this patch stops treating
these moves as copies: `KMOVBkk`, `KMOVDkk` and their `_EVEX` forms are
no longer marked `isMoveReg`, and `isCopyInstrImpl` excludes `KMOVWkk`
when BWI is available. Without BWI, `KMOVWkk` moves the whole mask
register and stays a copy.
Fixes #240463
Assisted-by: Claude Opus 5.5
[Clang] Fix qualifiers of ext vector components accessed via `->`
For `p->x` where `p` points to an `ext_vector_type` vector, Sema takes the
qualifiers from the type of `p`, which is the pointer itself, instead of the
vector it points to. As a result, `p->x = 1` is accepted even if `p` points to a
`const` vector, while `(*p).x = 1` is rejected. An address space on the vector
is lost in the same way.
This PR takes the qualifiers from the vector for both `.` and `->`. A swizzle
that repeats a component, e.g. `v.xx`, is a computed value, so it doesn't get
any qualifiers.
This PR was assisted by AI but I reviewed all the changes.
[flang][OpenMP] Evaluate composite DISTRIBUTE clauses outside PARALLEL
In composite DISTRIBUTE PARALLEL DO [SIMD], omp.distribute is nested
inside omp.parallel, and the DISTRIBUTE clauses were evaluated after
omp.parallel was created. A DECLARE VARIANT call in the DIST_SCHEDULE
chunk-size expression therefore matched construct={parallel}, although
DISTRIBUTE encloses PARALLEL in the source, and every thread evaluated
the expression.
Evaluate the DISTRIBUTE clauses before creating omp.parallel, as for the
explicit nesting, and destroy their temporaries once, after omp.parallel.
Fixes #244760
Assisted-by: GitHub Copilot
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
Utils: Preserve function analyses in CanonicalizeAliases and NameAnonGlobals
These passes only change aliases and the names of globals, so they do
not need to invalidate any function analyses.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CodeGenPrepare][X86] Add tests for sinking GEPs (#242745)
Pre-commit tests for sinking the GEPs computing the address of a
gather/scatter into its block.
This is a preparation for the PR that addresses FIXME in CodegenPrepare.
(https://github.com/llvm/llvm-project/pull/242746)
[clang-tidy] Fix SARIF test missing '--' (#244927)
[clang-tidy] Fix SARIF test missing '--'
export-SARIF-diagnostics-macro-thread-flows.cpp was missing a "--" that
caused this test to fail.
Co-authored-by: Jones, Matthew (DI SW SIM FRWK PLAT SIMFW HPC) <jones.matthew at siemens.com>
[CMake] Update regex to match typed arguments (#244963)
The regex used to match arguments in the cross-compiling case didn't
account for types and would fail to match.
[CMake] Fix variable name shadowing (#244962)
The append_passthrough_options macro has an argument named type, but it
also reads the property into the variable of the same name. Because
CMake macros perform textual substitution of the ${type} argument before
dereferencing the ${type} variable, passthrough options are emitted as
-DCMAKE_CXX_FLAGS:RUNTIMES=... instead of -DCMAKE_CXX_FLAGS:STRING=...
Attributor: Don't report a change when no functions are internalized
internalizeFunctions returned true for an empty set, so this reported
a change for every module and invalidated all function analyses even
when it did nothing.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
PHIElim: Trim PHI source subranges without a full shrinkToUses (#228488)
This contains a repurposed version of #226209, plus a supplemental fix
branch which was never posted. #228073 was an alternative implementation which
landed first; this replaces the brute-force shrinkToUses with targeted live range
adjustments. Some crude stress test benchmarking suggests this is 2-4x
faster measuring the pass in isolation.
shrinkToUses rescans every use of each subrange which is much more than is
necessary. The only segments that need changing are the ones ending at the
inserted phi source copies. Instead, track the per-lane copies as they are inserted
and trim each lane at its last read, clamped to the predecessor block, and stop
SplitCriticalEdge from extending subranges for lanes the PHI does not read. This
keeps the live ranges correct while avoiding the per-subrange rescans. The
shrinkToUses implementation's cost scales with the number of uses, but this remains
relatively flat. An example with 640 uses is 7.2x faster.
Because this edits segments surgically instead of recomputing them, it has to get the
bounds exactly right in cases shrinkToUses handles. The clamp to the predecessor
[14 lines not shown]
[lldb] Intern remaining SB API strings in the right pool (#244422)
Strings returned straight from a ConstString now go through the system
pool, or the owning debugger's pool. Only the strings that live in the
object itself (such as SBError, SBCommandReturnObject) and static
literals are left as they are.
SBDebugger::GetVersionString continues to use the global pool because it
can be called before SBDebugger::Initialize.
Assisted-by: Claude
[libc] Add strcmp benchmark
To guide some optimization work around implementing an optimized strcmp
implementation.
Assisted-By: LLM
Reviewers: petrhosek
Pull Request: https://github.com/llvm/llvm-project/pull/244924
[libc] Add a benchmark for strlen
Add a benchmark for strlen to guide optimization efforts.
Just reuse the SearchSetup that memchr uses by making it put a \0 at the
end.
Reviewers: petrhosek
Pull Request: https://github.com/llvm/llvm-project/pull/244923