[TargetParser][NFC] Move BasicSubtarget* into lib/ (#247094)
After #198433, there's nothing left in TargetParser.h that is needed for
outside users, it only exports BasicSubtarget* structs and a function
that is only used inside lib/TargetParser. Move the header into lib/.
Also rename it to BasicSubtarget to more accurately describe the
remaining content.
[Polly] Enable IRBuilder GEP canonicalization (#249378)
ParallelLoopGenerator::extractValuesFromStruct() took the type of the
loaded value from the result element type of the struct GEP, which is
now i8. Take it from the struct type instead.
Assisted-by: LLM
[X86] Truncate uitofp vXi64 to vXi32 if the upper 32 bits are known zero (#236194)
Without AVX512DQ, uitofp from vXi64 gets scalarized even when the upper
32 bits are known zero. combineUIntToFP sees the sign bit is zero and
turns it into sint_to_fp vXi64, but combineSIntToFP only narrows to
vXi32 when there are at least 33 sign bits, so we end up keeping the i64
conversion. I truncate the source to vXi32 first and convert from that
instead. With AVX512DQ the vXi64 conversion is already legal, so there I
only do it when the truncate is free, using the isTruncateFree change
from #249269.
Fixes #230152
---------
Co-authored-by: Simon Pilgrim <llvm-dev at redking.me.uk>
[LLD][NFC] Correct plugin test requirements (#249196)
Plugin tests require the plugin targets to be defined
(LLVM_INCLUDE_EXAMPLES), not that they are also built by default
(LLVM_BUILD_EXAMPLES). Adjust the conditions to match LLVM examples.
This will also cause these tests to run in several more CI
configurations, as LLVM_BUILD_EXAMPLES is usually off.
[Offload][OpenMP] Build TIMESCOPE profile details lazily (#246497)
The TIMESCOPE_*_IDENT macros constructed a SourceInfo from the ident_t
and concatenated the detail strings on every call, even when the time
trace profiler is disabled. Parsing the source location costs several
allocations plus string searches and integer conversions, which
dominates short runtime entry points. For example, a 'target data'
region with only 'use_device_addr' spent about half of its time there.
Pass the detail as a callback to llvm::TimeTraceScope, which only
invokes it when the profiler is enabled. The detail string is still
computed at scope entry, so the produced trace is unchanged.
On gfx90a, this reduces the cost of a 'use_device_addr' lookup in the
LCOMPILER-3239 reproducer from 1.47 us to 0.98 us per call.
Fixes: LCOMPILER-3239
Co-Authored-By: Claude <noreply at anthropic.com>
[2 lines not shown]
[FunctionAttrs] Don't build an access range for zero-size types (#249156)
`getArgumentAccessInfo` builds the range [Offset, Offset + Size) for a
load or store. For a zero-size type such as `{}`, both bounds are equal
and the ConstantRange constructor asserts. At offset 0 the range is
empty and a ConstantRangeList assertion fires instead.
This returns no range for zero-size types, like `GetConstantIntRange`
already does for zero-length memory intrinsics. A zero-size load is then
treated as an unknown access, the same as a zero-length memcpy source.
We could treat it as no access instead, but the complexity does not seem
worth it.
Fixes #225289.
Assisted-by: Claude Code (Opus 5.5)
[llvm-readobj][AMDGPU] Fix crash printing AMDGPU symbol types (#249193)
llvm-readelf --symbols and --hash-symbols ask the AMDGPU symbol type
table for its GNU name, but the table only has one name per entry. A
symbol of type STT_AMDGPU_HSA_KERNEL hits an assertion, or reads past
the table in a build without assertions.
Use the table's only name instead. Also print an unnamed OS-specific
type as a number in --hash-symbols, as --symbols does, instead of an
empty string.
Assisted-by: Claude Opus 5.5
[X86] Check every path into an EFLAGS copy's uses with a dataflow
The checks for INLINEASM_BR in X86FlagsCopyLowering were special cases for
the shapes found so far, and each one missed others. The pass didn't catch
an asm's indirect path back to the top of the copy's block, or one from a
block between the test and the copy. It rejected an asm whose indirect
target is its own block, and an asm that leaves EFLAGS alone, though both
are fine. Scanning the copy's block a second time, back to the copy, passed
the copied EFLAGS on to every successor, including the target of a later
asm that redefines them, whose flag reads were then rewritten. And an
indirect target that reads the asm's EFLAGS could be left without them live
at the end of the asm's block, which MIR needs in place of a live-out from
the middle of the block, so the result failed the verifier.
In a function with an INLINEASM_BR, find the blocks that a path may enter
without the copied EFLAGS and the test's condition registers, with a
forward dataflow that counts an asm's edge from the middle of its block, and
reject a use in one of them. From the end of the copy's block, pass the
copied EFLAGS on only to the successors that the end goes to, or to all of
[7 lines not shown]
[mlir][LLVM] Mark min/max, saturating, mulh and overflow intrinsics as Commutative (#249341)
LLVM's IntrinsicInst::isCommutative() treats these intrinsics as
commutative in their first two operands, but the LLVM dialect only marks
the arithmetic ops as Commutative.
Add the Commutative trait to the two-operand intrinsics that LLVM treats
as commutative: smax, smin, umax, umin, maxnum, minnum, maximum,
minimum, maximumnum, minimumnum, sadd.sat, uadd.sat, smulh, umulh, and
the sadd, uadd, smul and umul .with.overflow intrinsics.
Fixes: https://github.com/llvm/llvm-project/issues/249219
[flang] Stop treating NUM_IMAGES(), IRAND() and similar as constants (#247937)
`IsConstantExprHelper` takes any intrinsic call with no arguments, or no
first argument, as a constant expression, and any other pure intrinsic
call whose arguments are constant. So flang accepts these
kind-selectors:
```fortran
real(kind=command_argument_count()) :: x1
integer(num_images(1)) :: x2
integer(getpid()) :: x3
```
ifx 2023.0 rejects all three, and gfortran 15.3 rejects the GETPID one.
Item (8) of [Fortran 2023 section
10.1.12](https://j3-fortran.org/doc/year/23/23-007r1.pdf#page=186)
leaves COMMAND_ARGUMENT_COUNT, GET_TEAM, NUM_IMAGES, TEAM_NUMBER and
THIS_IMAGE out of constant expressions. GETPID, IRAND, TIME and the
[25 lines not shown]