[libc++][CI] Add a Github workflow to test libc++ tools (#211067)
We have a few scripts under libcxx/utils, and they wouldn't be tested on
a regular basis. As a result, changes to e.g. the build system could
break these scripts, which in turn could break some Github workflows
like the libc++ PR benchmarking workflow.
This patch adds a new `test-tools` configuration to `run-buildbot` which
allows testing these tools locally, and a new dedicated Github workflow
to run it.
clang/AMDGPU: Migrate cc1 tests to subarch triples (5) (#211840)
Rewrite OpenMP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu, and regenerate autogenerated CHECK
lines. Tests that intentionally assert the "target-cpu" attribute are
left unchanged.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
AMDGPU: Reject unrecognized amdgpu subarch in TargetID parsing (#211866)
A bare "amdgpu" or an unrecognized "amdgpu<x>" both parse to the
amdgpu arch with no subarch; TargetID::parse previously accepted them,
taking a named processor and ignoring the missing subarch.
Reject triples with no subarch, unless it uses the legacy spelling.
This is another workaround for Triple not having a proper unknown value
for subarches.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[NVPTXAsmPrinter] Allow self-referential device global initializers (#197838)
This change adds support for cyclic device global initializers in NVPTX,
including self-references and references between distinct globals. The
backend’s global-emission ordering walk previously treated every cycle
as an error and aborted with “Circular dependency found in global
variable set.” As a result, valid patterns such as __device__ void
*arr[] = {(void *)"foo", &arr[0]}; were rejected. The NVPTX asm printer
now models initializer dependencies as a graph and emits its strongly
connected components in dependency-first order. Acyclic components are
emitted normally. For cyclic components, it first emits compatible PTX
.extern declarations and then emits the definitions in a valid order.
Cycles that cannot be represented this way, such as cycles containing
only static globals, are still rejected. The forward declarations reuse
the normal definition emitter so their address spaces, alignments,
types, and aggregate layouts match the definitions. Added new tests to
cover self-references, cycles between distinct globals, mixed linkage,
packed aggregates, dependency ordering, and unrepresentable static-only
cycles.
[MC][NFC] Remove some virtual function from MCAsmInfo (#211858)
The MCAsmInfo vtable is currently 144B (no anchor)/152B (anchor) large
-- and there are 49 of these in an all-target libLLVM.so. Some of these
are not needed or can be easily removed. This removes 5 vtable entries.
Some notes on the remaining functions -- I think this vtable can be
removed entirely without too much effort:
- getStackSection can also be removed, this is ELF-only; unfortunately
this will require code duplication between AsmPrinter and
MCELFStreamer.
- getExprForPersonalitySymbol is single-use and two-overrides (Darwin on
x86-64, AArch64), likely removable.
- shouldOmitSectionDirective has three override modes -- COFF (disallow
for COMDAT/unique section), AMDGPU (4 .hsa sections), and always-omit
(NVPTX, SPIRV). This is only called from printSwitchToSection, so COFF
[20 lines not shown]
[lldb] Recover a WebAssembly function's mangled name from its declaration (#211707)
The Wasm "name" section stores only demangled names, so SymbolFileWasm
recovers each function's mangled name from the DWARF and attaches it to
the code symbol.
Currently, it only does so from a defining DIE, matched by address. When
we only have a declaration DIE (e.g. TU compiled without debug info), it
still carries the linkage name, but wouldn't get associated without the
address.
Match a declaration-only DIE to its code symbol by the demangled name
that the name section already carries, and attach the linkage name that
way.
Assisted-by: Claude
[OpenMP] Propagate PRESENT to pointee entries in mapper codegen
Extend map-type-modifier propagation in emitUserDefinedMapper to the PRESENT
modifier, but only for entries that have an attach ptr (the pointee data, whose
storage differs from the struct's own). A present modifier on the outer clause
must require that pointee to be present on the device.
This is gated on a new PropagatePresentToPointee argument, which Clang sets from
CGM.getLangOpts().OpenMP >= 60. Before 6.0 the present modifier is treated as
not applying to the pointee: the spec committee confirmed the divergence
between the present motion modifier (to/from) and the present map-type modifier
(map) was unintentional, to be fixed as an OpenMP 6.0 erratum. Only propagation
is gated; present written directly in a mapper's own clause applies at all
versions.
A TODO notes PRESENT should also propagate to the struct's own members, which
is blocked while pointer members use PTR_AND_OBJ.
Update the present-check tests to their final 6.0-gated behavior.
[2 lines not shown]
[ConstraintElim] use condition from latch in addInfoForInductions. (#210984)
Also use condition in latch to inject %iv <= %B and co into the header,
if the latch condition compares a post-inc IV like %iv + %step != %B.
This allows reasoning about loops that have been rotated before
ConstraintElimination, e.g. during the LTO phase or Swift where the
frontend already rotates loops before generating LLVM IR.
Alive2 Proof for injecting %iv <= B from %iv + %step != %B in latch:
https://alive2.llvm.org/ce/z/pH8Czb
This enables a number of additional simplifications in practice
(https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/736).
It comes with a compile-time impact when doing LTO, as all loops will be
rotated
and will hit the new code path.
* stage1-ReleaseThinLTO: +0.08%
[9 lines not shown]
[OpenMP][Clang] Enable ATTACH-style maps for mappers.
Track per-entry attach-ptr info (HasAttachPtr) through mapper codegen so that
emitUserDefinedMapper does not add a new outer MEMBER_OF to pointee/combined
entries (which occupy different storage than the struct) or to ATTACH entries.
Clang and the MLIR translator populate the per-entry array in parallel with the
other MapInfosTy arrays.
Address review:
- Rename MapSkipMemberOfArrayTy to MapHasAttachPtrArrayTy to match the
HasAttachPtr field it backs.
- Restructure the emitUserDefinedMapper comment into a bulleted (*)/(**)/(***)
list keyed to the example entries.
- Reword the Clang comments: HasAttachPtr marks pointee entries that have a
base attach-ptr; a combined entry has a base attach-ptr if its constituents
do; cross-reference emitUserDefinedMapper for the MEMBER_OF rationale.
- Update the moved present-check tests to their now-correct behavior (the
attach-style maps make the inbounds present checks pass and remove the
"explicit extension" errors).
[2 lines not shown]
[lldb] Remove ConstString from FileSpec (#211394)
This commit completely removes ConstString from FileSpec, replacing it
with llvm::SmallString instead.
I considered combining the directory and the filename together into one
field, but then it became impossible to distinguish between a
partially-constructed FileSpec's last directory and a fully-constructed
FileSpec's filename.
The sizes of the SmallStrings are somewhat arbitrary. I tested out a few
other configurations on my machine locally and this yielded the best
memory/runtime tradeoffs.
I measured the impact of this change in two ways:
(1) Runtime performance
I measured the runtime impact by using LLDB's statistics with `stat
enable` and `stat dump -f` (forcing the parsing of symbols) for a debug
[15 lines not shown]
[Clang] Avoid querying tag definitions for invalid DeclSpecs (#210085)
Guard hasTagDefinition() against invalid type-specifier state so
recovery from invalid auto/tag combinations does not assert.
Fixes #210014
---------
Signed-off-by: Osama Abdelkader <osama.abdelkader at gmail.com>
[OpenMP] Propagate ALWAYS/DELETE/CLOSE map-type modifiers to mapper entries
When a map clause uses a user-defined mapper, the map-type-modifying bits
(ALWAYS, DELETE, CLOSE) on the outer clause must apply to each map the mapper
inserts (OpenMP 6.0:281:34). Propagate them in emitUserDefinedMapper by OR-ing
the imported modifier bits into each pushed component, except ATTACH entries
(ATTACH|ALWAYS is reserved for attach(always) and the other bits are
meaningless for ATTACH).
PRESENT is intentionally not propagated here yet (a TODO notes it is handled in
a follow-on, since it requires distinguishing pointee entries from the struct's
own storage).
Add tests:
- offload mapper_map_always_from.c: ALWAYS forces a member copy-back that the
ref count would otherwise suppress.
- offload Fortran target-custom-mapper-delete.f90: DELETE is propagated to the
mapper's member entry so it is removed by target exit data.
Co-Authored-By: Claude Opus 4.8 <noreply at anthropic.com>
[IR] Make semantics of strictfp consistent v2 (#211769)
Changes: The patch was originally landed as af0c933e (#209465), but
there was an issue with strictfp functions being inlined into
non-strictfp functions. The issue has since been resolved by a2b42b10a
([IR] Reject inlining strictfp alwaysinline callee into non-strictfp
caller, #210701) and the re-land is identical.
Although the section on constrainedfp in the LangRef clearly states "All
function definitions that use constrained floating point intrinsics must
have the strictfp attribute", indicating that a function with strictfp
calls must be marked with strictfp, the general description of strictfp
does not specify this. Refine its semantics and make it so, eliminating
the inconsistency.
[VPlan] Endow DerivedIV with IRFlags (#205908)
Endow DerivedIV with no-wrap flags that are used in all adds and muls:
the FP induction can still get the FastMathFlags from the FPBinOp. The
patch changes vputils::createScalarIVSteps where no-wrap flags are
applicable. GEP no-wrap flags are missing nearly everywhere, and is left
to an exercise for a follow-up.
Proof: https://alive2.llvm.org/ce/z/rHtwEH +
https://alive2.llvm.org/ce/z/h297HG for a larger UF on one test
AMDGPU: Reject unrecognized amdgpu subarch in TargetID parsing
A bare "amdgpu" or an unrecognized "amdgpu<x>" both parse to the
amdgpu arch with no subarch; TargetID::parse previously accepted them,
taking a named processor and ignoring the missing subarch.
Reject triples with no subarch, unless it uses the legacy spelling.
This is another workaround for Triple not having a proper unknown value
for subarches.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[lldb] Classify embedded formatter sections in WebAssembly objects (#211704)
A `section` attribute on a data variable is placed in a named data
segment on WebAssembly rather than a top-level custom section, so the
.lldbformatters and .lldbsummaries segments that carry embedded data
formatters were classified as plain data. The data-formatter loader
looks these up by section type, so embedded summaries and synthetic
child providers were never registered for a Wasm module.
Map the two formatter segment names to their section types when creating
sections, and place the segments in linear memory like other data so
their contents resolve. This mirrors the ELF and Mach-O object file
plugins.
Assisted-by: Claude
AMDGPU: Avoid dropping poison when extracting a high element
Haven't found a case where this matters, but I want to stop finding
this instance of the is-undef-get-undef pattern.
AMDGPU: Validate processor is consistent with subarch in TargetID parsing (#211828)
TargetID::parse checked that a named processor was a recognized GPU, but
not that it was consistent with the triple's subarch. A target id like
"amdgpu9.00-amd-amdhsa--gfx803" was accepted even though gfx803 does not
belong to the amdgpu9.00 subarch, silently taking the processor and
ignoring the mismatched subarch.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
AMDGPU: Don't pack a build_vector with an undef/poison lane
Once ISD::POISON is legal it reaches isel and is treated as canonical, so
is_canonicalized_2<build_vector> matched build_vector<x, poison> and selected
a v_pack for a don't-care high lane. Avoids regressions in future patches.
Co-authored-by: Claude (Claude-Opus-4.8)
clang/AMDGPU: Migrate cc1 tests to subarch triples (8)
Rewrite SemaHIP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (7)
Rewrite the remaining small test directories (CodeGenCXX, Misc, Sema,
SemaCUDA, SemaCXX) cc1 RUN lines to the new subarch triple form, dropping
the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (6)
Rewrite CIR/CodeGenHIP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu, and regenerate autogenerated CHECK
lines.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (5)
Rewrite OpenMP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu, and regenerate autogenerated CHECK
lines. Tests that intentionally assert the "target-cpu" attribute are
left unchanged.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>