[ELF] Separate relative and non-relative dynamic relocations (#187959)
Previously, the flow was:
1. Parallel scan adds relative relocs to per-thread `relocsVec`
2. `mergeRels()` copies all into `relocs`
3. `partitionRels()` uses `stable_partition` to separate
Now, relative relocs are routed at `addReloc` time by checking
`reloc.type == relativeRel`. In `mergeRels`, sharded entries are
classified through the same `addReloc` path rather than blindly
appended. `relocsVec` may contain non-relative entries like
`R_AARCH64_AUTH_RELATIVE`.
This eliminates the `stable_partition` on the full relocation vector
(543K entries for clang) and avoids copying relative relocations into
`relocs` only to move them out again.
Linking an x86_64 release+assertions build of clang is 1.04x as fast.
[5 lines not shown]
[clang-tidy][NFC] Remove optimized container implementations in `misc-no-recursion` (#187630)
About half of this check's code is dedicated to implementing a pair of
set containers with optimizations for when the element count is small.
But the check only uses these containers while constructing the warning
message. That's not generally a hot path in any check. Just to confirm,
I ran the check over `clang/lib/Sema/Sema.cpp` and all its included
headers before and after, and saw no performance difference. So, these
containers seem like a false optimization.
[clang] On Windows, silence warning when building with MSVC (#187937)
This fixes:
```
[2124/7029] Building CXX object tools\clang\lib\AST\CMakeFiles\obj.clangAST.dir\TemplateBase.cpp.obj
C:\git\llvm-project\clang\lib\AST\TemplateBase.cpp(753): warning C4312: 'reinterpret_cast': conversion from 'clang::SourceLocation::UIntTy' to 'clang::TemplateArgumentLocInfo::LocOrPointer' of greater size
```
[mlir] Deterministic containers in BytecodeWriter (#187819)
Iteration over use lists in writeUseListOrders is non-deterministic as a
result of using a DenseMap. Replacing with a Vector-backed `MapVector`
restores deterministic behaviour.
[clangd] Code completion for declaration of class method (#165916)
Code completion previously could not tell apart the declaration of
a method from a call to it, and provided call-like behaviour even
in declaration contexts. This included things like not offering
completion for private methods, and inserting placeholders for
the parameters as though the user was going to fill in arguments.
This patch adds support to Parser and SemaCodeComplete to
detect and provide dedicated behaviour for declaration contexts.
In these contexts, the flag CodeCompletionResult::DeclaringEntity
is set, and createCodeCompletionString() is adjusted to handle this
flag, e.g. by inserting parameter declarations as text chunks rather
than placeholder chunks.
The DeclaringEntity flag is also available for consumers of
SemaCodeComplete, such as clangd, to customize their behaviour.
In addition, the patch tweaks the conditions under which the
[6 lines not shown]
[MLIR][XeGPU] Add distribution patterns for vector insert & extract ops in sg to wi pass (#184665)
This PR adds patterns for following vector ops in the new sg-to-wi pass
1. ExtractOp
2. ExtractStridedSliceOp
3. InsertStridedSliceOp
4. InsertOp
[Clang] Honour [[maybe_unused]] on private fields (#187940)
Before this commit, [[maybe_unused]] on private fields was ignored. In
conjunction with `-Wunused-private-field`, false warnings were emitted
by clang. This commit fixes this by checking if an unused private field
is annotated with [[maybe_unused]].
[VPlan] Add m_VPPhi pattern matcher and use in removeDeadRecipes (NFC).
Add m_VPPhi to match VPPhi instructions with exactly 2 operands.
Split off from https://github.com/llvm/llvm-project/pull/156262.
[llvm][ADT] Add PointerUnion benchmarks. NFC. (#187874)
Add microbenchmarks for `PointerUnion`'s `isa` and `isNull` operations
across union sizes of 2, 4, and 8 types. This it to establish baseline
performance numbers before making changes to the implementation.
I plan to refactor the implementation a bit and add support for more
variants using sparse encoding.
Co-authored-by: Claude Opus 4.6 (1M context) <noreply at anthropic.com>
[clang] On Windows, silence warning in `CFGBackEdgesTest` with MSVC (#187939)
This fixes:
```
[5804/7029] Building CXX object tools\clang\unittests\CMakeFiles\AllClangUnitTests.dir\Analysis\CFGBackEdgesTest.cpp.obj
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\include\xutility(721): warning C4018: '>': signed/unsigned mismatch
...
C:\git\llvm-project\clang\unittests\Analysis\CFGBackEdgesTest.cpp(170): note: see the first reference to 'testing::internal::PredicateFormatterFromMatcher<testing::internal::SizeIsMatcher<testing::internal::GtMatcher<int>>>::operator ()' in 'clang::analysis::`anonymous-namespace'::CFGBackEdgesTest_WhileWithContinueLoop_Test::TestBody'
```
[RISCV] Add guard to prevent GPRPair merge on targets without Zdinx or P (#186600)
Resolves #186527.
The issue points out that GPRPair merge logic in the RISCVMoveMerger
pass was being called on a target without `zdinx` or `experimental-P`,
triggering an unreachable in `getGPRPairCopyOpcode`.
This patch fixes this issue by guarding `isEvenRegisterCopy` and
`isOddRegisterCopy` to return false when neither Zdinx nor P is present.
[SLP]Do not try to reduced instruction, marked for deletion in previous attempts
Need to skip instructions, which were vectorized and marked for deletion
to prevent a compiler crash
[MC,clang] Fix -Wa,--noexecstack not emitting .note.GNU-stack (#187880)
AsmPrinter (clang -c a.c) and AsmParser (clang -c a.s, llvm-mc
-filetype=obj a.s) have different ways to emit .note.GNU-stack section.
913c5b4d1fff removed a redundant initSections call from cc1as, but
that was the only place where NoExecStack was consumed for the
assembler path.
Unify the .note.GNU-stack emission in MCELFStreamer::finishImpl,
making the `initSections` parameter redundant.
Add a -filetype=obj test for Solaris (see
https://reviews.llvm.org/D159179), which doesn't use .note.GNU-stack
`initSections` has 20+ uses. The parameter cleanup will be deferred to a
subsequent change.
Fixes https://github.com/llvm/llvm-project/issues/186004
[clang-tidy] use-after-move: Support null_after_move annotations (#186903)
Extend the bugprone-use-after-move check to recognize user defined
smart-pointer-like types that make guarantees on the state of a
moved-from object, leaving it in a valid and specified state that
matches the standard smart pointer's moved-from state (nullptr), where
it is safe to use but not dereference.
Following the RFC discussion:
* Use `[[clang::annotate]]` to mark the types.
* Use an schema for the `[[clang::annotate]]` annotation and arguments
to help avoid conflicts with other users of the attribute.
* The annotation will identify the tool ("clang-tidy") and the arguments
the plugin ("bugprone-use-after-move"), and the behavior of the type
("null_after_move"). E.g.:
`[[clang::annotate("clang-tidy", "bugprone-use-after-move",
"null_after_move")]]`
[2 lines not shown]