[Clang][AllocToken] Support TypeFuncHash and TypeFuncHashPointerSplit modes (#228492)
Extend Clang to support the `-falloc-token-mode=typefunchash` and
`-falloc-token-mode=typefunchashpointersplit` modes, which were added
to LLVM in #227686.
In these modes, CodeGen attaches the qualified name of the enclosing
function as the third operand of !alloc_token metadata. Allocations
outside functions use an empty function name. When type inference fails,
metadata is still emitted with an empty type name, so that a
function-based
token can be assigned. This allows distinguishing allocations that would
otherwise all share the fallback token.
Like the Increment and Random modes, `__builtin_infer_alloc_token()`
is not supported in constant expressions under these modes.
[lldb] Forward step plans through BorrowedStackFrame (#231657)
When a frame provider returns an index relative to its input frames,
LLDB wraps that frame in a BorrowedStackFrame. BorrowedStackFrame
forwards most StackFrame methods to the frame it borrows, except for
GetThreadPlanForStepType, so a scripted frame lost its custom step plans
as soon as another provider was stacked on top of it.
Forward it like the methods, and test stepping with a pass-through
provider stacked on top of a provider whose frames have step plans.
Signed-off-by: Med Ismail Bennani <ismail at bennani.ma>
[flang][clang][OpenMP] Fix context selector matching and scoring
Fix how OMPContext matches and scores context selectors:
- Derive device selector weights from the depth of the construct context
rather than from the candidate's construct selector count.
- Add each selector's score once, not once per property, using
arbitrary-width arithmetic instead of 64-bit sums.
- Match construct selectors as an ordered subsequence of the context and
score the highest-valued embedding. Keep partial matches for match_any.
- Apply the strict-subset rule to all applicable variants before choosing
the best one, rather than only to break ties: a selector that is a
strict subset of another compatible selector scores zero. Treat
kind(any) as an absent kind selector, and compare ISA traits by property
and name and user conditions by identity.
- Score an unknown property as unmatched instead of aborting. With two
applicable candidates, one naming an unknown vendor, Flang aborted with
"Unknown trait set is not to be used!".
[17 lines not shown]
[orc-rt] Describe connection specs in ogre's help. (#231665)
ogre's help described its argument only as "[positional arguments]",
though it takes exactly one connection spec, and never said what forms a
spec can take.
OptionParser gains setPositionalUsage, to name the positional arguments
in the usage line, and setEpilogue, for text printed after the options.
ogre uses them to name its <connection-spec> argument and to list the
forms it accepts. Other tools' help is unchanged.
[clang][modules] Include `-fmodule-map-file=` in context hash (#227776)
The `-fmodule-map-file=` arguments change whether headers are treated as
textual or modular. Not considering these options in the context hash
can lead to mis-compiles. This PR fixes that.
[LV] Have ExtractValue match the shape of the operand. (#229927)
Previously, BuildStructVector would create a vector of a wide struct
type, where each element is widened.
This can cause issues, if a transform turns an extractvalue of a wide
call into a single-scalar (e.g. makeScalarizationDecisions), because we
currently cannot extract lane 0 from a struct of vectors.
Instead of relying on BuildStructVector, we can instead have the
ExtractValue match the shape of its operand (either widen if the operand
is wide, or replicated if the operand is scalar). If a vector value is
needed, we can directly use the existing BuildVector.
This fixes a number of crashes in the newly added tests, including
https://github.com/llvm/llvm-project/issues/229609.
Depends on https://github.com/llvm/llvm-project/pull/229925
PR: https://github.com/llvm/llvm-project/pull/229927
VE: Use i32 registers for 32-bit loads in the SjLj dispatch block
Fix verifier errors in exception test. The call site index and the
PIC jump table offset were loaded with ldl.zx, which defines an i32
register, into vregs with the i64 register class.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
VE: Default to SjLj exception handling
The clang driver selects SjLj exceptions for VE (96d4ccf00c8f), but the
triple defaulted to no exception model. Make SjLj the default for the
triple and MCAsmInfo so llc agrees with the driver.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc] Order GPU targets after the generated stdint.h (#231229)
Several GPU targets reach `<stdint.h>` without depending on the
generated header, so a fresh build can compile them before or while
`stdint.h` is written and fail with `unknown type name 'uint32_t'`. This
is the same race as #149993, but via headers that don't include
`<stdint.h>` directly.
- GPU utils: `utils.h` includes `<gpuintrin.h>`, which includes
`<stdint.h>`; depend on `libc.hdr.stdint_proxy`.
- rpc_client: `shared/rpc_util.h` includes `<stdint.h>` but is also used
outside libc, so it can't use the proxy header; declare the dependency
on the libc target instead.
- GPU time_utils: declare its existing dependency on GPU utils.
This also changes GPU fixedbuffer to include `hdr/stdint_proxy.h` rather
than `<stdint.h>`. fixedbuffer was added after #150303, so it was missed
by that conversion.
[4 lines not shown]
AMDGPU: Add vgpr32_lo16/vgpr32_hi16 OutPatFrags
Add OutPatFrags for extracting a 16-bit half of a value after copying
it to a VGPR_32, and use them for the existing open-coded instances.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[AMDGPU][Doc] Add documentation about ABI occupancy
This PR introduces ABI occupancy in documentation. The actual code
implementation will be in follow-up PRs.
ARM: Generate processor family and architecture lists in backend
ARMTargetParserDef.inc is only included by ARMSubtarget. It was
generated by the TargetParser library's tablegen step, which every
other LLVM library depends on, even when the ARM target is not
built. Generate it with the rest of the ARM backend's tablegen outputs
instead.
This removes 14% of the time in the TargetParser tablegen step, along
with a dependency on 71 ARM td files.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
VE: Use i32 registers for 32-bit loads in the SjLj dispatch block
Fix verifier errors in exception test. The call site index and the
PIC jump table offset were loaded with ldl.zx, which defines an i32
register, into vregs with the i64 register class.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[flang][OpenMP] Destroy composite num_threads temporaries once
DISTRIBUTE PARALLEL DO and DISTRIBUTE PARALLEL DO SIMD evaluate the
PARALLEL clause operands before creating omp.parallel, using the
statement context of the dispatch. That context is finalized after the
returned omp.distribute, which is inside the parallel region, so every
thread destroyed the same num_threads temporary, for example for
num_threads(size(f())) where f returns an allocatable.
Evaluate these operands in a separate statement context and finalize it
after omp.parallel.
Fixes #230661
Assisted with Copilot and Claude Opus 5.5
AMDGPU: Use lo16_to_vgpr32/hi16_to_vgpr32 OutPatFrags
Replace open-coded REG_SEQUENCE widenings of 16-bit values into a
VGPR_32 with the existing OutPatFrags.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Move records through memory in x86_64 call lowering
CIR lowers a union to its storage type, so moving one as an SSA value
can drop bytes. An x86_fp80 member stores only 10 of its 16 bytes, for
example. The calling-convention rewriter now passes records through
memory at every coercion site, the way classic CodeGen does. That lets
us drop the union check #230302 added, which broke std::format.
Assisted-by: Cursor / Claude Opus 5.5
VE: Default to SjLj exception handling
The clang driver selects SjLj exceptions for VE (96d4ccf00c8f), but the
triple defaulted to no exception model. Make SjLj the default for the
triple and MCAsmInfo so llc agrees with the driver.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc] Implement fgetpos/fsetpos (#221349)
These functions read/write the file state, specifically the offset and
the multibyte state. This PR adds them as well as fpos_t, the struct
they manipulate, and thorough tests.
Assisted-by: Automated tooling, human reviewed.
[AMDGPU][SplitModule] Add entry points for unreachable call cycles
A function in a call cycle always has an incoming direct call, so
`SplitGraph` never makes it an entry point. If no kernel and no other
entry point reaches the cycle, the cycle is assigned to no partition.
This can hit an assertion in `verifyGraph`.
In this PR, we visit the unreached nodes in reverse post-order of the
direct call edges, and make each node that is still unreached an entry
point. Only the outermost unreached cycles get one, so their callees
are not copied into other partitions.
[NFC][AMDGPU] Add a test showing unreachable call cycles in module splitting (#230983)
If no entry point reaches a call cycle, `AMDGPUSplitModule` creates no
entry point for it. In assertion builds, `verifyGraph()` fails. In
release builds, no partition defines the functions in the cycle.
Add a test that shows the current crash.
[CIR] Add noalias on malloc-like function returns (#221817)
- Stamp `llvm.noalias` on function returns when the callee has
`RestrictAttr` (`__attribute__((malloc))` / `__declspec(restrict)`) and
no deallocator.
- Matches classic codegen in `CGCall.cpp`: return `noalias` on both
`define` and `call`, and skip `malloc(dealloc)`.
- Extends `restrict-noalias.c` with a malloc call, a malloc definition,
and a `malloc(dealloc)` negative.
Cursor assisted with this.