[clang][SYCL] Align device binary (un)registration with CUDA/HIP/OpenMP (#217173)
The SYCL offload wrapper still registers and unregisters the device
binary the way the offloading runtimes did before 421085fd740d (#86830):
a constructor and a destructor, both at priority 1. That commit moved
OpenMP/CUDA/HIP off a destructor and priority 1, and the reasons apply
to SYCL equally.
With no destructor left to emit, wrapSYCLBinaries() only ever hands back
one function, so shrink its out-parameter to a single Function *. This
also lets CodeGenModule::Release() emit the SYCL constructor next to the
CUDA one instead of ahead of registerGlobalDtorsWithAtExit(), where it
had to sit only because AddGlobalDtor() additions are dropped after that
call.
co-authored by claude
[MLIR][EmitC] Rewrite globals before moving function body (#217474)
WalkPatternRewriter only permits erasing matched operations or their
descendants. Replace get_global operations while they still belong to
the matched function before transferring its body into the new class
method.
Assisted-by: Codex
[CIR] Mark bit-field access units as their own member kinds (#216864)
A bit-field access unit is only as wide as the compiler needs it to be,
which can be narrower than the type the bit-fields were declared with.
Nothing in the record type says so. The unit just gets `data`, or
`empty` when none of its bit-fields are named, and an ordinary field
gets those same marks.
That makes `struct { long long x : 32; }` and `struct { unsigned x; }`
look identical here. Classic CodeGen tells them apart and coerces the
first to `i64`, the second to `i32`. It reads the declared type, where
the bit-field still leaves user data past bit 32.
The fix is to give a unit its own marks, `bitfield` and
`empty_bitfield`. Nothing reads them yet, and no record's emptiness
answer changes. The next PR records a zero-width bit-field, which the
marks miss too, and pad-aware classification can then use both.
Assisted-by: Cursor / claude-opus-5
[CIR] Move LoweringPrepare before callconv lowering (#216498)
Complex division returns a wrong imaginary part. CIR declares `__divsc3`
as returning `{ float, float }` where classic CodeGen coerces the return
to `<2 x float>`, so the caller reads the two halves out of two
registers while the callee packs both into one. Dividing 3+4i by 1+2i
gives 2.2 and 4.0 instead of 2.2 and -0.4, with no diagnostic. The
helper call is synthesized by LoweringPrepare, which runs after the
calling-convention pass, so it is never classified.
Moving LoweringPrepare before CallConvLowering lets the classifier see
everything the pass emits rather than complex alone. Complex mul and div
are the only calls it synthesizes today that need coercion, but anything
emitted there later is lowered properly too.
Assisted-by: Cursor / claude-opus-5
Analysis: Move LibcallLoweringInfo from CodeGen to Analysis
Middle end passes need to be able to reason about library call
availability and potentially emit them without depending on codegen.
TargetLibraryInfo already lives in Analysis, and this is a step towards
the eventual merger. For now this is a mostly mechanical move, type erasing
the reference to TargetSubtargetInfo.
The per-subtarget customization (TargetSubtargetInfo::initLibcallLoweringInfo)
is inverted into a caller-supplied function_ref, so the Analysis types carry
no CodeGen/TargetSubtargetInfo reference. The module map is keyed on an opaque
erased pointer. CodeGen continues looking up based on the subtarget.
It is not yet in a state where it is usable from middle end passes; that will come
later. In principle we should be able to write arbitrary rules based on a function's
ABI attributes for which calls can be used.
Co-authored-by: Claude (Claude Opus 4.8) <noreply at anthropic.com>
[NFC][TTI] Remove default value for CostKind from TTI::getPointersChainCost() (#217456)
No users relied on this default value.
Also, const-ify the `CostKind` parameter as a hygiene improvement.
See #135598.
Merge tag 'trace-ringbuffer-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull ring-buffer updates from Steven Rostedt:
- Remove unneeded semicolon
A macro ended with a semicolon that wasn't needed.
- Fix freeing cpu_buffer extra subbuffer with order greater than zero
When the cpu_buffer was being freed, its "free" page, was using
free_page() to free it when it could be more than one page.
- Hold the cpu_buffer lock when resizing the subbuffer
The freeing of the "free" page of the cpu_buffer was done without
locking. The order of the data was being saved and then the "free"
page was set to NULL. But there is a race that the "free" page could
have been updated between those two operations. Add locking around it
[46 lines not shown]
Merge tag 'tracefs-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracefs updates from Steven Rostedt:
- Define event fields before directory creation
Move the event_define_fields() call in event_create_dir() before the
eventfs directory creation. Previously, a failure after directory
creation wouldn't clean up eventfs_inode because the error path
didn't call eventfs_remove_dir(). This eliminates the need to clean
up the eventfs directories if event_define_fields() fails.
- Add warning for out of bounds pos in __eventfs_iterate()
Sashiko complains about the ctx->pos causing issues if it is less
than 2 or greater than MAX_INT in __eventfs_iterate(). The thing is,
the logic prevents that from happening. But to make Sashiko happy,
add a WARN_ON() and exit safely if the function ever does get input
that is out of the range the function expects.
[4 lines not shown]
Merge tag 'trace-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt:
- Expose btf_ids to trace events
In order to allow BPF programs to attach to system call trace events
(which are actually pseudo trace events built on top of raw_syscall
events), expose the BTF ID of the events. This will allow BPF
programs better precision in attaching to events.
- Use "u64" to assign to hist_field->type
Instead of using kstrdup("u64", GFP_KERNEL) to assign the
hist_field->type, just point it to "u64" instead. The
hist_field->type is freed via kfree_const().
- Replace kmalloc()/strcpy() with kstrdup() for trace_printk
[85 lines not shown]
[flang][cuda] Avoid crash when source is a block argument (#217459)
When the value is a block argument, getDefiningOp() returns null. Avoid
crash when this is the case by checking for the defining op first.
Merge tag 'ftrace-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull ftrace updates from Steven Rostedt:
- Deprecrate ftrace_enabled in disabling ftrace
The file /proc/sys/kernel/ftrace_enabled was created when ftrace was
first introduced back in 2008. It was to be a "kill switch" if
something was to go wrong. It was also used as a way to turn off
function tracing for the latency tracers that would have it on by
default. But in 2013 (Linux 3.10) the option "function-trace" was
introduced to disable function tracing for the latency tracers as the
"ftrace_enabled" file was considered too big of a hammer and caused
too many side effects.
When live kernel patching came along, disabling ftrace via the
ftrace_enabled file would put the system into an unstable state if a
live kernel patch was installed. This created the need to mark some
function hooks as "PERMANENT".
[25 lines not shown]
Merge tag 'trace-tools-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull RTLA updates from Steven Rostedt:
- Extend support for unsetting CLI options
libsubcmd auto-generates "--no-<option>" to unset options, provided
the option callback supports it. Implement this for RTLA CLI beyond
boolean options, and document the few exceptions that are left out.
- Test all tracer options in runtime tests
Verify that RTLA sets osnoise/timerlat options correctly by reading
them from tracefs during runtime tests.
- Improve range validation for option arguments
Make CLI range validation consistent with the kernel limits and unify
implementation and error messages between options.
[14 lines not shown]
[CIR] Insert on-demand functions at module scope (#207260)
This showed up building GROMACS with ClangIR at -O3, where compilation
hits an MLIR assertion about an operation already being in a block.
The problem is in vtable thunk emission. When we generate a thunk the
builder's insertion point is inside the thunk's entry block, and from
there we call getAddrOfFunction for the thunk's callee. If that callee
hasn't been created yet, as happens for a virtual-base override first
referenced by a construction-vtable thunk, createCIRFunction builds the
new function right there, parented under the thunk. The final push_back
then tries to move a function that is already in a block.
When there is no CIRGenFunction active, createCIRFunction should just
set the insertion point to module scope before creating the function
instead of creating it at the ambient point and pushing it back
afterward. This is what createGlobalOp already does for globals
materialized this way.
[5 lines not shown]
[RISCV] Turn certain cases of masked.load into vp.load + vp.merge (#217184)
Though RISC-V's loop vectorizer would never generate this, but I found
that other frontends like MLIR might generate "SVE-style" fixed vector
masked.load that looks like this:
```
%b = splat %base
%s = <0, 1, 2, 3, ...>
%a = add nuw %b, %s
%N = splat %n
%m = icmp ult %a, %N
%v = mask.load %p, %m, %passthru
```
By default RISC-V lowers this sequence verbatim and thus emitting masks.
To avoid masks, I think we could use vp.load + vp.merge instead with VL
equals to
```
min(%n - min(%n, %base + %offset), numElements)
```
where %offset is the start value of step vector %s and numElements is
the fixed vector size.
[X86] lowerFPToIntToFP - handle signedness for fp->int and int->fp independently (#217404)
We were assuming that both conversions were for the same integer
signedness
Fixes #217355
import gr-osmosdr
Unified gnuradio input/output block for a variety of SDR devices,
including RTL-SDR and HackRF.
needed as dependency for new comms/gqrx
feedback and OK bentley@
Use a fallback interval strategy for the task_for_pid request. (#217425)
We've seen cases on heavily loaded bots where task_for_pid requests get
denied because the authentication system is overloaded. Use an
increasing timeout to avoid piling on when this is happening.
The fallback I chose does:
0: 0.01
1: 0.02
2: 0.04
3: 0.07
4: 0.11
5: 0.16
6: 0.22
7: 0.29
8: 0.37
9: 0.46
which seems reasonable to me. At worst this will wait about a second,
which is still below our test launch timeouts.
X86/GlobalISel: Use mi_match for implicit-def and constant checks (#217444)
Also fix some broken tests using IMPLICIT_DEF without a set register
class. Ideally the verifier would check these. Real compiles should
have used G_IMPLICIT_DEF
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
Merge tag 'trace-rv-v7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull Real-time Verifier updates from Steven Rostedt:
- Switch LTL and DOT parsers to Lark in code generation tool
The rvgen code generation tool originally parsed DOT files and LTL
specifications using custom string parsing and Ply, which is no
longer maintained. The DOT parser was fragile and prone to failure on
minor format variations. Both LTL and DOT parsers have been rewritten
to use the Lark parsing library.
- Simplify Hybrid Automata clock variables
The clock variables in hybrid automata monitors now use a single
representation of the elapsed time since the clock was reset, rather
than converting between invariant and guard representations. This
allows simpler code generation for the newly refactored parser.
[111 lines not shown]
[VPlan] Move requiresScalarEpilogue to VPlan (NFC). (#217447)
Move requiresScalarEpilogue fully to VPlan after no issues uncovered in
the transition period mentioned in
https://github.com/llvm/llvm-project/pull/207784.
Analysis: Move LibcallLoweringInfo from CodeGen to Analysis
Middle end passes need to be able to reason about library call
availability and potentially emit them without depending on codegen.
TargetLibraryInfo already lives in Analysis, and this is a step towards
the eventual merger. For now this is a mostly mechanical move, type erasing
the reference to TargetSubtargetInfo.
The per-subtarget customization (TargetSubtargetInfo::initLibcallLoweringInfo)
is inverted into a caller-supplied function_ref, so the Analysis types carry
no CodeGen/TargetSubtargetInfo reference. The module map is keyed on an opaque
erased pointer. CodeGen continues looking up based on the subtarget.
It is not yet in a state where it is usable from middle end passes; that will come
later. In principle we should be able to write arbitrary rules based on a function's
ABI attributes for which calls can be used.
Co-authored-by: Claude (Claude Opus 4.8) <noreply at anthropic.com>
[mlir][inliner] Avoid re-expanding recursive calls across SCC iterations (#211377)
The MLIR inliner tracks inline history only within one invocation of
`inlineCallsInSCC`. This correctly detects recursion while processing
the current call worklist.
However, `inlineSCC` repeatedly runs optimization and inlining. On every
iteration, the inline history was recreated. A recursive call left from
the previous iteration was therefore treated as a new root call and
expanded again.
For example:
```mlir
func.func @caller(%arg: i32) -> i32 {
%0 = call @a(%arg) : (i32) -> i32
return %0 : i32
}
[144 lines not shown]
GlobalISel: Add m_GAssertZext matcher and use it in AArch64 combiner (#217443)
Generalize the G_SEXT_INREG source+immediate matcher into a shared
template and add m_GAssertZext on top of it. Use it to replace the
getVRegDef + G_ASSERT_ZEXT opcode and immediate checks. NFC.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>