[clang][driver][darwin] DarwinSDKInfo doesn't match sufficiently modified triples, doesn't warn for unsupported architectures (#204061)
DarwinSDKInfo::getPlatformPrefix(...) is passed the effective target
triple which has undergone modifications from the original -target
value, which can sometimes even include changes to the triple's
environment. That will cause it to fail to match the platform infos, not
get a platform prefix, and get incorrect default search paths. In the
case where a triple doesn't match, check all platform infos, and if they
all have the same platform prefix, then use that.
DarwinSDKInfo::supportsTriple(...) doesn't try to match the architecture
of the triple. That makes it not emit -Wincompatible-sysroot e.g. when
trying to use arm64 against a sufficiently old macOS SDK or when still
trying to build i386 for macOS. Instead of parsing values from
SDKSettings.json into a Triple, storing the probably-relevant
components, and then comparing those against a full Triple, just store
the parsed triple and get rid of the custom comparison code. While this
does make the matching problem above a little more fragile, in practice
that's well mitigated by treating thumb* and arm* as equivalent, and it
[6 lines not shown]
AMDGPU: Avoid default subtarget in generated codegen tests (2/9) (#205785)
Continue migrating away from testing the dummy target, and use
real targets approximating the old behavior. Performed by script.
Co-Authored-By: Claude <noreply at anthropic.com> (Claude-Opus-4.8)
AMDGPU: Avoid using default subtarget in generated codegen tests (1/9) (#205784)
Fix codegen tests using amdgcn triples without a target-cpu. The dummy
default subtarget has always been an irritating edge case to deal with.
For unknown/mesa3d/amdpal triples, this has been a gfx600-like result
and gfx700-like result for amdhsa. Convert tests to use the explicit
target. This was performed by vibe-coded script, and covers tests
using update_{llc|mir}_test_checks. There are some minor codegen
differences to be expected, mostly due to now having a scheduling
model.
In the future we should forbid trying to codegen the default target.
Co-Authored-By: Claude <noreply at anthropic.com> (Claude-Opus-4.8)
[MLIR] Fix broken 'Successor<CPred<...>>' functionality in mlir-tblgen (#205375)
Previously, mlir-tblgen would generate incorrect C++ code when
passing a custom constraint to `Successor<...>`. The code would fail
to compile. We lacked end-to-end tests for this functionality and all
in-tree dialects only use `AnySuccessor` for their successors.
Custom C++ predicates for an Operation's successor(s) can be useful
in order to generate verification for certain conditions (e.g. that the
successor is the "next" block). This commit fixes the mlir-tblgen
functionality and adds end-to-end tests in the Test dialect for single
and variadic successors.
Assisted-by: Claude
[NFC][CIR] Fix test that used 'DAG-SAME' (#205867)
'DAG-SAME' isn't a thing in file-check, so these lines weren't being
checked. This patch just puts them all on teh same line as they should
be.
[lldb][gdb-remote] Send QSetSTDIOWindowSize for a 0x0 size (#205772)
The client uses a 0x0 STDIO window size as a deliberate signal to the
server that there is no client terminal, so the server should redirect
the inferior's stdio over anonymous pipes instead of a ConPTY (on
Windows).
This is a follow up to https://github.com/llvm/llvm-project/pull/203562.
rdar://178725958
[MemProf] Make ICP test check compared target more strictly (#201656)
We intend to check that we are comparing to the original uncloned
target, but weren't checking for EOL. Add the EOL check.
[Clang-tools-extra] Add missing values to CharacteristicKindStrings (#205455)
Static analysis flagged that we were indexing CharacteristicKindStrings
in PPCallbacksTracker::FileChanged based on the values of
SrcMgr::CharacteristicKind which would access outside array bounds for
some values of the enum. As far I can see all value of the enum are
possible when calling FileChanged and so the array should indeed cover
all values. So I added the missing values to the array.
[Clang] Rebuild lambda capture initializers in default member initializers
Fixes https://github.com/llvm/llvm-project/issues/196469
Since the CWG1815 implementation, InitListChecker rebuilds a default member initializer at its point of use in aggregate initialization. The rebuild uses the EnsureImmediateInvocationInDefaultArgs tree transform, where TransformCXXBindTemporaryExpr strips CXXBindTemporaryExpr nodes, relying on the subexpression's rebuild to recreate the temporary binding and re-register cleanups in the current evaluation context.
However, the transform overrides TransformLambdaExpr because the lambda body is not a subexpression. Returning the original lambda unchanged skips the MaybeBindToTemporary call that BuildLambdaExpr would normally perform, so the rebuilt initializer can lack the closure temporary binding and cleanup marker. CodeGen then misses the closure destructor and init-captured members can leak.
Lambda init-capture initializers are evaluated in the enclosing context and can also contain immediate invocations or source-location expressions that need to be rebuilt at the default-initializer use site. Rebuild those initializer expressions without rebuilding the closure type, capture declarations, or body, so body references to init-capture declarations remain valid. When a capture initializer changes, create a replacement LambdaExpr that shares the existing closure and body, then bind the lambda temporary explicitly to restore cleanup emission.
Co-Authored-By: GPT-5.5 <noreply at openai.com>
[CIR] Fix lost catch clauses on EH landing pads (#205638)
A throw caught by an enclosing handler could call std::terminate instead of
entering the handler. The smallest trigger is a try that destroys a local and
throws a new-expression whose type has a throwing constructor: two cleanups
then sit on the path to the handler and produce two cir.eh.initiate operations
that funnel into one cir.eh.dispatch. The same bug also asserted on ordinary
nested try/catch and dropped the outer handler's catch clause from the inner
landing pad on a nested throw.
ItaniumEHLowering::lowerEhInitiate derived each landing pad's catch clauses
while destructively walking the eh_token graph, tying a correctness property
to lowering order: whichever initiate lowered first tore down the shared cir.br
edges, so the other reached no dispatch and kept an empty catch_type_list -- a
cleanup-only landing pad that resumes past the handler.
lowerFunc now does a read-only walk first. For each initiate it collects every
dispatch the exception can reach (innermost first, preserving nested catch
order) and records the catch_type_list, plus the cleanup clause when a cleanup
[4 lines not shown]
[CIR] Lower __atomic_is_lock_free / __c11_atomic_is_lock_free (#205862)
`__atomic_is_lock_free` and `__c11_atomic_is_lock_free` were routed to
`errorNYI` in CIRGen, so `std::atomic<T>::is_lock_free()` failed to
compile under `-fclangir` whenever the query wasn't constant-folded --
which is what the libcxx atomics lock-free tests hit.
This mirrors classic CodeGen (`CGBuiltin.cpp`): emit a call to the
runtime entry `bool __atomic_is_lock_free(size_t size, void *ptr)`.
`__atomic_is_lock_free` forwards its pointer argument;
`__c11_atomic_is_lock_free` passes a null pointer, since an `_Atomic`
object is always suitably aligned. `__atomic_test_and_set` /
`__atomic_clear` stay NYI.
The lowered call omits the `noundef`/`zeroext` argument and return
attributes classic emits, and the declaration picks up `dso_local`.
That's the existing CIR libcall attribute gap, so the test uses split
`LLVMCIR`/`OGCG` prefixes where the two diverge and a shared skeleton
where they match.
[SystemZ][z/OS] Improve link command for shared libraries (#204205)
This PR adds -e/-O CELQSTRT and improves the link command for shared
libs.
Co-authored-by: Yusra Syeda <yusra.syeda at ibm.com>
[flang][openacc] Ignore bare acc routine in module subprogram part instead of erroring out (#205450)
This small code below would trigger not easy to understand error like
`error: expected 'END'`. Ignore such directive and emit the standard
warning.
```
module acc_routine_bad
contains
!$acc routine
subroutine acc_routine20()
end subroutine
end module
```
[SBVec] Implement topDown/botUp vectorizers in unison
This patch introduces the `top-down-vec` pass to the Sandbox Vectorizer,
adding the ability to traverse use-def chains top-down to discover and
collect vectorization opportunities. Furthermore, this patch unifies
the two vectorizers into a single implementation to minimize code
duplication.
[lldb] Change BreakpointList::FindBreakpointsByName to use StringRef (#205695)
It's not possible to turn a StringRef into a c-string safely without a
potential allocation. I will use this in a follow-up to remove
ConstString from BreakpointName.
[ADT] Add StringRef::nonEmptyOr (#204690)
This adds a new method to StringRef. The intended use case is for
situations when a non-empty StringRef is needed but some operation
returns an empty StringRef because of missing data or some other
exception.
This is primarily for ergonomics. I'm mainly motivated to avoid creating
a temporary StringRef in situations where a StringRef is obtained
through a long call chain. e.g.
`doAThing(my_obj.getFoo().getBar().getBaz().getStringRef().nonEmptyOr("unknown"))`
---------
Co-authored-by: Jonas Devlieghere <jonas at devlieghere.com>
[BPF] Sort BTF struct members by offset (#205396)
Sort BTF structure elements by their debug offsets. Prevent
source-ordered Rust debug metadata from producing descending member
offsets after rustc chooses a different physical layout, because the
kernel rejects such BTF.
Use the sorted order for member emission, declaration-tag component
indexes, and CO-RE access strings. Keep physical offset calculations on
the original debug indexes so changing BTF order does not change
generated code.
Eliminate the need for the bpf-linker metadata rewrite by enforcing the
ordering in the LLVM BPF backend:
https://github.com/aya-rs/bpf-linker/commit/1007ec7fed03562eb7d08f3e7521094a7e698b95
Revert "[NVPTX] Fold symbol addresses into memory operands" (#205852)
Reverts llvm/llvm-project#202379
check-llvm now fails on one of the new testcases
```
Failed Tests (1):
LLVM :: CodeGen/NVPTX/address-folder.ll
```
[offload][OpenMP] Fix partial warp reduction
Don't use a full warp for the final cross-team reduction if the
reduction's thread limit is below the warp size.
Claude assisted with the test.
[ADT] Rewrite ImmutableSet/Map in-order iterator without per-node state (#205552)
ImutAVLTreeInOrderIterator was layered on a "generic" iterator whose
stack stored a 2-bit visit-state (None/Left/Right) packed into the low
bits of each node pointer, and which was spun through several
intermediate states per in-order step.
Replace it with a single iterator that keeps a stack of plain node
pointers (the root-to-current ancestor chain) and recovers the traversal
direction by inspecting whether it is ascending from a node's left or
right child. A node's parent cannot be cached in the node itself because
these trees are persistent and structurally shared (one node may be a
child of different parents across tree versions), so the ancestor stack
is the per-traversal parent chain.
The observable contract is unchanged: same in-order sequence, same
skipSubTree() semantics (so tree canonicalization via isEqual is
unaffected), and the iterator stays bidirectional. operator== now
compares the current node rather than the whole path, which is O(1) and
[21 lines not shown]
[lldb] Fix DWARFASTParserClang formatting (#205857)
In #205701, I applied Michael's suggestion and enabled auto-merge.
Despite the formatter check failing, the change still got merged. Fix
the formatting and another inconsistency in the use of braces.