[RISCV] Make cost of wide constant with MUL user free if can lower to shifts (#248199)
Prevents hoisting of such constants.
AI Usage: Codex assisted review and test generation.
[diagtool] Parse find-diagnostic-id arguments without cl::opt (#246761)
Parse the find-diagnostic-id command line by hand, like the other
diagtool subcommands, as part of removing cl::opt from clang/. LLVM's
global options (e.g. -debug-only, --version) are no longer accepted.
LLM-aided
Co-authored-by: Aaron Ballman <aaron at aaronballman.com>
[AMDGPU] Replace constant uses of LDS variables in the object linking mode
In the object linking mode, `AMDGPULowerModuleLDS` moves an LDS variable into a
struct and replaces the uses of the variable in instructions. A use outside
instructions, for example in the initializer of a table in global memory, kept
the old variable as an LDS definition next to the struct. Code that read the
address from the table then used another location than the instructions, and
`AMDGPUAsmPrinter` stopped at the assertion for LDS definitions.
The LDS lowering for ASan (`AMDGPUSwLowerLDS`) makes such a table for the LDS
slot of each kernel. So in object linking mode, ASan code crashed when a
non-kernel function used LDS.
Since the linker does the allocation in object linking mode, the remaining uses
now get the same field of the struct, after the variables are removed from the
used lists.
[mlir][Presburger] NFC: Mark set ops nodiscard (#247433)
Mark PresburgerRelation, PresburgerSet, IntegerRelation, and
IntegerPolyhedron methods that return a new set or relation (such as
complement, subtract, intersect, coalesce, and simplify) [[nodiscard]]
so callers do not confuse them with in-place mutators such as
IntegerRelation::simplify. Remove a discarded complement() call in a
unit test.
Assisted-by: gemini-4-carbon
[CIR][OpenACC] Attach acc global variable interfaces (#244313)
Attaches the OpenACC dialect operation interfaces to `cir.get_global`
and `cir.global` which are used for implicit `acc declare`
determination.
Along with it, the OpenACC passes are registered so they can run through
`cir-opt` and a new test folder to hold the IR tests for OpenACC dialect
Transforms.
[MLGO] Reject EmitC models with mismatched input buffer sizes (#242629)
Since #224598 a tensor can be wider than the compiled field, so writing
a tensor wider than the compiled field corrupted the heap
Report an error and fall back to the default advisor instead, as the AOT
runner does
Requires https://github.com/llvm/llvm-project/pull/242627
[mlir][Presburger] Fix MAF duplicate div merging (#247440)
When MultiAffineFunction::mergeDivs merges duplicate division j in
`other` with division i in `this`, it removes column j from
`other.output`. Before removing column j, it added column i into column
j instead of adding column j into column i, dropping the duplicate
division's output coefficients.
As a result, unionLexMin and unionLexMax compared the wrong expressions
when two pieces shared a division.
Also remove the outdated comment on unionLexMin and unionLexMax stating
that pieces with divisions are unsupported.
Assisted-by: gemini-4-carbon
[flang] Inline scalar hlfir.transfer
Add a SimplifyHLFIRIntrinsics pattern for TRANSFER with a scalar MOLD
and without SIZE when the storage size of SOURCE is a compile time
constant. Trivial results are loaded from SOURCE storage if it is large
enough and suitably aligned, or copied into a temporary otherwise. Other
results are evaluated with an hlfir.eval_in_mem that copies the bytes of
SOURCE, so that the bytes can be copied directly into the LHS of the
assignment.
For instance, no temporary and no runtime call are needed anymore for:
integer(8) :: codes(100)
character(8) :: tags(100)
do concurrent (j = 1:100)
tags(j) = transfer(codes(j), tags(j))
end do
Like the runtime, the bytes of the result that are not covered by SOURCE
[19 lines not shown]
[flang] Lower TRANSFER to hlfir.transfer
Use the new hlfir.transfer operation when lowering TRANSFER, including
when its arguments are polymorphic.
Logical actual arguments computed as i1 values are converted to the
logical kind of their Fortran type before the operation is created.
Tests checking the code generated by the intrinsic library for TRANSFER
now check the FIR produced after hlfir.transfer has been lowered.
[flang][Frontend] Add -fexperimental-openacc-exec (#247270)
The flag enables experimental support for executing OpenACC
constructs. Plain -fopenacc stays as it is, and the constructs that are
not supported yet are still rejected when it is given. The driver passes
the flag to the frontend, and the frontend keeps it in the language
options. It will be used as a language option to relax the current
errors that get emitted for unsupported acc constructs in order to
enable experimental OpenACC execution.
Assisted-by: Claude Sonnet 5.5
---------
Co-authored-by: Tarun Prabhu <tarun at lanl.gov>
[ARM] Remove M7/M85 scheduling global. NFCI (#247714)
This removes the InstructionInformation used in M7 and M85 scheduling,
that originally used a global and was attempted to change to a
ManagedStatic recently. Instead of creating an array of Info for each
instruction, the relevant pieces of information are queried on the fly.
The compile time impact, according to my measurements was not
significantly impacted.
Co-authored-by: Alexis Engelke <engelke at in.tum.de>
[clang] Register builtin identifiers lazily; share a name index (#243274)
Every compilation used to create an identifier for each builtin of its
target and language upfront, in
`Builtin::Context::initializeBuiltins()`. That's ~12,000 identifiers for
AArch64 (mostly NEON, SVE and SME) and ~3,400 for x86-64, for every
`CompilerInstance`, including every implicit module build, while typical
translation units and modules only use a few dozen of them.
This PR has two commits, best reviewed separately.
---
### 1. Register builtin identifiers lazily
The `IdentifierTable` now assigns the builtin ID when it creates an
identifier: it asks `Builtin::Context::lookupBuiltinID()` whether the
name is a builtin that its `LangOptions` support. An empty AArch64 C
file now creates 874 identifiers instead of 12,896.
[91 lines not shown]
[ValueTracking] Add coverage for isKnownToBeAPowerOfTwo SQ migration (#248498)
The change a5260d8b2 ([ValueTracking] Remove non-SimplifyQuery
isKnownToBeAPowerOfTwo() overload (NFC), #248456) is not actually
non-functional, and enables more folds in InstCombine and fixes a
miscompile in NewGVN, by virtue of not overriding information already
present in SimplifyQuery. Add tests covering this.
Proof: https://alive2.llvm.org/ce/z/_LGmec
Assisted-by: llm
[InstCombine] Fold the bitcast of byte load to ptr load (#248392)
Follow-up on the comment on #240168:
Fold a load of byte type followed by a one-use bitcast
to a direct load of that type.
[clang][X86] Report source FP eval method when x87 is not used (#245660)
Solves an issue in the clang frontend: when x87 is disabled (e.g.
`-mno-x87`) or the soft-float target feature is set,
`__FLT_EVAL_METHOD__` is reported as 2 (everything is computed in long
double), even though nothing runs on x87, and `-ffp-eval-method=source`
warns.
GCC reports 0 (each operation is computed in its own type: float in
float, double in double) in these cases
For example, seen in picolibc libm built with soft-float and
`-mlong-double-64`, where `fma` calls itself.
`-msoft-float` in the driver keeps x87 on x86, so it still reports 2.
Fixes #198405
Assisted-by: Claude
[2 lines not shown]
[flang] Fix inline REAL MOD for quotients outside the integer range (#244466)
With -ffast-real-mod (implied by -ffast-math), MOD(A, P) for REAL
arguments is inlined as `A - REAL(INT(A/P))*P`, where the intermediate
integer has the same width as the REAL (8aa64edb34ec6). fir.convert
lowers the float-to-integer step to llvm.fptosi.sat, so a quotient
outside the integer range is clamped. MOD then returns approximately A
instead of a value bounded by P. This happens once `|A/P| >= 2^31` for
REAL(4), `2^63` for REAL(8) and `2^15` for REAL(2).
For example:
```
REAL, VOLATILE :: B, C
INTEGER, VOLATILE :: IB
C = 3.0
! B = 2.7631963E+23 (-O3 value), exact MOD(B,3) = 1
IB = INT(Z'666A0D45')
B = TRANSFER(IB, B)
PRINT '(Z8.8,1X,ES16.8,1X,ES16.8)', IB, B, MOD(B, C)
[37 lines not shown]
[AMDGPU] Rejoin half-zero packed i32 halves in performOrCombine (#240724)
Add a performOrCombine rule that recognizes an or of two 32-bit values
whose known-zero halves are complementary, and folds it back into a
single packed v2i16 build_vector:
` (or (bitcast (v2i16 build_vector 0, Hi)), (zero_extend i16:Lo))
-> (bitcast (v2i16 build_vector Lo, Hi))`
The replacement build_vector:
- On GFX11+ targets it becomes a REG_SEQUENCE of two 16-bit
subregisters, i.e. at worst a single v_mov_b16 into .h.
- On GFX10 it selects to v_perm_b32
- On GFX9 the v_perm_b32 byte-selector mask needs an extra s_mov_b32 to
materialize, so skipped
Codegen effect
```
- v_and_b32_e32 v0, 0xffff, v0
[9 lines not shown]
[Hexagon] Make global scheduler V2 deterministic (#248187)
Use SetVector and DenseMap for containers the pass iterates or looks up,
and llvm::stable_sort for regions and clusters, so pointer values and
std::sort tie order no longer affect the output.
Assisted by AI
[Hexagon] Replace combines with REG_SEQUENCE (#247702)
Combines that build a register pair (A2_combinew, V6_vcombine,
LX_combine_w) were kept through register allocation when nothing earlier
removed them. For HLX this left an extra combine in loop bodies:
{ L11:10 = combine(L11,L10) }
HexagonPeephole now rewrites any instruction with isRegSequence and a
virtual destination into REG_SEQUENCE, so the register coalescer can
assign both halves directly to the pair. A2_combinew gets the
isRegSequence flag; V6_vcombine and LX_combine_w already had it.
-disable-combines-to-regseq turns this off.
Assisted by AI
Co-authored-by: Ikhlas Ajbar <iajbar at qti.qualcomm.com>
Co-authored-by: Krzysztof Parzyszek <kparzysz at qti.qualcomm.com>
Fix regression with __has_embed on file that cannot be read
It's unclear if it is desirable, but it's the current behaviour of
clang and gcc that __has_embed is resolved on files that cannot be read, so
avoid changing behaviour even in PCH/modules that use them as inputs.
Independently of whether we want unreadable files to be __has_embedable, this
is slightly better in that it avoids reading such files unnecessarily, and
avoids rebuilding modules when such files change their contents/mtime but not
their size. In principle we could go further and only rebuild if the size
changes between 0 and non-zero, but that would require special handling in the
ASTReader instead of just falling out of existing checks, so I don't think it's
worthwhile.
[Sparc] Remove write-only SparcRegisterInfo::Is64Bit (NFC) (#248364)
The last reader was removed on September 17, 2026 in commit
cd6dab01e6b968fe9eacd417777afb1e1ba7b676. This patch also removes its
initializer and the now-unused STI constructor parameter.
Assisted-by: Antigravity
[Instrumentation] Remove write-only and unused member variables (NFC) (#248363)
FunctionStackPoisoner::IntptrPtrTy: The last readers were removed on
October 14, 2025 in commit 489a921796fe8d33de0f055ca6084e8f54cb1d84.
This patch also removes its initializer.
MemorySanitizerVisitor::OriginPHINodes: Added on November 29, 2012 in
commit d4bd7b73e370eb429d1d2ef884967b88a299b763 without any uses.
FuncPGOInstrumentation::TLI: The last reader was removed on July 11,
2023 in commit 95014050dac528f53ab704d62a16a44ed0df032b. This patch
also removes its initializer.
Assisted-by: Antigravity