[ADT] Simplify FoldingSetIterator (NFC) (#219073)
This patch simplifies FoldingSetIterator by defining it entirely in the
header without the type-erased FoldingSetIteratorImpl.
Now that FoldingSet uses an open-addressing hash table, we just have to
march through the entire bucket array while skipping empty slots. It
does not make sense to call out-of-line advance().
This also reduces the .text section size of a release build of bin/clang
by 647 bytes (from 185,968,635 to 185,967,988 bytes).
Assisted-by: Antigravity
[C++20] [Modules] Load friends for classes in ADL (#219094)
Close https://github.com/llvm/llvm-project/issues/218228
The root cause of the problem is the corresponding friend is not loaded
at the point of ADL.
This patch tries to fix this simply by loading the friends at the point
of ADL. Note that this may be best efficient if there are a lot of
friends. We just think it is rare. If it is really possible, we can
change the structure of friends from a list to a name lookup table.
[orc-rt] Add SimpleRemoteCA, a SimpleRemote protocol base (#219093)
SimpleRemoteCA implements the transport-independent parts of the
SimpleRemote protocol: opcode and header validation, setup-message
encoding, hang-up encoding and decoding, pending-call tracking, and
completion of controller calls onto the Session::ControllerAccess
contract. Subclasses own wire framing and byte transport entirely --
they de-frame incoming messages and hand the header fields to
handleMessage, and build outgoing ones from the Opcode set and the
encode helpers.
Header validation rejects fields the protocol requires to be unset: a
Result may not carry a handler tag, a hang-up may not carry a sequence
number or tag. It does not interpret fields the protocol requires to be
present -- in particular a Call's handler tag is passed through as
given, since the executor's job is to jump where the controller tells it
to.
A hang-up carries a serialized Error giving the reason the session is
[6 lines not shown]
[NFC][clang][Serialization] Fix std::set_difference sorting mismatch in ASTReader (#219053)
Fixes a `std::set_difference` sorting violation in
`ASTReader::checkTargetOptions` that causes a crash when building clang
with `LLVM_ENABLE_EXPENSIVE_CHECKS` on libstdc++.
`accumulateFeaturesAsWritten` sorts target features using a custom
comparator that strips the `+`/`-` prefix (i.e. comparing `A.substr(1) <
B.substr(1)`). However, `std::set_difference` was being called with the
default `std::string::operator<` comparator, which does not match the
sorting order because `+` (ASCII 0x2B) is less than `-` (ASCII 0x2D).
For example, `["-cx16", "+sse2"]` is correctly sorted according to the
custom comparator, but incorrectly sorted according to the default
lexicographical comparator.
This patch fixes the issue by passing the same custom comparator used
for sorting to both `std::set_difference` calls.
Fixes #219046.
[SLP]Trim combined nodes only at their roots
Combined subnodes were added to the trimming worklist as independent
candidates, carrying their descendants' aggregated costs. Trimming such
a subnode on its own deleted operands still referenced by the combined
root, producing instructions that no longer dominated their uses.
Skip CombinedVectorize subnodes in subtree-cost aggregation and worklist
construction so only combined roots are evaluated as trim candidates.
Fixes #218974
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/219095
[lsan][llvm-profdata] Suppress leak check on abnormal exit (#219088)
This is common issue with lsan after exit().
`exit()` is no return, we can't expect that compiler
will preserve pointers to allocations done by callers.
Fixes new build bot report after upgrading base compiler to clang 23.1.0
https://lab.llvm.org/buildbot/#/builders/169/builds/26007
It probably has improved stack or registers re-use.
[flang][docs] Mention --driver-mode=flang in FlangDriver.md (#207659)
This patch adds a description about the `--driver-mode=flang` flag.
The behavior will be ensured by #207658.
---------
Co-authored-by: Tarun Prabhu <tarunprabhu at gmail.com>
[libc][bazel] Add a repo with linux kernel UAPI headers
This will be used to support libc's -DFULL_BUILD option, which uses `-nostdlibinc` and thus requires a copy of linux kernel headers.
[libc][bazel] Allow building with -DLIBC_FULL_BUILD
This PR defines a flag `--@llvm-project//libc:build_mode` that configures LLVM-libc to build with full-build flags. This is only compatible with clang at the moment, since it relies on the `-nostdlibinc` flag.
[compiler-rt][cmake] Change orc-rt target names (#216901)
When configured with `LLVM_ENABLE_RUNTIMES=compiler-rt;orc-rt`,
following two CMake errors occur.
```
CMake Error at llvm-project/llvm/cmake/modules/AddLLVM.cmake:2245 (add_custom_target):
add_custom_target cannot create target "check-orc-rt" because another
target with the same name already exists. The existing target is a custom
target created in source directory
"llvm-project/compiler-rt/test/orc". See documentation
for policy CMP0002 for more details.
Call Stack (most recent call first):
llvm-project/llvm/cmake/modules/AddLLVM.cmake:2326 (add_lit_target)
llvm-project/orc-rt/test/CMakeLists.txt:24 (add_lit_testsuite)
CMake Error at llvm-project/orc-rt/test/unit/CMakeLists.txt:1 (add_custom_target):
add_custom_target cannot create target "OrcRTUnitTests" because another
target with the same name already exists. The existing target is a custom
[10 lines not shown]
[SSAF][clang-reforge] Add end-to-end clang-reforge tests
- Make CppBoundedBuffers adapt to flattened WPA results;
- Let CppBoundedBuffers use qualified EntityNames so that it can
associate ASTNodes with WPA results;
- Add end-to-end tests
Final step of:
rdar://185840466
[SSAF] Fix stage-2 clang build error on TestTransformationPlugin
The plugin code defines the extern variable
SSAFTestTransformationAnchorSource, which is supposed to be used to
force static linking, so not needed here.
The variable definition should undoubtedly be removed, as doing so
solves the build issue locally. The explanation below regarding why
this variable causes the issue was provided by Claude. I repeatedly
asked Claude questions, and he revised his reasoning several times
until it became consistent. However, we should still take the
following explanation with a grain of salt:
ASan created a private alias symbol for the extern variable
SSAFTestTransformationAnchorSource. The linker, when in
'-flat_namespace' mode, treated the symbol as a name-based bind, which
later failed to be resolved through name searching by the loader.
rdar://185749574
[2 lines not shown]
[mlir][IR] Require inherent symbol attributes for Symbol operations (#218920)
Require SymbolTable operations to implement SymbolOpInterface and store
symbol names and visibility as inherent attributes.
Add missing symbol properties/interfaces to GPU, OpenACC, OpenMP, EmitC,
and Toy operations, and update affected tests and the GPU Python
builder.
Assisted-by: Codex
[LV] Support EVL for partial reduction and VPExpressionRecipe. (#205741)
This patch adds the support for partial reduction with EVL tail-folding
by not creating a new VPExpressionEVLRecipes but just changing the last
expressionRecipes from VPReductionRecipe to VPReductionEVLRecipe.
Currently, all partial reductions will be converted to
VPExpressionRecipe
when construction. So this patch also supports the VPExpressionRecipe
for EVL.
[BOLT][RISCV] Avoid evaluating indirect branches as direct branches (#218088)
The RISC-V branch evaluator can resolve JALR when the base register
state is known. In particular, jalr zero, zero, 0 evaluates to address
zero even though it remains an indirect branch.
Do not send indirect branches through the direct branch symbolization
path. Leave them to the existing indirect branch handling instead.
Add a regression test modeling a tail call to an undefined weak symbol
relaxed by GNU ld.
[CIR][AARCH64] Fix neon conversion test (#219069)
This fixes the neon intrinsics test, which has been failing since a
recent change to introduce more conversion handling. The test had an
inadvertantly repeated CIR check.
Revert "Revert "workflows/release-binaries: Disable flang on Darwin (#164667)"" (#218978)
Reverts llvm/llvm-project#216667
This change was ported to the `release/23.x` branch in #217059, and when
we created the first release that included this change (3.1.0), the job
for the MacOS ARM binaries was killed when the job hit the 6 hour mark.
Previous 3.1.0-rc release did not include this change and all completed
well within the 6 hour time out.
To enable the job that builds the release binaries to complete within
the allotted time, I am reverting this change which will essentially
disable flang from building on Darwin.
In the future if we get faster builders, we can explore re-enabling
building flang.
[ELF] Avoid repeated scans when merging strings
Build per-worker shard lists before inserting merge pieces. This keeps
each shard's input order deterministic while avoiding a full scan of every
piece by every worker. Reuse SectionPiece::outputOff for packed temporary
(section, piece) links.
Both the worker and shard counts are capped at 32,
as a result the auxiliary list storage is bounded at 16 KiB
regardless of the number of input sections.
Focused benchmark on Linux 6.16, Btrfs, 16 pinned CPUs, --threads=16. The
input is 16 copies of an object containing 2,000,000 identical mergeable
strings (32,000,000 pieces total) averaged across 20 runs and 3 warmups.
(RSS is the median)
wall CPU RSS
before 0.353 s 1.523 s 682.5 MiB
after 0.343 s 1.167 s 682.7 MiB
[7 lines not shown]
[mlir][Linalg] Split explicit inherent/discardable attribute APIs access (#218916)
Migrate Linalg, Bufferization, and MemRef users to explicit discardable
or operation-specific attribute access, including the Linalg generator
and C API.
Assisted-by: Codex
[AMDGPU] Add MaxHWAddressableLocalMemorySize to TargetParser (#219020)
This is to aid in resolving
https://github.com/ROCm/llvm-project/issues/3298 : "Comgr should use
target information from upstream TargetParser rather than maintaining
its own"