[ADT][docs] Document SortedVectorMap in ProgrammersManual (NFC) (#215930)
This patch adds a section for SortedVectorMap in the Programmer's
Manual, detailing its intended use cases (small maps, minimal memory
overhead vs DenseMap, iteration in sorted key order) and trade-offs
(O(log N) binary search lookup and O(N) insertion/deletion vs O(1) in
DenseMap).
We also add a cross-reference from the existing "A sorted 'vector'"
section.
[BOLT] Link pthread in Profile and Target libs to fix undefined pthread_rwlock_* symbols (#215748)
MCPlusBuilder.h uses llvm::sys::RWMutex, which aliases std::shared_mutex
on non-Apple platforms. Its inline lock/unlock calls pthread_rwlock_*
directly, so any shared library that instantiates these inline functions
must link pthread explicitly under -Wl,-z,defs.
This only shows up when building with -DBUILD_SHARED_LIBS=ON. With
static libs, the missing symbols get resolved elsewhere on the final
link line, so the problem stays hidden.
LLVMBOLTCore, LLVMBOLTRewrite, LLVMBOLTPasses, and LLVMBOLTUtils already
link ${LLVM_PTHREAD_LIB}; LLVMBOLTProfile and the LLVMBOLTTarget{X86,
AArch64,RISCV} libs were missing it, causing link failures.
[ORC] Move EPCGenericJITLinkMemoryManager to RTBridge proxies (#215797)
Reimplement EPCGenericJITLinkMemoryManager's reserve/initialize/release
calls using rt::Proxy objects rather than direct
ExecutorProcessControl::callSPSWrapperAsync calls, matching
EPCGenericMemoryAccess and EPCGenericDylibManager. The manager's
behavior is unchanged.
Details:
* SymbolAddrs (five ExecutorAddrs) becomes Bindings: the allocator
instance address plus rt::Proxy handles.
* The proxy types and SPS specs are hoisted into shared headers --
RTBridge/GenericMemoryManagerProxies.h and
RTBridge/SPS/GenericMemoryManagerProxySpecs.h -- since they now need
only Shared/SPS vocabulary. Deinitialize is included in the family for
completeness though this manager does not call it.
[9 lines not shown]
[lldb] Guard against null dereference in GetCppObjectPointer (#215710)
ClangUserExpression::GetCppObjectPointer dereferenced the ValueObjectSP
returned by GetObjectPointerValueObject before checking it for null. Fix
by moving the existing check above the child lookups.
[Offload] Keep empty COFF offload entry ranges alive (#215390)
A Windows offload link can have no real offload entries. One example is
a HIP program, or a HIP-related host-only object, built with RDC
but with no kernels or registered device globals. The wrapper still
emits registration code that refers to the offload entry range.
On COFF this range is built from ordered sections. Empty start and stop
sections let `lld-link /opt:ref` discard them. The registration code
then has relocations against discarded `__start_llvm_offload_entries`
and `__stop_llvm_offload_entries` symbols, and the link fails.
Linux avoids this through the ELF section-retention path. The wrapper
emits a dummy `llvm_offload_entries` section entry and places it in
`llvm.used`, which gives the section a retain flag in the ELF object.
That keeps the section alive under `--gc-sections`, so the linker can
still synthesize the `__start` and `__stop` symbols.
The same fix does not map to COFF. COFF does not use ELF-style
[20 lines not shown]
[lldb] Change the Symbol rep for re-export symbols (#213356)
On Darwin system, we have re-export symbols. A library can have a symbol
table entry for function A() that is a re-export symbol; it's only data
is the name of the actual function to call, B(). When code calls A(),
the dynamic loader will resolve this to B() in some other library.
Previously, Symbol was using its AddressRange's Address object's offset
field to point to lldb memory where the name of the target function,
B(), was stored in the binary symbol table. In December Alex put up a PR
to stop abusing the Address object in this way, and store (1) the name
of the target function, and (2) once it has been looked up, the name of
the target function's library.
https://github.com/llvm/llvm-project/pull/172565
Alex originally added a ConstString target_name, FileSpec solib to
Symbol, which increased the size of this object, and lldb stores many of
them, so this was a problem.
[14 lines not shown]
[MachineModuleInfo] add a grouping mechanism to defer deletion MF (#214525)
Add a mechanism so that We can defer deleting the MF after a function is
finalized because there are cases in which we want to late-inline those
MF into some caller.
commit-id:d24afd34
[ADT][ProfileData] Introduce SortedVectorMap and switch CallTargetMap to it (#215733)
This patch introduces SortedVectorMap, a map implementation backed by
a sorted SmallVector, and switches SampleRecord::CallTargetMap from
DenseMap<FunctionId, uint64_t> to
SortedVectorMap<FunctionId, uint64_t, 0>.
Commit 3746f3e4d612 previously changed CallTargetMap from
std::unordered_map<FunctionId, uint64_t> to DenseMap. However, greater
than 97% of CallTargetMap instances have no more than one
element. When storing a single callee, the DenseMap incurs over 60x
memory overhead compared to a single std::pair<FunctionId, uint64_t>
(allocating a 64-bucket table and bit vector of ~1.5 KB vs 24
bytes). Since we instantiate CallTargetMap for every call site, this
~1.5 KB table floor per record adds up to gigabytes of wasted heap
memory across a large profile.
SortedVectorMap keeps key-value pairs in contiguous memory ordered by
key and uses std::lower_bound for lookups. Configuring N = 0 inline
[20 lines not shown]
[CIR] Use CIR integer type for EH personality function signature (#215901)
We had previously been using the MLIR builtin i32 type as the return
type when creating the declaration for exception handling personality
functions. This caused the calling convention lowering to fail because
it wasn't expecting non-CIR types in a CIR function.
This change updates the code that builds the declaration to use the CIR
s32 type. Multiple tests that had been disabling calling convention
lowering because of the above problem can now leave it enabled.
[DebugInfo] Print the record in the salvage debug line (#215903)
The line takes the record pointer, so -debug prints an address rather
than the record.
Changes -debug output only.
[flang][OpenACC] Handle declare actions on CUF allocation ops (#214568)
Recover the typed descriptor from cuf.allocate and cuf.deallocate when
inserting calls to OpenACC declare-action recipes. Add conversion and
lowering coverage for pinned allocations.
[ProfileData] Remove OnDiskMode from SecFuncOffsetTable (#215876)
This patch removes code related to OnDiskMode on both the reader and
writer sides.
Originally, I was going to use OnDiskChainedHashTable in
SecFuncOffsetTable, but I have decided to go with Eytzinger-based
tables. Note that we have never deployed OnDiskChainedHashTable-based
SecFuncOffsetTable.
RFC:
https://discourse.llvm.org/t/rfc-faster-sample-profile-loading/90957/8
Assisted-by: Antigravity
RuntimeLibcalls: Stop improperly reporting fp128 long double calls on ARM
32-bit ARM's long double is IEEE double, so l suffixed calls do not have fp128
type. Additionally, the f128 typed / suffixed functions are not built in glibc as
__HAVE_FLOAT128 is defined to 0 in the arch config. Remove the testcases
which emitted nonexistent or wrongly typed calls and replace with error
tests.
Related: #44744
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
RuntimeLibcalls: Fix reporting incorrectly typed fp128 long double functions
l-suffixed long double math functions are fp128 only when the target's
long double is fp128. The default set provided them on every target that was
not x87 or ppc_fp128, so targets using double as long double wrongly reported
the fp128 l-suffixed functions.
Update tests that were reliant on phantom fp128 calls. These are only available
with glibc on select targets. In cases where the target supports the calls in
some triple, split the tests. In cases where the target has no fp128 library
support, delete the tests.
Related: #44744
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
DAG: Gracefully diagnose missing FP conversion libcalls when softening
Diagnose the missing libcall and return poison instead.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[HLSL][DirectX] Implement lowering of texture stores (#212364)
Fixes https://github.com/llvm/llvm-project/issues/194930
This PR implements the DirectX lowering of texture stores via the
subscript operator (`.operator[]`).
Also adds missing frontend tests exercising stores to textures via the
subscript operator.
Also fixes an issue with `lowerTextureLoad` incorrectly supplying a mip
level to texture loads on UAV textures (except multisampled UAV
textures) which caused validation errors.
An UndefValue is used in the lowering because DXIL is based on an older
version of LLVM that requires the use of undef.
Assisted by: Claude Opus 5
[DWARFLinker] Consider module units when creating the type unit (#215731)
The parallel linker creates the artificial type unit only when some
compile unit uses an ODR language, but it looks for that language in the
compile units of the object files alone. A clang module unit decides its
own ODR availability from its own DW_AT_language, so a module built as
C++ or ObjC++ imported from an object file whose units are all C, ObjC
or Swift places DIEs in the type table which does not exist, asserting
in CompileUnit::cloneDIE and dereferencing null without assertions.
Scan the languages of the module units as well, so a module which
deduplicates types always has a type unit to hold them.
rdar://182719465
[lldb] Search for a corefile's images before loading any of them
A userland or kernel corefile can list hundreds of images, and searching for
one can shell out to a symbol server or fetch over the network. Searching for
them one at a time is where loading such a corefile spends its time.
Add a batch form of SymbolLocator::Locate that runs the searches on the
debugger's thread pool, gated on target.parallel-module-load. Results come
back in the order the requests were given, since that order decides the
Target's module order. Only the results are ordered, and anything a search
reports to the user arrives in whatever order the searches finish in.
Only the plugin searches run concurrently, so a platform hook does not have to
be thread safe to take part, and reading a binary's UUID out of memory stays
on the calling thread.
Setting up a platform binary can replace the Target's platform and dynamic
loader, and now happens for every image before any of them is searched for, so
the platform a corefile asks for is the one all of its images are searched
[4 lines not shown]
[lldb] Consult the platform before the symbol locator plugins (NFC)
A symbol locator plugin has no Platform to consult, so a platform that knows
where its binaries live cannot take part in a search. The only way to reach
one is Platform::GetSharedModule, which also creates the module and registers
it, so the lookup cannot be reused by a caller that wants to search for many
binaries before creating any.
Add a hook that only answers where the files are. An answer ends the search,
so an override owns what the plugins would otherwise have been asked for.
No platform overrides it yet. A follow-up moves PlatformDarwinKernel's kext
and kernel index lookups behind it.
Assisted-by: Claude
[MSP430] Add AsmPrinter names
So that -stop-before=msp430-asm-printer works, which is used in some
DebugInfo tests.
Reviewers: aeubanks, asl
Pull Request: https://github.com/llvm/llvm-project/pull/215909
[lldb] Add a unified entry point for locating a binary and its symbols
The three-plugin composition that finds a binary and its symbol file is open
coded in several places. Give it one home, as a pure function of a module
spec, so that a caller holding several binaries can search for all of them
before creating any.
Nothing on this path takes a lock, where ModuleList::GetSharedModule holds the
shared module list's lock across the plugin search. That is what will make
searching for several binaries at once worth doing.
A miss that nothing could explain gets its own error type rather than an error
code, because a Status carrying an errno converts to the same llvm::ECError,
and a caller composing its own message for a plain miss must not swallow a
failure to reach a symbol server.
DynamicLoader's search no longer runs twice for a binary that is not already
known, and a module created from a located binary is now registered in the
shared module list, so a second Target asking for the same binary reuses it.
[2 lines not shown]