[clangd] Index symbols declared inside export declarations (#234755)
SymbolCollector::shouldCollectSymbol only accepts symbols whose semantic
parent is a translation unit, namespace, linkage spec, enum, record or
one of a few ObjC containers. ExportDecl is a DeclContext and is
returned by getDeclContext(), so every entity declared with `export` or
inside an `export { ... }` block was dropped from the index. Members of
exported classes were still indexed, since their parent is the record.
In C++20 modules code this hides most of the exported interface from the
index: Go to Definition on an exported function stops at the declaration
in the module interface instead of reaching the definition in the
implementation unit, and workspace/symbol does not find it. Rename uses
the same check, so it rejects exported symbols as "not eligible for
indexing" (reported in clangd/clangd#2569).
Use getNonTransparentDeclContext() instead, so declarations inside
transparent contexts (export, extern "C", unscoped enums) are judged by
their enclosing context. Do the same in isIndexedForCodeCompletion, so
[4 lines not shown]
[APFloat] Make `PackCategoriesIntoKey` a constexpr function (#236316)
Since we can very much use constexpr in the code base these days, use a
constexpr function here instead of a macro.
Resolving a 13 year old TODO comment.
[asan][test] Test UAR/UAS modes in throw_call_test.cpp and XFAIL on Android (#236664)
By default, `-fsanitize-address-use-after-scope` unpoisons `ar[100]` on
entry to `CheckStack()`, and `-fsanitize-address-use-after-return`
allocates frames on `FakeStack`. Because of this, `CheckStack()` did not
catch poisoned stack left behind after `throw`.
On Android, `__cxa_throw` is currently not intercepted (#236665). The
test passed on Android API 29 and only failed on API 34 because
`fprintf` inside `catch` happened to call `memset` on the poisoned stack
before `CheckStack()`.
Add explicit UAR/UAS flags so `CheckStack()` catches this directly, and
mark the test `XFAIL: android`.
https://lab.llvm.org/buildbot/#/builders/sanitizer-x86_64-linux-android
Assisted-by: Gemini
[VPlan] Compute the backedge-taken count with an explicit recipe. (#236655)
Instead of a symbolic VPValue for the backedge-taken count, which is
materialized after dissolving the loop regions, compute TC - 1 directly
in the vector preheader when creating the header mask that compares
against it, together with an explicit broadcast.
This removes VPlan::BackedgeTakenCount (VPlan)global state.
[SPARC] Do not fill delay slots at -O0 (#235248)
At -O0 the delay slot filler still moves the instruction before a call
into its delay slot, and at -O0 that's typically the spill of an
argument. A breakpoint on the line of the call stops on the `call`
before the store has run, so the debugger reads stale stack. GCC only
fills delay slots from -O1, and the Mips filler skips -O0 as well.
This skips the optional fill, and the restore folding, at -O0.
Two fills are needed for correctness and are kept at every level: the
restore before a tail call has to be in its delay slot (a jmp %reg reads
its target from the current window, a call writes %o7), and so does the
mov %g1, %o7 before a leaf tail call.
Until now only the optional search put them there, so
`-disable-sparc-delay-filler` produced leaf tail calls that returned
into the next function.
[33 lines not shown]
[LoopUnroll] Use DenseMap::contains instead of count (NFC) (#224529)
Replace count()-then-lookup style membership checks with contains() in
analyzeLoopUnrollCost for readability.
[llvm-mc] Report more errors through the SourceMgr (#236281)
Avoid printing to errs() directly and use the SourceMgr instead like
all the other assembler and disassembler diagnostics.
This is needed for the upcoming `--verify` option: without this, these
options interfere with the exit code from --verify and can't be matched.
Mostly NFC, although the errors now print without a `llvm-mc:` prefix.
Assisted-by: AI tooling
Pull-Request: https://github.com/llvm/llvm-project/pull/236281
[llubi] Add support for llvm.masked.gather (#235986)
Re-use the logic for llvm.masked.load to also support
llvm.masked.gather.
Instead of computing consecutive addresses from a base pointer, enabled
lanes are loaded from the pointer of the lane. Masked-off lanes are
taken from the passthru operand and are not accessed.
PR: https://github.com/llvm/llvm-project/pull/235986
[Support][mlir] Clean up list of unmatched @unknown directives (#236282)
mlir-opt calls `verify()` twice (explicitly and in the handler's
destructor), and `verify()` clears the per-file directive lists, but
did not clear the list of `@unknown` ones.
This fixes reporting unmatched `@unknown` twice.
Assisted-by: AI tooling
Pull-Request: https://github.com/llvm/llvm-project/pull/236282
[clang][Sema] Fix crash caused by invalid implicit format attributes (#229010)
Clang implicitly adds `format_arg(1)` to `__CFStringMakeConstantString`,
including prototypeless declarations created during error recovery. A
zero-argument call can then cause format string checking to access a
nonexistent argument and crash.
Reproducer:
```c
void a(char *) __attribute__((format(__CFString__, 1, 2)));
void b() { a(__CFStringMakeConstantString()); }
```
Before this change, an assertions-enabled build crashes after reporting
the source errors (diagnostic excerpts):
```text
error: call to undeclared function '__CFStringMakeConstantString';
[10 lines not shown]
[VPlan] Remove redundant VPIRFlags::transferFlags (NFC) (#236641)
Its only user, VPReplicateRecipe::cloneWithOperands, already passes
*this as the flags to the new recipe/ Remove the unnecessary call.
[clang] Remove declarations without definitions (NFC) (#236620)
This patch removes function and method declarations that have no
definitions and no callers.
Assisted-by: Antigravity
[clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast_if_present (NFC) (#236619)
PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present. This patch replaces
PointerUnion::dyn_cast with llvm::dyn_cast_if_present in
SARIFDiagnostic::emitDiagnosticMessage, and adds a test case to cover
the null operand case.
Note that DiagnosticRenderer::emitSingleMacroExpansion invokes
emitDiagnosticMessage with a null DiagOrStoredDiag when emitting a
macro expansion note.
This patch completes the migration away from PointerUnion::dyn_cast
under clang/.
Assisted-by: Antigravity
[SandboxVec][LoadStoreVec] Vectorize store chains whose loads have external uses
vectorizeStores() used to give up on a load-store chain if any of the
loads had a user other than its store. Now that loads of mixed types
can be unpacked from a vector load, vectorize such chains as well: the
loads become a single vector load, and the external users are fed from
the lanes each load occupies, cast back to the load's type if needed.
The unpacking loop of vectorizeLoads() is factored out into
unpackLoads() (along with the canUnpackLoads() check) and shared by
both paths. Chains with a non-integral pointer load that has external
users are still left alone.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SandboxVec][LoadStoreVec] Add Reinterpret helper for same-size type casts
Replace getEquivalentConstantWithType() with a Reinterpret utility that
reinterprets the bits of a value as another type of the same size. It
builds a chain of ptrtoint / bitcast / inttoptr casts, and applies it
either to a constant (folding) or to a runtime value (inserting casts).
The runtime form will be used to unpack mixed-type vector loads and to
pack mixed-type store operands.
Also add VecUtils::isNonIntegralPtr(). A non-integral pointer has no
stable integer representation, so it is no longer packed into an
integer lane. Previously only a non-integral destination type was
rejected (via an assert), while a non-integral source such as
'ptr addrspace(5) null' was silently converted with ptrtoint.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SandboxVec][LoadStoreVec] Add LLVM_ABI annotations to Reinterpret
Export the out-of-line static members of Reinterpret, as reported by
the LLVM_ABI annotation check. getCastChain() is private but is called
from the inline canReinterpret(), so it needs to be exported too.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SandboxVec][LoadStoreVec] Support mixed-type load vectorization
Remove the restriction that every load in a top-level load chain must
have the vector's element type. A chain of mixed types such as
{i32, float} or {double, i32, i32} is loaded as a vector of integers
(as chosen by VecUtils::getCombinedVectorTypeFor()), each original load
is unpacked from the lanes it occupies, and then reinterpreted back to
its own type with Reinterpret::reinterpretValue().
Chains involving a non-integral pointer are left alone, since such a
pointer cannot be recovered from an integer lane.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SandboxVec][LoadStoreVec] Move contiguity check into canVectorize() (NFC)
Both vectorizeStores() and vectorizeLoads() (via createVectorLoad())
checked that the bundle is consecutive right before calling
canVectorize(). Fold that check into canVectorize() so that every
caller gets it.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SandboxVec][LoadStoreVec] Reject bundles that cannot be scheduled
canVectorizeLSV() created a CantSchedule result when the scheduler
failed, but did not return it, so such bundles were still reported as
Widen. For a load chain like
%ld0 = load i32, ptr %p0
store i32 %ld0, ptr %p1
%ld1 = load i32, ptr %p1
the vector load was placed after %ld1 and the store was rewritten to
use a lane extracted from it, producing a use before its definition.
Return the CantSchedule result.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[mlir][Python] Generate type stubs for dialect extensions
Continue #175403 by generating extension stubs for each concrete Python
package. Keep imports and build dependencies local to that package, handle
optional extensions, and normalize native IR type references.
Co-authored-by: makslevental <maksim.levental at gmail.com>
[VPlan] Don't query IVDesc for pointer-induction step type (NFC) (#236640)
The step operand of VPWidenPointerInductionRecipe is created from the
descriptor's step SCEV in createWidenInductionRecipe, so its scalar type
matches ID.getStep()->getType(). Use it directly.
[SandboxVec][LoadStoreVec] Support mixed-type store vectorization of arbitrary values
vectorizeStores() only handled chains whose stored values were all
consecutive loads or all constants. Any other chain, e.g., storing
function arguments or computed values, was left alone.
Pack such values into a vector with createPack(). For a chain of mixed
types the vector has integer lanes, so each value is first
reinterpreted (bitcast / ptrtoint) as the lanes it occupies with
Reinterpret::reinterpretValue(), and a value spanning several lanes is
inserted lane by lane. The pack is placed right before the vector
store, where every stored value is available. Whether this pays off is
left to the existing cost check in acceptOrRevert().
Chains storing a non-integral pointer are left alone.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[Github] Run generic-llvm-libc against libc changes (#234440)
libc changes have been breaking the libc++ tests reasonably often, so
run the generic-llvm-libc CI job on libc changes to ensure things do not
get broken premerge. This job typically runs in <20 minutes so shouldn't
be too interruptive.
[Analysis] Declare command line options in TableGen (#236489)
Port the file-local options of llvm/lib/Analysis to a per-LLVMContext
AnalysisOptions struct. These remain cl::opt: exported options, options
read by public APIs without IR context (getInlineParams, TTI getters,
InlineConstants::getInstrCost, generateParamAccessSummary), and options
read per query without an object to bind them (ValueTracking,
ConstantFolding, CFG reachability, ObjectSizeOffsetVisitor, TBAA,
ScopedNoAliasAA).
* Option-reading classes hold `const AnalysisOptions &`; the inline
constructors of BasicAAResult, MemoryDependenceResults,
DependenceInfo, MemoryDepChecker, RuntimePointerChecking,
InterleavedAccessInfo and ProfileSummaryInfo move out of line, and
InterleavedAccessInfo::isStrided becomes non-static.
* Rename -disable-gep-const-evaluation and
-da-disable-delinearization-checks to positive spellings; the old ones
remain aliases.
* The inline cost annotation printer no longer sets
[2 lines not shown]
[SandboxVec][LoadStoreVec] Vectorize store chains whose loads have external uses
vectorizeStores() used to give up on a load-store chain if any of the
loads had a user other than its store. Now that loads of mixed types
can be unpacked from a vector load, vectorize such chains as well: the
loads become a single vector load, and the external users are fed from
the lanes each load occupies, cast back to the load's type if needed.
The unpacking loop of vectorizeLoads() is factored out into
unpackLoads() (along with the canUnpackLoads() check) and shared by
both paths. Chains with a non-integral pointer load that has external
users are still left alone.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>