[ASan] Correctly handle vectorized pointer sub/cmp for `invalid-pointer-pair` (#213546)
Before this PR, asan will treat vector operands just like pointer and
pass it to `__sanitizer_ptr_sub/__sanitizer_ptr_cmp(i64, i64)`,
which leads to assertion failure because it doesn't matches the needed
parameter type.
This PR extracts vector's elements and creates runtime call for each
pair of them.
Closes #212453 .
[VPlan] Split handleEarlyExits into countable and uncountable passes. NFC (#206017)
This allows us to remove UncountableExitStyle::NoUncountableExit, and
isolate it to just the uncountable exit path. This should make it easier
to choose a style from within VPlan alone later on.
This also allows us to plug UncountableExitStyle into a TTI hook or CLI
flag eventually, as I don't think we want to expose NoUncountableExit.
[gn] Make GlobalISel depend on SelectionDAG (#217335)
This dependency has been present in the CMake build for many years.
Suddenly, a bunch of binaries (e.g. llvm-extract) stopped linking
without it, so add it to the GN build too.
[orc-rt] Make the Session attach preconditions a contract (#217325)
Session::attach silently dropped the attach if the Session was already
attached, or if a detach or shutdown had been requested, leaving the
ControllerAccess constructed but never connected or notified and giving
the caller no indication. There is no coherent alternative behaviour --
a detach may be arbitrarily far along by then -- so document the
precondition and assert it instead.
Also make Session::detach pass nullptr to proceedToDetach from its
Start-state branch, asserting that no ControllerAccess is attached, to
match Session::shutdown on the same path.
A TODO covers what to do about contract violations in release builds.
[Flang] Move integration Lit tests to the right directory, NFC
Flang unit tests that involve multiple stages of the compiler are
intended to be placed in flang/test/Integration. However, many existing
unit tests meeting this condition are currently located in the Lower
subdirectory.
This patch moves all tests in Lower that emit LLVM IR from Fortran or
run the FIR MLIR lowering pipeline via `tco` to Integration, and adds the
corresponding notice at the top of each file.
Assisted-by: Claude Opus 4.8.
[orc-rt] Report the disconnection mode to Session clients (#217236)
ControllerAccess::notifyDisconnected now takes an Error describing how
the controller connection ended: success if the disconnection was
orderly, otherwise an Error describing what went wrong. A
ControllerAccess passes its terminal error here rather than to
reportError; with no on-disconnect handler installed the Session
forwards it to the error reporter.
Session::setOnDisconnect installs that handler. It is called exactly
once as the Session detaches, including on a Session that never attached
a controller (reporting success), so a client can use it both to record
the Session's result and to decide whether to shut down.
[clang][bytecode] Move `Descriptor` metadata to `Block` (#217280)
The metadata in `Descriptor`s was only ever used for "toplevel"
descriptors, i.e. never for fields or array elements. Those are also the
descriptors we allocate into `Block`s though, so move the metadata there
and save some space in `Descriptor`.
[MLIR][OpenMP] DeclareTargetInterface and DeclareTargetAttr cleanup, NFCI
The changes introduced by this patch are intended to avoid triggering
multiple by name lookups to the "omp.declare_target" attribute every
time any data from the `DeclareTargetInterface` is queried, remove the
need for keeping multiple default values for the same data, clean up
the assembly format and generally improve the usage of the interface.
List of changes:
- `DeclareTargetInterface` only provides `setDeclareTarget` and
`getDeclareTarget` methods to handle the "omp.declare_target"
attribute, maintaining a single canonical way of accessing it.
- `DeclareTargetAttr` provides direct access to the capture clause and
device type enums, rather than wrapping them into an `Attribute`.
These are now mandatory as well. Both changes together make accessing
them more straightforward and simplify the attribute representation.
[MLIR][OpenMP] Add verification for DeclareTargetInterface
This patch introduces checks to ensure the "omp.declare_target"
attribute is only attached to `DeclareTargetInterface` operations, it is
always the right type attribute and its properties do not conflict with
the operation they are attached to.
[MLIR][OpenMP] Support calls added between MarkDeclareTarget runs (#214185)
Currently, if there are multiple executions of the `MarkDeclareTarget`
pass in a compiler pipeline and somewhere between both runs function
calls get added to a non-declare_target function that was marked as such
implicitly, potential changes to the `device_type` won't get propagated.
This is because we can't distinguish between a user-specified
`declare_target` function attribute and one added by that pass. This
patch addresses this by adding a new parameter to `DeclareTargetAttr`
that is used by that pass to know whether new `declare_target`
information could be propagated to it.
The `automap` and `implicit` parameters are given default values to
simplify the representation of these attributes.
[Flang][OpenMP] Improve implicit declare_target propagation (#214184)
After starting to run the `MarkDeclareTarget` pass later in the
pipeline, some limitations of its original implementation started to be
hit; specifically, some calls being missed could result in an overly
restrictive marking that would cause the `HostOpFiltering` pass to
remove reachable device code.
This patch aims to address these problems by making the following
changes:
- It makes sure to mark functions in every `RecipeInterface` op pointed
to by OpenMP operations.
- It recursively propagates and combines declare_target information from
target regions and explicitly set declare_target functions to unmarked
functions, but it never modifies explicitly marked functions.
- External and public functions can now only be marked with
`device_type(any)`. Before, marking them as `nohost` or `host` was
possible, but without the ability to see all users we can't give such
guarantees.
[6 lines not shown]
[Flang][OpenMP] Remove the DeleteUnreachableTargets pass (#214183)
The `DeleteUnreachableTargets` pass was initially added to work around a
problem caused by the interaction between the function filtering and
host op filtering passes and generic MLIR optimizations.
Specifically, by running function and host op filtering before these
optimizations, we would lose the ability to detect unreachable
`omp.target` operations when compiling for the device. This would cause
GPU kernels being created for them, for which no host counterpart
existed.
By now having moved both passes towards the end of the compilation
pipeline, after FIR to LLVM lowering, removal of unreachable host and
device code is no longer impacted by them. This makes the
`DeleteUnreachableTargets` pass redundant.
[Flang][MLIR][OpenMP] Move function filtering to the omp dialect (#214182)
The `FunctionFilteringPass`, which removes host-only functions when
compiling for an OpenMP target device, is currently defined only for
Flang. However, it implements logic that would generally be useful for
other frontends that can generate OpenMP offloading code. This patch
makes that transition by implementing the following changes:
- It rewrites the `FunctionFilteringPass` to work on lower level non-FIR
MLIR modules.
- It splits off preexisting logic to check for not-yet-implemented
target device features during function filtering to its own pass and it
improves context detection to properly diagnostic only device code.
- It delays function filtering to run at the end of the pipeline, as
well as the `MarkDeclareTargetPass`. This will enable the latter to run
only once in the pipeline after the `UnimplementedDeviceCheckPass`
becomes no longer necessary.
One side effect of these changes is that delaying the filtering will
cause all following passes to process host functions that are eventually
[3 lines not shown]
[LV] Optimise code created by createElementCount (#216981)
At the moment when creating an element count we generate vplan like this
mul(vscale, EC)
however since we know that the VF should always be a power of 2 we can
just do
shl(vscale, log2(EC))
instead. This leads to IR simplifications in quite a few tests, where
redundant shifts get folded away.
There are some instances in tests like
AArch64/partial-reduce-dot-product.ll
where a nsw flag is being dropped, however I don't see this as a bad
thing since again I'm not sure how we could previously justify the nsw
flag anyway.