[CIR] Remove 2 NYIs in CIRGenTypes.cpp (#238589)
While looking at NYIs I realized that incomplete and vla types don't
need to pay attention to CVR qualifiers, as classic codegen does not.
This just removes the two NYIs and adds tests here.
These qualifiers are ONLY valid in C and only on function parameters,
where they are entirely a SEMA feature, so there is nothing
codegen should have to do here.
AtomicExpand: Use RuntimeLibcallsInfo signatures for atomic libcalls
Take the function type and attributes of the emitted __atomic_* calls
from RuntimeLibcallsInfo instead of building them by hand.
This fixes missing extension attributes on the value operand and
result of the sized variants, which are unsigned integers of the
access size. On targets whose C ABI extends narrow integer arguments,
such as RISC-V and ARM, the callee could see unextended high bits. i8
and i16 values now get zeroext, and i32 values get signext on
RV64. Callers can also rely on the extended return value, which
removes redundant extensions after some calls.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[offload][amdgpu] Replace KLE test (#238800)
Temporarily set kernel_launch_environment_reduction.c to unsupported on
AMDGPU until https://github.com/llvm/llvm-project/issues/238409 is
resolved.
Add kernel_launch_environment_dyn_gprivate.c instead, which is also
stress-testing the KLE, but without accidentally stress-testing
concurrent memory transfers as well and, thus, not causing the GPU hang
on the buildbot that is described in the linked GitHub issue.
Claude assisted with this patch.
RuntimeLibcalls: Only apply vector math attributes to floating point vectors
i128 is now <2 x i64> on Win64, which made the vector type checks treat
integer helpers like __atomic_load_16 as vector math functions and mark
them nosync and nofree. Check for a floating point vector argument.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply at anthropic.com>
RuntimeLibcalls: Use <2 x i64> for i128 libcall types on Win64
Win64 passes __int128 by reference and returns it in XMM0. i128 uses
GPR pairs, and <2 x i64> uses the correct vector register. This
matches the type AtomicExpand and clang uses for these functions.
Also fix AtomicExpand to use the correct type for UEFI (which should
eventually use the type information in RuntimeLibcallsInfo).
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Demangle] Support D-prefixed types in literals (#238564)
`<expr-primary> ::= L <type> <value number> E`, and `<type>` includes
the D-prefixed builtin types (`DB<n>_` for `_BitInt`, `Du` for
`char8_t`, ...). `parseExprPrimary` only accepted `LDn0E` and rejected
every other `L D...` literal, so names such as `_Z1fILDu114EEvv` and
`_Z16ManglingTestNTTPILDB99_38EEvv` could not be demangled. Treat them
as ordinary typed literals. `LDm` (C++26 reflection) is still rejected.
[Godbolt](https://godbolt.org/z/x4eYGnKaf): clang trunk and GCC 15.3
emit the same symbol for a `char8_t` template argument.
Part of #111345.
LLM-aided
[CIR][CodeGen] Add conditional 'run' lines to CodeGen tests that pass (#238886)
I did a run through all of the tests with some sort of codegen/filecheck
functionality that passed, and added a conditional clang-ir run line to
make sure we don't regress. This converts 574 tests based on the
following rules:
1- Only tests that 'pass' with clangir on by 'default' on my machine 2-
Only Codegen-esque tests:
-%clang_cc1 in the run line.
-has a code gen action, -emit<something>
-It pipes to filecheck
3- Only tests where EVERY applicable 'codegen' test line can be
converted, and doesn't violate one of the following:
-already has a clang-ir run setup
-it uses -verify
-it uses %t or %T, as CIR would overwrite the temp file
-it uses 'not'
-it has no explicit triple (AS CIR is limited as to its supported
[7 lines not shown]
[RISCV] Add RISCVABI helper functions for single/doubleFP and PureCap.
Use them to simplify code that checks for individual enum values.
I've lumped Cheriot in with the other pure cap ABIs, but maybe that's
wrong.
I've added the pure cap ABIs to the FP functions, but I've added
asserts that the ABI is not pure cap at the usage to allow someone
to review in the future.
[RISCV] Add ABI_IL32PC64E and ABI_CHERIOT to RISCVABI::isRVE. Use in RISCVTargetELFStreamer::finish. NFC (#238673)
The isRVE function is used in codegen, but as far as I know we don't
support codegen with these ABIs yet so that code isn't reachable.
[InstCombine] Narrow relational fcmps with inexact constants
When a constant rounds to a normal IEEE-like source value, compare directly
against that rounded value and adjust strictness according to the rounding
direction. The equality outcome at the rounded value is determined by the
original predicate's less-than or greater-than outcome. Unordered behavior
is preserved.
Require a single-use fpext so that the transform removes an instruction.
Keep non-normal results and non-IEEE-like source formats unchanged.
Update five existing functions in fcmp.ll and cover nonstrict-to-strict
adjustments and negative constants with ordered and unordered predicates.
MachineLICM: Preserve the machine dominator tree
MachineLICM already updates the dominator tree when it splits an edge,
so report it as preserved instead of forcing the next user to rebuild
it.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[OpenMP][clang] Correctly widen loop iteration calculation (#237914)
For a loop like `for (uint32_t i = 0; i < (size_t)13; i += 2)`, widen
the `lower - step + 1` calculation to the size of the upper bound type,
aka size_t in this case. Otherwise, we would not caluclate 13 - (-1),
but instead 13 - (0xFFFFFFFF) and get the wrong result.
Fixes https://github.com/llvm/llvm-project/issues/70687.
Claude assisted with this patch.
[GlobalISel] Auto-commute combine patterns
Emit both operand orders for constrained commutative generic match
patterns, including each use of a PatFrag. Skip redundant permutations
and enforce MaxPermutations before allocating expanded alternatives.
Give each permutation its own operand expansions so operand indices
cannot leak between alternatives.
Keep commuted immediate patterns available with constant-to-RHS
canonicalization, and consolidate AMDGPU carry rules while preserving
zero-addend and RHS-first matching.
Make the integer and AMDGPU multiply/select helpers accept either operand
order.
Add emitter documentation and TableGen, MIR, and codegen regressions.
[libc] Reland 90cd08c8381cf01921b915a56c7347bed1bf7a11 with test fix. (#238934)
Reland 90cd08c8381cf01921b915a56c7347bed1bf7a11 - Implement sigpending
Fix the test by verifying that SIGUSR1 is indeed blocked and is in
pending state.
But restoring the original mask caused this signal to be instantly
delivered
to the process, potentially crashing it.
Fix it by installing `SIG_IGN` handler before restore the original mask.
[CIR][OpenMP] Add support for 'distribute parallel for' with 'target teams'
Adds support for handling the full '[target] teams distribute parallel for'.
Introduces setting the omp.composite attibute for the 'distribute parallel for'
composite construct.
Assisted-by: Cursor / Claude Sonnet 5 High
[CIR] Make LoweringPrepare safe to rerun on CUDA/HIP host modules (#237413)
LoweringPrepare registers kernels and device variables with the runtime
from the 'cu.kernel_name' attribute on kernel stubs and the
'cu.var_registration' attribute on device variables, but left both in
place. Running the pass again on its own output, e.g. on an emitted .cir
file, rebuilt the module ctor and asserted with "function already has an
entry block" for HIP. CUDA only escaped because the pass already drops
the device binary attribute, without which CUDA builds no ctor; HIP
builds one regardless.
Drop both attributes once the module ctor is built. Only CIRGen and
LoweringPrepare touch them, and after the pass the registration is in
the IR. Only the host side changes.
[CIR][OpenMP] Add initial support for distribute
This patch adds initial support for the OpenMP 'distribute' directive. Basic
code generation for the standalone and combined cases is introduced. Support
for clauses will be added in the future. The composite 'teams distribute
parallel for' form will be added in a subsequent patch.
Assisted-by: Cursor / Claude Sonnet 5 High
[cmake] Pass arguments to ccache on Windows (#218791)
Since ccache 4.8 it is possible to pass options as arguments. As such
now PCH files can be enabled along with ccache on windows when using
clang as the compiler. The original behavior was left on other systems
to preserve compatibility with older ccache versions.
[clang-format] IBS_RegroupByDirectory to add breaks between top level directories (#233877)
When a project wants to visually separate the projects' includes by
folders, they would need to curate a list of IncludeCategories per
folder. This provides an alternative where they can capture multiple
folders with a single IncludeCategory regex and still insert breaks
between changes in top-level directory.
```
/// Foo.cpp
#include "Foo.h"
#include "A/a.h"
#include "B/b3.h"
#include "B/b2.h"
#include "C/Bar.h"
#include "C/BarBar.h"
#include "AThirdPartyLibrary/TPL.h"
[34 lines not shown]
[CIR][OpenMP] Add support for omp teams
This patch adds support for the OpenMP 'teams' directive, both standalone
and as the combined `target teams` construct. isCombinableLeaf now also
recognizes teams, so an explicitly-nested `target` + `teams` pair gets
the same omp.combined marking as the combined case.
Assisted-by: Cursor / Claude Sonnet 5 High
RuntimeLibcalls: Add signatures for floating point comparison libcalls (#238521)
The three-way and unordered comparisons return libgcc_cmp_return. This
is the word size with a few exceptions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>