CSKY: Use LastSubtargetCache in getSubtargetImpl (#242778)
Migrate to the new common pattern for targets to cache the last
result.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[Offload][AMDGPU][NFC] Introduce per-device runtime options (#239816)
This PR:
- Introduce per-device runtime options;
- Enable flexible setting for default values;
- Move AMDGPU queue and SDMA settings into the new options structure to
show the usage;
- No changes to the existing behaviors and defaults;
- Can be extended to support configurations from profiles.
RFC can be found:
https://discourse.llvm.org/t/rfc-offload-amdgpu-device-specific-runtime-defaults-for-the-openmp-amdgpu-plugin/91613
Assisted by GPT5.6
[LLVMABI] Treat data member pointers as scalars (#244140)
Match Clang, which passes atomic data member pointers directly on x86-64
Required for https://github.com/llvm/llvm-project/pull/223259
CGExprCXX: emit family and allockind attributes (#239732)
This allows us to remove the special knowledge about C++ allocation from
LLVM's MemoryBuiltins.cpp, instead trusting attributes to communicate
the important properties.
Annoyingly, clang has to grow a little bit of hard-coded knowledge about
mangled symbol names in order to actually get the most-basic-matching
::operator::new when working out the alloc-family attribute. I spent
some time trying to do this "right" by looking up the available
operators new and finding the best one, but that's super tricky and this
has the virtue of working and being pretty obviously correct when
compared to the old code.
Happily, clang now emits allocator family attributes for custom
allocators like the `__hot_cold_t` overloads in `new_hot_cold.cpp`
(which `isReplaceableGlobalAllocationFunction` in clang recognizes),
allowing us to remove that special knowledge from LLVM.
[6 lines not shown]
[clang] Don't relocate DWARF on 32-bit ARM and x86 Mach-O (#244069)
On 32-bit ARM and x86, Mach-O uses scattered relocations, which identify
their target by address. Relocatable DWARF puts every __DWARF section at
address 0, so these relocations become ambiguous: a line table's
reference to a file name in __debug_line_str resolves to the first
function in __text instead.
Don't enable relocatable DWARF for these architectures.
Assisted-by: Claude
[dsymutil][test] Use FileCheck --ignore-case in pseudo-probe.test (#243999)
Follow-up to #243925, addressing the post-merge review comment from
@perry-ca.
Use FileCheck's `--ignore-case` option instead of piping `od` output
through `tr A-F a-f`, consistent with other tests (e.g.
`llvm/test/tools/yaml2obj/XCOFF/string-table.yaml`).
[OpenMP] Fix __kmp_invoke_microtask for arm64_32 (#243956)
On arm64_32 pointers are 4 bytes. Use 4 byte loads and stores for the
p_argv entries, the stack arguments and *exit_frame_ptr.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[InstCombine] Check the select type in the usub.sat sign mask fold (#244281)
`foldICmpUSubSatWithAndForMostSignificantBitCmp` replaces a select with
an `and` that has the type of the `usub.sat` operands. We can't do the
replacement when the select has a different type.
This PR was assisted by AI but I reviewed all the changes.
[lldb] Fix SBCommandReturnObject::SetError dropping the error (#244317)
8789c96698e0 inverted the check, so only a successful SBError was
forwarded.
Assisted-by: Claude
[lldb][MS ABI] Use special demangle flags for templates (#238970)
In #236572, I added some flags to mimic the formatting MSVC (and Clang)
use for templates in PDB. Specifically, they don't insert spaces in
parameter lists and closing braces do have a space. DWARF only differs
in that it puts spaces between parameters.
When we detect a template name, we now demangle that manually, since
`Mangled` doesn't use the right flags. This is a bit more overhead, but
the result is cached anyway.
[Clang][Driver][NFC] Simplify fp-contract state tracking (#243282)
Simplify -ffp-contract state tracking by replacing
'LastSeenFfpContractOption' and 'SeenUnsafeMathModeOption' with a single
optional fallback value 'FPContractFallback';
Explicit -ffp-contract options set the fallback 'FPContractFallback' to
their value. Unsafe-math options establish "on" as the fallback only
when none exists. Disabling unsafe math restores that fallback,
preserving existing option-ordering behavior and CUDA/HIP exceptions.
Share the contraction-enabling logic through enableUnsafeFPContract()
and remove a redundant diagnostic-state reset.
Assisted by Copilot GPT-6.1 Sol
[clang][OpenMP] Fix APSInt bit-width mismatch in ordered depend/doacross check (#238672)
In `ProcessOpenMPDoacrossClauseCommon`, both `DepCounter` and
`TotalDepCount` were initialized as `32-bit APSInts`, after which
`TotalDepCount` was overwritten by
`OrderedCountExpr->EvaluateKnownConstInt(...)`. When the `ordered(n)`
clause expression had a bit-width other than 32 bits, `TotalDepCount`
took on that expression's bit-width while `DepCounter` remained 32-bit,
triggering an APInt bit-width assertion in `DepCounter >=
TotalDepCount`.
Initialize `DepCounter` after `TotalDepCount` is evaluated using
`TotalDepCount.getBitWidth()` so both unsigned APSInts always have
matching bit-widths.
Fixes #235971
Assisted-by: Gemini
[CIR][OpenMP] Specify target triple in OpenMP loop codegen tests (#244278)
Add `-triple x86_64-unknown-linux-gnu` to tests added in
61067a5096e (#229256) to avoid defaulting to the host target triple
and failing on non-x86 builders like
https://lab.llvm.org/buildbot/#/builders/231/builds/2223.
[bazel][libc] Enable fullbuild-only tests in CI (#244324)
These were previously excluded from CI, but now have support in
Buildkite and github CI (19b0091751d8c786c92e749a2d3404595edd359b). This
PR also adds `target_compatible_with` for overlay builds.
[OpenMP][flang] Score unknown context selector properties by selector
Flang records an unknown property such as kind(bogus) or vendor(bogus)
as TraitProperty::invalid, which belongs to no selector. Under
match_any or match_none, where such a variant can still be selected,
the property therefore lost its selector's weight: kind(bogus) added
nothing, while an unmatched kind(gpu) adds 2^l, where l is the number of
constructs in the context. A score on a selector that mixes known and
unknown properties was also added twice, once for the known property and
once for invalid, and unknown properties in different selectors shared
a single score.
Add VariantMatchInfo::addUnknownTrait, which keeps the property
unmatched and records its selector and score, and score that selector
like any other. Use it in Flang. Clang drops unknown properties while
parsing and is unaffected.
Fixes: https://github.com/llvm/llvm-project/issues/233029
Assisted-by: GitHub Copilot (Claude Opus 5.5)
[Clang][OpenMP] Use the associated loop's range in loop metadata (#240649)
The start and end locations in the `!llvm.loop` metadata of an OpenMP
loop came from the directive's source range, which covers only the
pragma line. Consumers of these locations, such as optimization remarks,
therefore reported the loop at the `#pragma omp` line rather than at the
loop.
Use the range of the associated loop instead, looking through loop
transformation directives such as `unroll` and `tile`. This covers the
inner loop and the outer dispatch loop of dynamic, guided and chunked
schedules. `sections` has no associated loop and keeps the directive
range.
For example, with `-fopenmp -O2 -Rpass=loop-vectorize`:
2 #pragma omp simd
3 for (int i = 0; i < n; ++i)
4 a[i] += b[i];
[4 lines not shown]
CGExprCXX: emit family and allockind attributes
This allows us to remove the special knowledge about C++ allocation from
LLVM's MemoryBuiltins.cpp, instead trusting attributes to communicate
the important properties.
Annoyingly, clang has to grow a little bit of hard-coded knowledge about
mangled symbol names in order to actually get the most-basic-matching
::operator::new when working out the alloc-family attribute. I spent
some time trying to do this "right" by looking up the available
operators new and finding the best one, but that's super tricky and this
has the virtue of working and being pretty obviously correct when
compared to the old code.
Happily, clang now emits allocator family attributes for custom
allocators like the `__hot_cold_t` overloads in `new_hot_cold.cpp`
(which `isReplaceableGlobalAllocationFunction` in clang recognizes),
allowing us to remove that special knowledge from LLVM.
[7 lines not shown]
SimplifyLibCalls: preserve allocation attributes in optimizeNew (#239731)
When `LibCallSimplifier::optimizeNew` rewrites an `operator new` call
into a `__hot_cold_t` allocation call, forward the allocation attributes
(`allockind`, `allocsize`, `"alloc-family"`, and parameter `allocalign`)
from the original call onto the synthesized call instruction alongside
its metadata.
This is a new patch since 2023 (unlike most of the rest of the stack)
and allows the next patch to remove more specialized C++ knowledge from
the LLVM layer, instead leaving it in clang where it seems more
sensible.
This patch was authored with the assistance of an LLM and was reviewed
by me before posting.
[AMDGPU] Fix more MSVC signed/unsigned and shift warnings (#241461)
Fix three MSVC warnings in the AMDGPU backend:
- AMDGPUISelLowering.cpp: C4018 (signed/unsigned mismatch) comparing the
unsigned DivBits against the int literals 23 and 22.
- AMDGPUDisassembler.cpp: C4334 (32-bit shift implicitly converted to 64
bits) in an assert comparing a uint64_t against 1U << EncSize. Use a
64-bit shift.
- AMDGPUInstCombineIntrinsic.cpp: C4334 EnBits is a uint64_t but the
masks were built with 32-bit shifts. Use 64-bit shifts.
[InstSimplify] Fold infinity arms of scalar ninf selects
A scalar ninf select produces poison when it selects a constant
infinity. Replace the select with its other arm, which preserves the
result whenever the select is defined. This removes infinity arms
from AMDGPU libcalls that already use ninf selects.
AI assisted.
[Inline] Preserve nofpclass(inf) on returned selects
Inlining can lose a call's nofpclass(inf) return constraint when the
callee returns a select. Carry the constraint over as ninf on eligible
scalar selects whose only use is the return. This lets later passes
simplify overflow paths that would return infinity.
AI assisted.
[InstCombine] Propagate ninf through single-use scalar selects
When an ninf select chooses the result of an inner select, an
infinity from the inner select makes the outer result poison.
If the inner select has no other uses, give it ninf so InstSimplify
can fold a constant infinity arm. This also propagates ninf through
nested selects in AMDGPU libcalls.
AI assisted.
[lldb] Remove ConstString from DynamicRegisterInfo (#243644)
RegisterInfo and RegisterSet both have `const char *` values. In many
cases, they are backed by static data and so their lifetime is
guaranteed. The one case where this is not true is DynamicRegisterInfo.
DynamicRegisterInfo produces RegisterInfo and RegisterSet objects for
register information that lldb is not aware of ahead of time. Currently
it stores strings in the ConstString pool to guarantee their lifetimes
for the remainder of lldb's run time. As a part of removing ConstString
from LLDB in general, this change ties those strings to the lifetime of
the DynamicRegisterInfo itself.
There are a few cases where RegisterInfo objects are pulled out of
DynamicRegisterInfo or a DynamicRegisterInfo object is copied. Those
cases are handled carefully, sometimes with ConstString, to make sure we
are not producing dangling pointers. Future changes will fix them.
[libLTO] Apply late -mllvm options to the target options (#244090)
lto_codegen_debug_options and lto_codegen_debug_options_array only
record the options. They are parsed when the first output is produced,
but the target options, including the MC options, are read from the
library options when the generator is created. Options that ld64 passes
with -mllvm, such as -macho-relocatable-dwarf or
-nozero-initialized-in-bss, were parsed and then ignored.
Read the target options again after the late options are parsed.
lto_set_debug_options and thinlto_debug_options parse before the
generator is created and are unchanged.