[SimplifyCFG] Reuse function comdat for switch lookup table (#190995)
Fixes #190994.
As the switch table is extracted from the function, the table should be
removed when the function is removed, and therefore inherits the comdat
of the function.
[ValueTracking][KnownFPClass] Cover known no-infinity cases for powi (#191736)
Teach `computeKnownFPClass` to infer non-infinity cass for `powi`.
Rules out `inf` for `powi(x, exp)` when:
- `x ?= inf` && `exp > 0`
- `x ?= +/-0` && `exp < 0`
- `x ?= finite` && `|exp| > 1`
- `x ?= subnormal` && `exp ?= -1` (special asym case after |exp| > 1)
where `?=` is maybe equal.
It's a bit conservative, and we could refine it further, but I'd take an
iterative improvement.
[OpenACC] Fix invalid routine case where 'bind' didn't exist (#192270)
For some reason I'd failed to check the result of `find_if` and just
assumed that the `bind` clause must exist! Looking through my other
tests, I've validated every other combination other than this one for
some reason.
Fixes: #192245
[Clang] Fix handling of overloads differing only by constraints and ref-qualifiers (#192018)
We should only error about inconsistent qualifiers if the functions are
actually overloads.
Fixes #120812
[llvm-jitlink] Hold Session::ObjLayer by unique_ptr. (#192253)
This will simplify the Session construction process when we remove
jitlink::JITLinkMemoryManager ownership from ExecutorProcessControl in
an upcoming patch.
(Reason: ObjectLinkingLayer's constructor will require a
JITLinkMemoryManager, which we'll want to cerate after the
ExecutionSession has been initialized. Creating a JITLinkMemoryManager
is generally a fallible operation, so we want to be able to bail on
construction of the ObjectLinkingLayer entirely if we can't create a
memory manager for it).
[lldb][Docs] Fix presentation of some default values (#192239)
There were two bugs with the display of default values:
1. If a default value contains a backtick, that would render
incorrectly. For example
[`disassembly-format`](https://lldb.llvm.org/use/settings.html#disassembly-format).
Fixed by doing the wrapping when we generate the Markdown instead of
when parsing the directive. MyST will already parse the content of the
directive as Markdown. We can escape backticks inside the string by
changing the fence. Markdown can take any number of backticks at the
start as long as they match the amount at the end
([spec](https://spec.commonmark.org/0.31.2/#code-spans)).
2. When the docs were built on Windows, UTF-8 was not correctly picked
up, because the default encoding isn't utf8 there.
[`separator`](https://lldb.llvm.org/use/settings.html#separator) was one
example (renders correctly on the Website but not on my machine).
[Clang] Diagnose `co_await` expressions in default arguments of nested functions (#191817)
co_await/co_yield expressions are not allowed in default arguments. We
were checking they do not appear outside of function contexts, which
include default arguments of the corresponding function, but it missed
default arguments of functions declared in the body of another
functions.
Because parsing default argument isn't done in a dedicated scope, we do
additional checks in `ActOnParamDefaultArgument`. Because the checks is
done in two places, we cannot introduce a more precise diagnostic.
It might be worth considering a parse scope for default arguments in the
future.
Fixes #98923
[LifetimeSafety] Propagate origins through explicit cast expressions (#192180)
Before this PR, `FactsGenerator` handled cast nodes with
`VisitImplicitCastExpr` (`CastKind` switch case) and
`VisitCXXFunctionalCastExpr` (handle`gsl::Pointer` types). Other
explicit casts (`CStyleCastExpr`, `CXXStaticCastExpr`, ...) had no
handler, so origin was silently dropped. This is the root cause of
#190912: the dangle in `a = StringView(s);` is missed even though the
equivalent `StringView tmp(s); a = tmp;` is reported.
The policy for "does this cast propagate origin?" is a function of
`CastKind`, independent of whether the cast is implicit or explicit.
This PR replaces `VisitImplicitCastExpr` with a generic `VisitCastExpr`.
`VisitCXXFunctionalCastExpr` is retained only to preserve the
`handleTestPoint` logic, then delegates to `VisitCastExpr`.
This mirrors `clang/lib/AST/ExprConstant.cpp`, where each evaluator
implements only `VisitCastExpr` and switches on `CastKind`; the few
ExprClass-specific overrides (e.g., `VisitCXXDynamicCastExpr`) exist
[4 lines not shown]
[MLIR] Fix a mismatch between the function return type and the returned value type (NFC) (#192258)
This fixes the build on some platform where the inferred count differs.
[Flang] Fix statement-function shadowing to avoid false unresolved-symbol internal error (#189360)
When a statement function shadows a host-associated internal procedure
name, HandleStmtFunction creates a local symbol but leaves name.symbol
pointing to the host SubprogramNameDetails.
Because of that stale pointer, AnalyzeStmtFunctionStmt exits early (it
expects SubprogramDetails), so the RHS is never resolved and flang emits
a false `internal error: "Internal: no symbol found".` Clearing
name.symbol after creating the local shadow symbol lets it re-resolve
correctly and fixes the issue.
---------
Co-authored-by: Chandra Ghale <ghale at pe34genoa.hpc.amslabs.hpecorp.net>
[MLIR][Math] Move exponent threshold check before IR creation in PowIStrengthReduction (#188955)
PowIStrengthReduction::matchAndRewrite was creating the `one` constant
(using complex::ConstantOp::create for complex::PowiOp) before the
threshold check that guards whether the rewrite is profitable. When the
exponent exceeds the threshold, the pattern returned failure() after IR
was already modified, violating
MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS.
Fix: reorder so the abs(exponent) computation and threshold check occur
before any IR creation.
Assisted-by: Claude Code
Fix a failure present with MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
[MLIR][Bufferization] Fix foldMemRefCasts dropping ranked return type for unranked->ranked cast (#189249)
When one-shot-bufferize with bufferize-function-boundaries is used and a
function returns a ranked tensor that is produced by casting from an
unranked intermediate (e.g. a call to a function returning
tensor<*xf32>), the foldMemRefCasts post-processing step incorrectly
unpacked the memref.cast from unranked to ranked memref, downgrading the
function return type to the unranked memref type and using the unranked
value as the return operand.
The fix is in unpackCast(): do not unpack a cast whose source is an
unranked memref and whose result is a ranked memref, since doing so
would lose type specificity.
Fixes https://github.com/llvm/llvm-project/issues/176739
Assisted-by: Claude Code
[CIR] Lower PsuedoObjectExpr LValues (#192108)
This ends up being pretty much copy/paste from classic-codegen, so it
doesn't have anything particularly novel.
I DID switch the return type of the helper function to be a variant
instead of a manually-put-together pair, and switched to range-for, but
otherwise it should be identical.
However, I was uanble to reproduce a few of the branches, so NYIs were
left in place until we can figure them out. At least some of them are
going to be for RValue versions.
[CIR] Handle scalar lowering of qualification-changes (#192152)
Similar to the previous Expr-change that I made, this does the same with
pointers-to-arrays (and other types). The new implementation is
effectively a copy/paste of the classic-codegen, so it maintains our
current invariants/assumptions about changes via emitLoadOfLValue.
[CIR] Implement 'ArrayInitLoopExpr lowering' in ExprAgg. (#192053)
This ended up being a fairly common pattern: a copy operation on a
structure with an array inside of it. Classic-Codegen has a few
different ways of initializing/copying an array, of which this is one.
However, this patch uses the array-init functionality we already have.
This ends up being a bit verbose, but will make sure we don't have to
worry about separately handling throwing types/etc for this AST node.
Additionally, this has to handle the ArrayInitIndexExpr, but that is as
simple as making sure we properly cache the index value when doing our
initialization.