[libc] Use a syscall wrapper for remap_file_pages (#240074)
This PR move remap_file_pages behind the centralized syscall wrappers,
following libc/docs/dev/syscall_wrapper_refactor.md.
[libc] Use a syscall wrapper for posix_madvise (#240073)
This PR move posix_madvise behind the centralized syscall wrappers,
following libc/docs/dev/syscall_wrapper_refactor.md.
[RegAlloc] Fix failed-reassign cache build after namespace removal
The reassign namespace was dropped from FailedReassignCache.h, but
RegAllocEvictionAdvisor and the unit test still referenced it, so the
tree did not build. Drop the qualifiers and forward-declare Cache in
llvm directly.
Also make a hint-only remember() discard any existing entry instead
of storing a flag, since hint sets can change without an overlapping
unassign.
Co-authored-by: Cursor <cursoragent at cursor.com>
[RegAlloc] Fix failed-reassign cache build after namespace removal
The reassign namespace was dropped from FailedReassignCache.h, but
RegAllocEvictionAdvisor and the unit test still referenced it, so the
tree did not build. Drop the qualifiers and forward-declare Cache in
llvm directly.
Also make a hint-only remember() discard any existing entry instead
of storing a flag, since hint sets can change without an overlapping
unassign.
Co-authored-by: Cursor <cursoragent at cursor.com>
[RegAlloc] Cache failed canReassign searches
The eviction advisor can ask canReassign repeatedly for the same live
interval. For register classes with long allocation orders, rescanning every
candidate is expensive when the answer remains false.
Cache failed searches that examine more than the configured order-size
threshold. A failure remains valid while registers are assigned because an
assignment cannot make another physical register available. LiveRegMatrix now
notifies every eviction advisor when an interval is unassigned so cached
failures whose slot ranges overlap the freed interval can record the affected
physical register. MLEvictAdvisor embeds a DefaultEvictionAdvisor, so both
register as listeners.
On a later query, return the cached failure immediately when no relevant
unassign occurred. Otherwise, check only the freed register and its aliases
that belong to the interval's allocation order. If none are now free, retain
the failure without rescanning the full order. Hint-only searches are not
reused, because the hint set can grow without an overlapping unassign.
[12 lines not shown]
[VPlan] Share the result-type helper of `VPReplicateRecipe` with `VPWidenRecipe` (NFC)
Turn `VPReplicateRecipe::computeScalarType()` into an overload of
`computeScalarTypeForInstruction()` that takes the instruction. Both
`VPReplicateRecipe` and `VPWidenRecipe` use it when they wrap an instruction.
The opcodes it takes from the instruction never reach `VPWidenRecipe`, so the
types don't change. It prepares for widening `bitextract`, whose result type
can't be computed from its operands.
[Clang] Mark template instantiations with main-file template arguments as likely_module_local
With -fmodule-local-hints, Clang marks inline functions and template
instantiations defined in the main source file as likely_module_local. A
template defined in a header but instantiated with an entity declared in the
main file (e.g. std::sort with a main-file comparator or lambda) isn't marked,
even though such an instantiation can't be referenced or emitted by any other
translation unit either.
Also mark a function template instantiation if its template arguments, or
those of the enclosing class and function template specializations, name a
class, enum, lambda closure type, function or template declared in the main
file. Pointer, reference, array, member pointer and function types are looked
through, as are the template arguments of class template specializations used
as arguments. The walk is bounded to avoid blowup on deeply nested arguments.
[clang-repl] Undo the enumerators of an unscoped enumeration (#228370)
The enumerators of an unscoped enumeration are in the lookup table of
the enclosing context. Undoing the input that declared the enumeration
removed the enumeration, but its enumerators stayed visible:
```
clang-repl> enum E { Red };
clang-repl> %undo
clang-repl> int Red = 5;
error: redefinition of 'Red' as different kind of symbol
```
`ASTDeclUnmerger` now also visits the declarations of an undone
enumeration definition.
**Test:** new lit test `code-undo-enumerators.cpp` with three cases: an
enumerator reused as a variable, an enumeration redefined, and an
enumeration in a namespace. It checks printed values only, not
[7 lines not shown]
[mlir][nvgpu] Expose which memrefs optimize-shared-memory can swizzle (NFC) (#237180)
Extract checks on a memref's type out of
`optimizeSharedMemoryReadsAndWrites` into a new public function,
`canSwizzleSharedMemoryType`. The function would be helpful for prior
passes to reason about optimization decisions based on whether it is a
valid swizzling candidate.
Assisted-by: Claude
[ASan][test] Mark Linux/stack-overflow-recovery-mode.cpp UNSUPPORTED on Android AArch64 (#240097)
Temporarily mark `TestCases/Linux/stack-overflow-recovery-mode.cpp`
unsupported on Android AArch64 while waiting for #236879, matching
#236884 (https://lab.llvm.org/buildbot/#/builders/186/builds/4079).
Assisted-by: Gemini
[ADT] Add LLVM_ATTRIBUTE_WARN_UNUSED to SmallPtrSet (#240080)
This patch adds LLVM_ATTRIBUTE_WARN_UNUSED to SmallPtrSet so that
compilers can diagnose unused SmallPtrSet variables even though
SmallPtrSet has a non-trivial constructor and destructor.
This patch also addresses the existing warnings uncovered by the
attribute:
- ScheduleDAGSDNodes::BuildSchedUnits had an unused local variable
Visited, which this patch removes.
- SmallPtrSetTest.cpp intentionally leaves Other unused in two move
tests, so this patch marks Other with [[maybe_unused]].
Assisted-by: Antigravity
[LLVM] FIx fallout from #239908 (#240096)
The original patch added LLVM_ATTRIBUTE_WARN_UNUSED to some ADT classes,
which caused some more -Wunused-variable warnings under release builds
(that optimize out asserts).
https://lab.llvm.org/buildbot/#/builders/228/builds/17397