[libc][bazel] Adds missing targets for double smoke tests (#226823)
part of #223714
pr adds the missing bazel targets for the existing double smoke tests
[Clang][OpenMP] Fix crash on `safelen` and `simdlen` of different types (#228700)
Fixes #108367
When a `simd` directive has both `safelen` and `simdlen`, Sema checks
that `simdlen` is not greater than `safelen`. It compared the two values
with `APSInt`'s `operator>`, which needs both operands to have the same
bit width and signedness. But each clause keeps its argument in the type
it was written with, so in `safelen(11111111111) simdlen(1)` one value
is 64 bits wide and the other 32, and the comparison asserted. Mixed
signedness, as in `safelen(8u) simdlen(4)`, hit a second assertion on
the same line. A build without assertions rejected the valid code
instead, as if `simdlen` were the larger value.
The check now uses `APSInt::compareValues`, which extends the operands
to a common width and handles mixed signedness, so the values themselves
are compared. The error is still emitted whenever `simdlen` is larger
than `safelen`.
[CodeGen] Declare command line options in TableGen
Move the cl::opts of TargetPassConfig.cpp and CodeGenPrepare.cpp into
CodeGenOptions.td, private to lib/CodeGen; other files will follow.
-enable-machine-outliner (cl::ValueOptional) and -regalloc
(RegisterPassParser) stay cl::opt.
CodeGenPrepare and its addressing-mode helpers hold
`const CodeGenOptions &Opts`; TargetPassConfig functions read
CodeGenOptions::Global. getCGPassBuilderOption() converts
std::optional<bool> members to the cl::boolOrDefault fields of the
public CGPassBuilderOption. -basic-block-section-match-infer, which was
not cl::Hidden, is now listed by -help-hidden only.
Aided by Opus 5.5
[CodeGen] Stop exporting cl::opts. NFC
AMDGPU reads -misched-prera-direction and -verify-misched, every
target's TTI reads -partial-unrolling-threshold through BasicTTIImpl.h,
and AsmPrinter reads -emit-bb-hash through extern declarations. Add
getters for them, move inline code that reads options (LiveIntervals,
MachinePipeliner, MIR2Vec) out of line, and let unittests use default
weights, so that the options can be file-local.
Aided by Opus 5.5
[CIR] Reject language address spaces in DirectToLLVM pointer conversion
Reject unlowered language address spaces in pointer types when bypassing TargetLowering. Guard pointer-producing lowerings, including generated patterns, so failed conversions report legalization failures instead of silently selecting address space zero or constructing invalid LLVM operations.
Assisted-by: Codex / GPT-6
[CIR] Propagate initializer type adjustment failures
Reject initializers whose active members have no LLVM representation, including when an enclosing union's storage type is convertible. Propagate recursive adjustment failures before querying data layout or constructing LLVM operations.
Assisted-by: Codex / GPT-6
[CIR] Propagate type conversion failures in DirectToLLVM
Propagate failed type and constant conversions through DirectToLLVM so unsupported types produce legalization failures instead of invalid LLVM operations or a void function result.
Assisted-by: Codex / GPT-6
[Clang] Keep scope annotations covering typo-corrected qualifiers (#223978)
Fixes #221890
While tentatively deciding whether `(void(foo::S<int>))` is a type-id,
the parser annotates `foo::S<int>`. Lookup of `S` in `foo` fails, typo
correction suggests plain `S`, and Sema rebuilds the `CXXScopeSpec`
without the qualifier. The annotation token takes its start from that
scope specifier, so it only covers `S<int>` and the already-consumed
`foo ::` tokens are never replaced in the token cache. They resurface
after the tentative parse backtracks, every later parse sees `foo ::
<type>`, and the second `isTypeIdInParens()` in
`ParseCXXAmbiguousParenExpression` contradicts the first.
The parser owns the invariant that an annotation replaces every token
consumed to produce it, so the fix lives in
`ParseOptionalCXXScopeSpecifier`. After each Sema call that can rewrite
the qualifier through typo correction, the scope specifier is re-ranged
over the tokens actually consumed. When the qualifier was dropped
entirely, the template-id annotation is extended back over those tokens
instead. Sema and the typo-correction recovery are untouched.
[RegAllocFast] Order partial defs before other defs (#222882)
```
%0:gr64_with_sub_8bit = COPY $rax
%0.sub_32bit, %1:gr32 = MULX32rr $ecx, implicit $edx
```
The partial def of %0 is live-through: it reads the rest of %0, so it
must avoid the registers the instruction reads ($ecx, $edx) and is meant
to be allocated before an ordinary def like %1, which may share a
register with a use. The comparator in findAndSortDefOperandIndexes,
from the 2020 rewrite c8757ff3aa7d ("RegAllocFast: Rewrite and
improve"), tests `getSubReg() == 0`, the inverse of the allocation
sites, so %1 is allocated first and takes $eax; %0 then misses its hint
$rax, lands in $rsi, and the copy from $rax stays.
Share one isLiveThroughDef predicate between the ordering and the
allocation. %0 now takes $rax, the copy is deleted, and %1 takes $ecx.
Aided by Opus 5
[flang] Add an example plugin defining compiler directives
flangDirectivesPlugin registers directives with the prefix "example" (a
callback on a procedure, a watch on a variable or COMMON block, and a note on
either). The tests check their lowering to fir.directives attributes, the
semantic and parse errors, and their round trip through module files.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[Support] Clarify purpose of LLVM_DEPRECATED (#228367)
Rename the macro to LLVM_DEPRECATED_WITH_FIXIT, to clarify that is is
used for deprecations where a machine-applicable fix-it exists (which is
only pure rename deprecations).
[clangd] Fix header-name completion replace ranges (#225473)
Handle header-name completion as a special case for replace edits. Its
insert range already extends past the identifier, including delimiters
such as '"' and '>'. Reuse that range for replace edits so that the
insert range remains a prefix of the replace range, as required by the
LSP specification.
Add a unit test covering this case.
Fixes llvm/llvm-project#225326
[mlir][tblgen] Warn about the deprecated multi-result fold form
The legacy form `LogicalResult fold(FoldAdaptor,
SmallVectorImpl<OpFoldResult> &)` will be removed. This patch makes
`mlir-tblgen -gen-op-decls` warn when a dialect keeps `useOpFoldResults`
at 0 and has an op with `hasFolder` that does not have exactly one fixed
result. The warning points at the dialect definition. A note names the
first op that uses the legacy form.
The warning comes once for each dialect in one `-gen-op-decls` run. A
dialect with ops in more than one `.td` file can warn once for each file
that contains such an op. `-gen-op-defs` does not warn.
No in-tree dialect warns, because each in-tree dialect with such an op
already sets the bit.
The diagnostic follows the `-on-deprecated` option: `none` silences it,
`warn` (the default) warns, and `error` reports an error and fails the
run. `MlirTblgenMain.h` exposes the option value through
[3 lines not shown]
[mlir][linalg] Use OpFoldResults for linalg folds
The linalg dialect now sets the `useOpFoldResults` bit. ODS then
declares `OpFoldResults fold(FoldAdaptor)` for each linalg op that does
not have exactly one fixed result. This patch moves the eleven folds of
such ops in `LinalgOps.cpp` to the new form. It also changes the fold
template of `mlir-linalg-ods-yaml-gen`, so the generated named ops use
the new form too.
The behavior of the folds does not change. A fold that returned the
result of `memref::foldMemRefCast` now returns the same in-place state
through the `LogicalResult` constructor. The folds of `transpose`,
`pack`, and `unpack` return their replacement value directly.
The yaml-gen test now checks the generated fold definition.
A build directory that uses a native `mlir-linalg-ods-yaml-gen` does
not regenerate `LinalgNamedStructuredOps.yamlgen.cpp.inc` when the tool
changes. Delete that file before the build.
[2 lines not shown]
[mlir] Use OpFoldResults in more upstream dialects
The scf, shape, sparse_tensor, gpu, math, and builtin dialects now set
the `useOpFoldResults` bit. ODS then declares `OpFoldResults
fold(FoldAdaptor)` for each of their ops that does not have exactly one
fixed result. This patch moves the seven folds of such ops to the new
form: `scf.if`, `shape.split_at`, `sparse_tensor.crd_translate`,
`gpu.memcpy`, `gpu.memset`, `math.sincos`, and
`builtin.unrealized_conversion_cast`.
The behavior of the folds does not change, except in the graph-region
case below. Each fold builds the same normalized `OpFoldResults` object
that the legacy adapter built from the old return. The existing tests of
each dialect cover these folds.
In a graph region, an operand that `unrealized_conversion_cast` or
`sparse_tensor.crd_translate` forwards can be another result of the
same op that the same fold replaces. The new form drops such a fold.
For a forward chain, the legacy form gave a correct result by the order
[22 lines not shown]
[mlir][CIR] Use OpFoldResults for the cir.scope fold
The CIR dialect now sets the `useOpFoldResults` bit. ODS then declares
`OpFoldResults fold(FoldAdaptor)` for each CIR op that does not have
exactly one fixed result. `cir.scope` is the only such op with a fold.
Its fold now returns the yielded value directly. The behavior does not
change. The existing test `clang/test/CIR/Transforms/canonicalize.cir`
covers this fold.
Signed-off-by: Víctor Pérez Carrasco <victor.pc.upm at gmail.com>
[mlir] Deprecate the legacy fold APIs with a results vector
The legacy `Operation::fold` overloads with a
`SmallVectorImpl<OpFoldResult> &` parameter drop partial folds. The
overloads that return `OpFoldResults` keep them.
This patch moves every in-tree caller of the legacy overloads to the
overloads that return `OpFoldResults`, except the unit tests of the
legacy APIs. `OpFoldResultsTest.cpp` suppresses the deprecation warnings
for these tests. Then the patch marks these APIs as deprecated: the two
legacy `Operation::fold` overloads, the legacy general `foldTrait` form,
the legacy fold hook overloads of `DynamicOpDefinition`, and the
`DynamicOpDefinition::LegacyFoldHookFn` alias. ODS cannot put an
attribute on an interface method, so only the documentation marks the
legacy `DialectFoldInterface::fold` method as deprecated.
The new code in `cir::CastOp::fold` also fixes two bugs. The fold
crashed when the source of an integral cast was a block argument, and it
read slot 0 when the source was a different result of its op. Two new
[17 lines not shown]
[mlir][vector] Use OpFoldResults for vector folds
The vector dialect now sets the `useOpFoldResults` bit. ODS then
declares `OpFoldResults fold(FoldAdaptor)` for each vector op that does
not have exactly one fixed result. This patch moves the five folds of
such ops to the new form: `to_elements`, `transfer_write`, `store`,
`masked_store`, and `mask`.
The behavior of the folds does not change, except in the graph-region
case below. A fold that returned success with an empty vector now
returns `success()`, which is an in-place change. A fold that filled the
vector now returns its values.
The all-true fold of `vector.mask` moves the masked op out of the
region, and the terminator then has null operands. So this fold must
replace every result, and the driver erases the op. A mask without
results has no slot to replace, so the fold reports the move as an
in-place change.
[26 lines not shown]