[NFC][AMDGPU] Add tests for an fmul split from its fadd/fsub user (#213303)
Record the current behaviour over the types and subtargets where the
fusion rules differ, f32, f16, bf16, f64, v2f32 and v2f16, with
denormals both enabled and flushed, with and without the contract flags,
and under -fp-contract=fast.
Contributes to https://github.com/llvm/llvm-project/issues/211092
[ConstraintElim] Decompose xor %a, -1 as -1 - %a in the signed system. (#213476)
InstCombine canonicalizes sub nsw i8 -1, %a -> xor i8 %a, -1. Decompose
the XOR as `sub nsw -1, %a` in the signed system
Alive2 Proof: https://alive2.llvm.org/ce/z/f_YVjH
This triggers quite rarely in C/C++ workloads (no end-to-end changes in
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/840), found
one instance in Blender. One simple end-to-end C example is
https://clang.godbolt.org/z/G343shYje
This is part of an effort to improve ConstraintElimination support for
IR generated by the Swift compiler, where such patterns are more common
due to a number of signed runtime checks.
PR: https://github.com/llvm/llvm-project/pull/213476
[ELF] Emit synthetic local in symbol table for non-preemptible IFUNC
Currently we create an internal alias of the original symbol and then
rewrite the latter to point to the IPLT entry, which means we lose
symbol table information for the actual resolver. In practice compilers
also emit a normal function symbol for the resolver due to how IFUNCs
are represented in GNU C so that at least shows up, but we shouldn't be
relying on it. By emitting a synthetic local we can keep having a symbol
for the resolver whilst still redirecting references to the IPLT entry.
[NFC][ELF] Remove Symbol's unused copy constructor
Now that we are no longer copying symbols via the copy constructor we
can remove it. Given we track symbol pointers in various data structures
it can be dangerous to have multiple objects for the same symbol that
would risk being viewed inconsistently, or even moved and the original
lost, though no such cases exist upstream that I'm aware of.
Copying a symbol entirely is also a weird thing to do, and can be
inefficient, so when copies are being made it's best to be explicit
about the members to copy. This also makes it clearer to understand what
members are relevant, rather than implicitly copying all the members,
most of which aren't relevant in practice.
Whilst the copy/move constructors/assignment operators are currently
implicitly deleted due to the atomic flags member, explicitly delete
them all so they remain deleted in case that ever changes.
[NFC][ELF] Create fresh alias in handleNonPreemptibleIfunc
We don't need to copy the full symbol here, we just want an internal
alias to use for the IPLT and IGOTPLT entries and IRELATIVE relocation's
addend.
[NFC][ELF] Only create alias in handleNonPreemptibleIfunc if needed
In the no direct relocations case, the original IFUNC symbol keeps its
value, and so there's no need to create a separate alias; it's only
needed when the original symbol is being redirected to the IPLT as a
normal function symbol.
This change also shifts the isInIplt assignment to be explicit and
mirror the allocateAux/pltIdx uses, rather than relying on makeDefined
copying it, and to be clear that this is in fact deliberately and
consistently being copied like them.
[NFC][ELF] Avoid need to copy Symbol in replaceWithDefined (#210612)
Firstly, by overwriting the symbol, it will have its existing flags, so
there is no need to copy them back; all we need to do is mask out the
other bits on the existing symbol.
Secondly, copying the whole symbol just to preserve the symbol version
that gets cleared by Defined::overwrite is a waste; just copy the single
member to reinstate it.
clang/AMDGPU: Fix confused image builtin availability tests
These tests appear to have been copy paste from other image error
tests, which were checking for invalid argument validation. The point
of these tests were to reject image builtins on unsupported targets,
and not just gfx942. Rename the tests, and fix the invalid argument usage.
Each builtin should be used in a valid way.
Co-authored-by: Claude (Claude-Opus-4.8)
[flang] Remove unused includes in MIFCommon.cpp to fix GCC debug-build link errors (#213508)
An undefined symbol error when building Flang in debug mode. This PR fix
this by remove unused include file. Here is a brief error log:
`/usr/bin/ld:lib/libFIRBuilder.a(MIFCommon.cpp.o): in function
Fortran::evaluate::FunctionRef<Fortran::evaluate::Type<(Fortran::common::TypeCategory)4,
1> >::~FunctionRef()':`.
[lldb][test] Recognize a Wasm trap as a crash (#213551)
is_thread_crashed maps how each platform reports the bad access the test
suite uses to simulate a crash, and had no case for Wasm, where there
are no signals and a bad access raises a trap that a runtime reports as
an exception. Without one it fell through to a description match that
never held, so a crashed thread read as running fine.
[lldb] Fix typo in SBUnixSignals.get_unix_signals_list (#213527)
Found when looking through the generated Python file. `sig` doesn't
exist in that context, it should be `idx`.
[libc] Add __isoc99_fscanf alias. (#213125)
- Add LLVM_LIBC_ADD_FUNCTION_C_ALIAS macro to add another C alias public
symbol to a function.
- Add LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES config
- Add __isoc99_fscanf for generic fscanf target if
LIBC_CONF_SCANF_PROVIDE_ISOC99_ALIASES is set.
- Similarly: scanf, vfscanf, vscanf.
[Clang][OpenMP] Skip Sema actions for invalid assumption clauses (#212822)
Do not call the Sema actions for absent, contains, and nullary assumption
clauses after the parser has diagnosed that the clause is not allowed on the
current directive.
Add assertions documenting that these Sema actions must only receive clauses
allowed on the current directive, and add tests covering all affected clause
kinds.
Fixes #212780.
[Hexagon] Avoid predicating debug instructions (#212917)
The change is made in HexagonExpandCondsets::(predicate) function. The
debug instructions are not predicable as they cannot be separated into
conditional branches. So while predicating instructions in a machine
basic block if we encounter any debug instructions we need to skip these
instructions and continue with other instructions.
The scan that collects the registers defined and used between the
definition of the source register and the conditional transfer bailed
out as soon as it saw a non-virtual register operand, which a DBG_VALUE
can have. The transfer was then left as an unconditional A2_asrh plus an
A2_tfrf instead of being folded into a single predicated A4_pasrhf, so
again the generated code differed depending on whether debug info was
enabled.
Co-authored-by: Chandana Sinderikeri <csinderi at qti.qualcomm.com>
[ORC] Add AutoImportGenerator for COFF dllimport auto-import (#203914)
On Windows/COFF, a dllimport call is emitted as an indirect call through
an `__imp_` IAT slot (`callq *__imp_bar(%rip)`), and even a direct call
to a library function is expected to bind to a thunk supplied by an
import library. Today a JIT client must produce those import libraries
themselves. `AutoImportGenerator` synthesizes them on demand instead.
Bound to a single dynamic library via `AutoImportGenerator::Load(ES,
ObjLinkingLayer, "/path/to/lib.dll")`.
For each referenced export `X`, lazily synthesizes an `__imp_X` pointer
slot holding `X`'s address in the library plus an `X` thunk that jumps
through it, so both `__imp_`-mediated and direct references resolve.
The library's export table is the authority: a name the library does not
export is left unresolved, so the link fails exactly as a static link
against the corresponding import library would (no silent invention of
symbols).
[23 lines not shown]
[clang][Driver] Fix libc++ include path on NetBSD (#212716)
`clang++` defaults to `-stdlib=libc++` on NetBSD. When building with
both `clang` and `libcxx` included, the freshly built `clang++` fails to
find `<__config_site>`:
```
In file included from /usr/include/strings.h:68:
In file included from bin/../include/c++/v1/string.h:57:
bin/../include/c++/v1/__config:13:10: fatal
error: '__config_site' file not found
13 | #include <__config_site>
| ^~~~~~~~~~~~~~~
```
The file is present in `include/<triplet>/c++/v1`, but that isn't
searched by default. NetBSD has its own version of addLibCxxIncludePaths
which misses that directory.
[9 lines not shown]
[ORC] Generalize RTBridge Callers to any runtime function (#213526)
An RTBridge Caller is a controller-side handle for calling a function in
the runtime. Until now the abstraction assumed every such function was a
trampoline -- a runtime function whose job is to invoke *another*
function at an address the controller supplies (run-as-main, run-as-int,
etc.) -- so every Caller carried a dedicated ExecutorAddr parameter for
that target.
Generalize Callers to call runtime functions of any shape. Invoking a
supplied target is now just one kind of call, with the target address an
ordinary leading argument rather than a built-in parameter: e.g.
MainCaller becomes Caller<int64_t(ExecutorAddr, ArrayRef<std::string>)>.
The SPS signatures already led with an SPSExecutorAddr for the target,
so this is a pure interface change -- the SPS wrappers and all call
sites are unaffected. It lets Callers model runtime functions that do
the work themselves, such as the memory-access wrappers, rather than
only those that dispatch to another function.
[offload][OpenMP] Add atomic cross-team reductions (#209298)
Regular cross-team reductions have two phases: the intra-team reduction
and the inter-team reduction. Atomic cross-team reductions replace the
second phase with a atomic instruction which is used by the main thread
of each team to directly fold the result of the intra-team reduction
into the final result. Since this requires a combination of "data type"
and "combine operation" for which an atomic instruction is available,
only some (but very common) reductions can be transformed to atomic
reductions. In cases where multiple reductions are performed on the same
construct, the atomic path is only taken if all reductions can be
transformed. Otherwise, we fall back to the regular cross-team reduction
using a buffer with per-team slots. This is not strictly necessary, but
hybrid reductions would induce more complexity with questionable
benefit.
Selecting an atomic path might not be the best option for every
situation, which is why it is not enabled by default. Instead, it can be
enabled via `-fopenmp-target-atomic-reduction`. Note that enabling the
[17 lines not shown]