[clang][bytecode] Use a regular static function in `Pointer::toRValue()` (#219772)
Instead of the previous std::function, which was awkward due to
recursing.
[lld][MachO] Support Objective-C class stubs
Teach Mach-O objc stubs to synthesize class-message stubs that load the class object, selector, and objc_msgSend target.
lld already supports the Apple clang _objc_msgSend$<selector> stub form, even though upstream clang does not currently expose a driver or cc1 flag for emitting it. Apple clang also emits _objc_msgSendClass$<selector>$_OBJC_CLASS_$_<class>; handling that form completes the existing selector-stub support.
Cover local classes, dylib classes, archives, dynamic lookup via -U, missing class symbols, malformed names, unsupported architectures, and dead stripping.
[lld][MachO] Fix ObjC stubs from autolinked archives
Move ObjC stub preparation after LC_LINKER_OPTION processing so archive members loaded via autolink can contribute _objc_msgSend$ selector stubs before selector references are built.
Previously those stubs missed __objc_methname setup; assert builds could fail in makeSelRef, and release builds could form an invalid selector reference.
[lld][MachO] Prepare ObjC stubs for variable sizes
Track ObjC stub sizes explicitly so future changes can mix different stub layouts in one synthetic section.
[lld][MachO] Order objc stubs by caller priority
__objc_stubs is synthetic, so the input section sorting never reaches
its entries: they stay in symbol interning order even with -order_file.
A stub is faulted in when its caller runs, so stubs called from hot code
end up scattered across pages that startup otherwise never touches.
Record the sections that branch to each stub, give each stub the lowest
priority among its callers, and stable-sort the stubs before addresses
are assigned. Stubs with no prioritized caller keep their relative order
at the end.
General __stubs ordering is left alone because stubsIndex also drives
lazy pointers, indirect symbols, and bind/rebase offsets.
This reduces page faults in __objc_stubs by 40% for a large app.
[lld][MachO] Support Objective-C class stubs
Teach Mach-O objc stubs to synthesize class-message stubs that load the class object, selector, and objc_msgSend target.
lld already supports the Apple clang _objc_msgSend$<selector> stub form, even though upstream clang does not currently expose a driver or cc1 flag for emitting it. Apple clang also emits _objc_msgSendClass$<selector>$_OBJC_CLASS_$_<class>; handling that form completes the existing selector-stub support.
Cover local classes, dylib classes, archives, dynamic lookup via -U, missing class symbols, malformed names, unsupported architectures, and dead stripping.
[lld][MachO] Fix ObjC stubs from autolinked archives
Move ObjC stub preparation after LC_LINKER_OPTION processing so archive members loaded via autolink can contribute _objc_msgSend$ selector stubs before selector references are built.
Previously those stubs missed __objc_methname setup; assert builds could fail in makeSelRef, and release builds could form an invalid selector reference.
[lld][MachO] Prepare ObjC stubs for variable sizes
Track ObjC stub sizes explicitly so future changes can mix different stub layouts in one synthetic section.
[clang] Don't add documentation comments to the AST if not requested (#206363)
Don't collect documentation comments unless they are requested
(-Wdocumentation, -fparse-all-comments, code completion, PCH
serialization, or libclang)
closes #165515
---------
Co-authored-by: Erich Keane <ekeane at nvidia.com>
[mlir][LLVM] Preserve !associated and !absolute_symbol on llvm.mlir.global (#218839)
Add optional `associated` and `absolute_symbol` attributes on
`llvm.mlir.global` so the corresponding LLVM IR metadata is preserved
through import and export.
`associated` is a symbol ref to another global, alias, or function (used
for ELF `SHF_LINK_ORDER`). `absolute_symbol` is an array of `[lower,
upper)` integer range pairs, with `[-1, -1]` for the full set.
Verifier rejects a self-associated global and malformed range lists.
Translation attaches the metadata after all globals, aliases, and
function signatures exist so symbol refs can be resolved.
Fixes #215549
Assisted-by: Cursor
---------
Co-authored-by: Cursor <cursoragent at cursor.com>
[ORC] Route SimpleRemoteEPC::runAsMain through CallMainProxySpec (#219770)
Replace runAsMainAddr with a CallMain proxy that is lazily initialized
by lookupAndApply on first use. This is another step towards making
callWrapperAsync the only call primitive
ExecutionSession/ExecutorProcessControl need to know about.
[clang][bytecode] Reduce `EvalEmitter::Descriptors` inline size (#219773)
For pure expressions, we usually have few locals and few scopes. Reduce
the inline size here.
[clang][bytecode] Remove native pointer marshalling (#218911)
Just emit pointers to bytecode as uintptr_t. This avoids a vector and a
DenseMap in Program. We used to emit the ID as uint32_t, but since all
arguments are pointer-aligned in bytecode anyway, switching to uint64_t
shouldn't cause a memory regression.
[clang][bytecode] Divide `noteStep()` in hot and cold paths (#219760)
Move the hot success path into the header file to encourage inlining.
Also add a likeliness-hint since the steps check should _almost_ never
hit.
[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] Flatten 'UnsafeBufferReachableAnalysisResult' to a plain set
Previously, an 'UnsafeBufferReachableAnalysisResult' was organized as
a map from contributors to their mutually exclusive
sub-results. Because this extra layer of contributor information
proved unnecessary, this commit flattens the result into a plain set.
The source transformation expects the result to be a plain set, so
this is a prerequisite step for
rdar://185840466
[SSAF] Add APIs for resolving bare EntityNames to qualified EntityNames (#219033)
Also give Transformation access to SSAFOptions so that it can use
link-unit and compilation-unit IDs to resolve bare EntityNames.
first step of
rdar://185840466
[orc-rt] Fold the default clear_icache into sys/CacheControl.h. (#219758)
It was in a sys/posix/ header, but the default belongs with the
declaration: sys/CacheControl.h now selects on the builtin rather than
on an OS, so a freestanding target -- which has no __unix__ but does
have the builtin -- is served too. Darwin keeps its own header, to call
libSystem directly rather than depend on __clear_cache being linked in.
[FoldingSet] Add typed lookup/insert/erase/getOrInsert (#219644)
FindNodeOrInsertPos hands the insertion state to InsertNode as a `void *`:
any pointer converts to it, only a comment says where it may come from,
and since the switch to linear probing the value is the node's hash, not
a position at all.
Carry it in FoldingSetInsertToken instead, the hash wrapped in a type
whose constructor and accessor are private to FoldingSetBase, with
NotAHash as the no-token state. The `void *` overloads remain,
forwarding to the typed ones, until their callers are migrated.
LLM-aided
[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