[Verifier] Strip incorrect strictfp FIXME, test (NFC) (#215487)
Follow up on 0193519 (Partial-revert "[IR] Make semantics of strictfp
consistent v2", #213723) to clean up the incorrect FIXME and test it
left behind. There are still open questions around the semantics of
strictfp, but it is clear that the semantics proposed by the original
patch is incorrect.
[RISCV][NFC] Add tests for zext(phi/select) (#215363)
Since RISC-V has zero-extending loads (lbu/lhu), we can pattern match
zext-of-load into a single instruction. Often load and the zext/sext are
separated by select and / or phi instructions. In the future we want to
"push back" the zext instructions so they are next to the loads. This PR
precommits tests for this optimization.
Assisted by AI.
[CodeGen] Correctly classify/mark dead defs when adjusting lane liveness
Despite what the documentation of `adjustLaneLiveness` suggests, the
method never sets dead flags on dead def operands, even when missing
dead flags can later lead to machine verifier errors.
This makes the method identify dead definitions from definitions that
are initially thought to be alive, and makes it add a dead flag on the
last definition of a virtual register, matching the behavior expected
by the machine verifier (ref. "Instruction ending live segment on dead
slot has no dead flag").
`adjustLaneLiveness` and `detectDeadDefs` now also use the same
mechanism to identify dead definitions. It relies on comparing the
defined lanes of a definition with those that stay alive after it.
[lldb][Windows] Fix races in the DebuggerThread exception handshake (#213075)
`DebuggerThread::m_active_exception` and `m_exception_pred` are accessed
both from the Windows debug-event loop and from the thread driving the
debugger. There is no sync mechanism between the two. That caused 2
failures.
1. Use after free: The `m_active_exception.reset()` in
`ContinueAsyncException()` can destroy the exception while the delegate
uses it.
2. `ContinueAsyncException()` can be called between the end of the
delegate and `SetValue(result)`. Causing
`WaitForValueNotEqualTo(BreakInDebugger) to spin forever`.
This patch guards `m_active_exception` with a mutex and returns a
`ExceptionRecordSP` from `GetActiveException()` so callers no longer
have to lock a weak_ptr.
To verify this, I ran the test suite and injected a 50ms delay into the
[3 lines not shown]
[CIR] Leave a bad record member mark to the type parser
parseMemberKind named `data` only so it could reject it, and separately
rejected a second mark on one member. Both bought a tailored message
where the type parser already fails, and neither spelling can be reached
from printed CIR, since a data member is unmarked and only one mark is
ever emitted.
Drop both. The function then has no failure path left, so it returns
void.
Assisted-by: Cursor / claude-opus-5
[lldb] Use `GetValueAsUnsigned` for pointers in an `lldb.value` (#215580)
When we had a pointer in an `lldb.value`, we used to use
`GetValueAsSigned`. If the sign bit is set, we'd get negative values
like in the failed lldb-arm-ubuntu test
(https://github.com/llvm/llvm-project/pull/214295#issuecomment-5254541467).
With this PR, we use `GetValueAsUnsigned` for pointers to get the
unsigned value. I'm not sure if we should use `AsUnsigned` or
`AsAddress` here. The difference is that `AsAddress` will clear the top
bits. In the test, I'm using `assertEqual(arr_start + 2,
arr[1].sbvalue.GetLoadAddress())`, but as far as I know,
`GetLoadAddress` will not clear any bits(?)
[libc] Annotate RPC members as global pointers (#215412)
Summary:
These are currently all routed through the generic interface. Doing this
should safe a handful of instructions and make the intent clearer.
Basically, makes it nicer on the optimizer and reduces the number of
wait counts while effectively being NFC because this address space is
where these always lived.
Main rationale, lets you link C++ into OpenCL without requiring flat
addressing.
Also trims off some SGPRs I think.
[clang][OpenMP] Split OMPOrderedDirective into two classes (#214730)
Now that OMPD_ordered has been replaced with two variants, split
the OMPOrderedDirective class into two classes, one for each
variant.
[clang][OpenMP] Use different ids for block and s/a ORDERED directive (#214728)
Use OMPD_ordered_blockassoc for the block-associated ORDERED directive,
and OMPD_ordered_standalone for the standalone variant.
This still uses a single AST class for both though. The directive
kind stored in can now take either of the two values.
---------
Co-authored-by: Alexey Bataev <a.bataev at outlook.com>
[flang][OpenMP] Use different ids for block and s/a ORDERED directive (#214727)
Use OMPD_ordered_blockassoc for the block-associated ORDERED directive,
and OMPD_ordered_standalone for the standalone variant.
[OpenMP] Create separate directives for two variants of ORDERED (#214726)
The ORDERED directive comes in two flavors, standalone and block-
associated. Create two different directive ids, one for each kind.
This will allow a more precise connection between the directive id
and its properties.
This does not remove OMPD_ordered, nor does it change clang or
flang beyond the minimum required to keep working as before.
[DAGCombiner] Don't create illegal types in visitSRL (#215374)
Besides what's fixed in #205074, the srl(bitcast(build_vector)) fold
added in #181412 has another way to create an illegal type: the bitcast
to LastElt.getValueType().changeTypeToInteger() is itself illegal when,
for example, LastElt is f16 and i16 is not a legal type.
Unfortunately, this happens in a downstream target so no testcase.
[lldb][NFC] Use Python3's importlib.reload directly (#215271)
Instead of importing it as reload_module. That name comes from
https://reviews.llvm.org/D15209/7d2d09842a428bc0b45414ff0f32391a447e048d.
reload_module is what the 2/3 compatibility library "six" called it.
In Python 2 "reload" was a builtin and 3 moved it into importlib. We
require 3.8 so we don't need to consider 2 anymore.
Hexagon: Stop excluding some generic compiler-rt functions from libcalls (#210963)
RuntimeLibcalls should indicate any function that exists and is
callable. Historically the list of library functions was conflated with the
library functions which should be used, so the library definition was
complicated by excluding the overridden cases. My reading of the
compiler-rt sources is that the generically named functions are built
alongside the __hexagon prefixed variants. e.g., __divsi3 and
__hexagon_divsi3 both exist.
It will simplify future libcall work the fewer special case target
exclusions there are, so allow the functions to be defined and apply
the selection preference for the __hexagon prefixed versions in
LibcallLoweringInfo.
I do question why compiler-rt is built this way; why doesn't the
hexagon just replace the standard entrypoint names with the target
implementations?
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[CIR] Accept _Complex and all float formats in x86_64 callconv lowering (#215117)
The CallConvLowering bridge accepted only `float` and `double`, so a
function taking a `_Complex`, or a float in any other format, failed the
pass instead of being classified. An all-float aggregate failed for a
different reason: its SSE eightbyte coerces to a vector, and the bridge
had no way to represent one, so it reported the coercion NYI rather than
emitting a wrong signature.
Mapping every CIR floating-point type through `FPTypeInterface` covers
all of them at once. A `_Complex` maps to the library's complex type and
a vector coercion now converts back to a CIR vector.
Accepting a `long double` also makes a union holding one classifiable.
That exposes the ABI-compatibility flags, which the pass left at the
library defaults. They now come from the triple and the compatibility
version, which is what lets a `long double` union reach registers on
Darwin instead of memory.
[9 lines not shown]
[clang] Replace existing `#include` directives with `#import` when inserting an import (#213751)
When inserting a header with an `#import` directive, if an existing
`#include` directive for the same header and quotation style is found,
replace it with the `#import` directive instead of adding a duplicate.
This is based on two assumptions:
1. that `#import` outranks `#include` since headers that are included
are assumed to have appropriate include guards to prevent multiple
inclusions
2. that there is no good reason to have an include and import of the
same header in a given source file.
Note that this is intended for include-cleaner support for Objective-C.
[OpenMP][DeviceRTL] Use the actual block size in the SPMD no-loop distribute path (#214073)
In the SPMD no-loop path the iteration index is `BId * NumThreads +
TId`, so `NumThreads` has to
be the size of the block the threads are actually in. `DistributeFor`
uses the caller-supplied
value as-is. If that value is larger than the block size, the index
strides past the end of each
block and the iterations in between are never run.
Fixes #198621.
Reproduced on gfx90a, `num_teams(4)`, 128 iterations, varying the value
passed as `NumThreads`
against the threads the block actually has:
| NumThreads passed | threads in block | iterations not run |
|---|---|---|
| 256 | 32 | 96 of 128 |
[38 lines not shown]
[mlir][tensor] Add a ValueBoundsOpInterface model for tensor.concat (#215346)
Attach ValueBoundsOpInterface model to tensor.concat. The result has the
same size as the inputs in every dimension except the concatenated one,
whose size is the sum of the input sizes.
The verifier makes all inputs equal in a dimension that is not
concatenated, so relate the result to all of them. Relating it to the
first input alone loses the bound when that input is the unbounded one,
which makes the result depend on operand order.
Code generated with Claude Code.
Signed-off-by: Víctor Pérez Carrasco <victor.pc.upm at gmail.com>
[mlir][tensor] Add a ValueBoundsOpInterface model for tensor.splat (#215344)
Attach ValueBoundsOpInterface model to tensor.splat, mapping each result
dimension to its size operand, through `getMixedValues`.
Code generated with Claude Code.
Signed-off-by: Víctor Pérez Carrasco <victor.pc.upm at gmail.com>
[offload] Fix compatibility for level_zero 25.22.33944 (#214215)
This patch changes a few of more recent level zero APIs to use
`apihelper::canCall`. Also I added a new template `callDefaulted` into
`APIHelpers.h` that can be used to call a function with all arguments
initialized using `{}` which can be used to call APIs to check if they
are implemented. It was used to implement
`INVALIDATE_LEVEL_ZERO_API(zeCommandListAppendLaunchKernelWithArguments);`
macro which checks if an API returns ZE_RESULT_ERROR_UNSUPPORTED_FEATURE
and based on that we can fallback those functions.
I also added a skip in our tests if `olLaunchHostFunction` returns not
supported. It made me think it all offload APIs should behave similarly
to level zero which returns ZE_RESULT_ERROR_UNSUPPORTED_FEATURE even if
arguments are invalid, so users can easily check availability of some
feature. In our level zero plugin for host tasks we return `not
supported` at the very end.
Tested on few version of level zero and cuda 12.4.1.
[3 lines not shown]
[CVP] Refine results of getValueAtUse for single users. (#212133)
As discussed in in https://github.com/llvm/llvm-project/pull/207522.
Update getValueAtUse's loop inspecting uses to intersect the at-use
value with the range.
This gives the minimum range for the value at the final use site.
Skipping the intersection would pessimize results in some cases, e.g.
when looking up the result in the use block returns overdefined, due to
the walk hitting the bound of traversed blocks, or when dealing with
cycles. https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/790
shows the regressions when just adjusting the context instruction for
the initial lookup (vs intersecting the result of getConstantRangeAtUse
https://github.com/llvm/llvm-project/pull/211668,
but should be comparable to this).
Triggers widely in real world programs, improving flag inference,
[14 lines not shown]