[CIR][CUDA] Add support for NVVM ldu builtins (#211843)
Adds CIR codegen support for the NVVM global uniform load builtins
`nvvm_ldu_*` ,including the integer, floating-point, and vector
variants.
These are lowered to the corresponding `llvm.nvvm.ldu.global.*`
intrinsics based on the pointee type.
[flang] Fix host association for ASYNCHRONOUS/VOLATILE in submodules (#211669)
In `HandleAttributeStmt`, when an `ASYNCHRONOUS` or `VOLATILE` statement
names a variable not already in the current scope, flang creates a
host-association symbol — but only for `Subprogram` and `BlockConstruct`
scopes. Submodule scopes have kind `Module`, so the check excluded them.
This caused a fresh `EntityDetails` symbol (zero-initialized) to be
created instead of a `HostAssocDetails` symbol pointing at the ancestor
module variable, producing value 0 instead of the initialized value.
Fix: extend the condition to also fire when `currScope().IsSubmodule()`.
`Scope::FindSymbol` already traverses into the parent module for
submodules, so the host variable is found correctly.
Note: the `volatile`/`asynchronous` `fortran_attrs` are not propagated
to `hlfir.declare` for host-associated variables in general
(subprograms,
BLOCK constructs, and submodules); that is a separate lowering issue
tracked in #208588.
[3 lines not shown]
[flang][OpenACC] Don't rebind construct entities to enclosing variables (#210775)
`AccAttributeVisitor::Post(Name)` "adjusts" every name referenced inside
an OpenACC region to the symbol found in the current scope. A construct
entity -- a `DO CONCURRENT`/`FORALL` index-name, or a variable declared
in a `BLOCK` construct -- lives in its own scope nested within the
region, but the visitor's current scope does not descend into that
construct scope. `FindSymbol` therefore resolves the name to a
like-named variable in an enclosing scope and rebinds the reference to
it.
When such an entity shadows an enclosing DO variable and the loop is
associated with an OpenACC construct, this makes the entity alias that
active DO variable, so referencing or defining it wrongly triggers
"Cannot redefine DO variable" -- even though the code is legal and
compiles without error when OpenACC is disabled. This affected a `DO
CONCURRENT` index-name as well as a variable declared in a `BLOCK`
construct nested in the loop, e.g.:
[21 lines not shown]
[libc][termios] Make termios hermetic and fix its compatibility with glibc 2.42 or after. (#211039)
Make termios hermetic and address its compatibility with glibc 2.42
breaking change
with baud rate definitions:
https://inbox.sourceware.org/libc-announce/5906001.DvuYhMxLoT@pinacolada/T/
Fixes include:
- Baud rate translation utilities.
- Add proxy headers for termios.h macros and types.
- Update tests.
Assisted-by: Gemini 3.5 Flash.
committers-guide: add Watchgoose benefit
Watchgoose, via its open-source support program, offers hosted
monitoring for scheduled/recurring tasks, such as cron jobs and backups.
[HashRecognize] Fix compiler hang on dense use-def chain (#211711)
When `digRecurrence` checks the use-def chain for a binary operator, it
simply uses a worklist to check the operands of each instruction. If
there are many instructions, and most instructions have multiple uses,
this takes exponentially long to compute, and can hang the compiler. Use
a visited set to skip instructions that have already been visited in the
use-def chain.
Credit to @freaknbigpanda for discovering this bug.
[compiler-rt] FreeBSD kernel headers in baremetal libprofile (#211278)
Add conditional FreeBSD kernel headers when building baremetal profile
library. This is unconnected to a CMake target; it requires building
libprofile out of band with `-DCOMPILER_RT_PROFILE_BAREMETAL=1`
and `-I/usr/src/sys/sys`.
The headers replaced in this diff are not available when building for
FreeBSD kernel space. This is the first issue I hit when experimenting
with using the baremetal libprofile like this, so there may be other
changes required as I make progress.
[VPlan] Fix sentinel assertion when broadcasting invoke results (#210464)
VPTransformState::get broadcasts a scalar value by inserting after the
last scalarized instruction using
std::next(BasicBlock::iterator(LastInst)). When LastInst is a terminator
like invoke, std::next advances past the end of the block, hitting the
!isKnownSentinel() assertion.
Use Instruction::getInsertionPointAfterDef which correctly handles PHIs,
invokes, and regular instructions, matching the pattern already used in
VectorCombine.cpp.
Fixes #210342
(cherry picked from commit 81cedf1e2060dbc2c5be43a6be0c86d6ba76df8d)
clang/AMDGPU: Migrate cc1 tests to subarch triples (4) (#211839)
Rewrite Headers cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu, and regenerate autogenerated CHECK
lines.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[AggressiveInstCombine] Avoid converting first table element when folding table-based cttz (#211202)
Do not attempt to zext (or truncate) the table's first element into the
cttz input type, as the element type may be wider than the input type.
Instead, convert the cttz result and emit the select directly in the
table's access type, which is the final expected type as well. Minor
opportunity to favor using APInt when the first element has more than 64
active bits to avoid crashing.
Fixes: https://github.com/llvm/llvm-project/issues/210890.
(cherry picked from commit 9edfdc231c9811124bbb7e3943c578c538d46aba)
[clang][Driver][SYCL] Fix SYCLInstallationDetector for compiler installs outside sysroot (#211351)
Currently if the compiler install is not under SYSROOT, we don't try to
compute the relative path to `libLLVMSYCL.so` based on the compiler
binary installation directory, resulting us never setting
`SYCLRTLibPath` so when we try to geenerate a linker call we get a raw
`libLLVMSYCL.so` which fails unless the user happens to be running the
compiler from a directory with `libLLVMSYCL.so` inside it.
It seems we never use the result from SYCLInstallationDetector on
Windows, so I can't add a test, however change the code to be consistent
in case we start to use it in the future.
---------
Signed-off-by: Nick Sarnie <nick.sarnie at intel.com>
AMDGPU: Reject unrecognized amdgpu subarch in TargetID parsing
A bare "amdgpu" or an unrecognized "amdgpu<x>" both parse to the
amdgpu arch with no subarch; TargetID::parse previously accepted them,
taking a named processor and ignoring the missing subarch.
Reject triples with no subarch, unless it uses the legacy spelling.
This is another workaround for Triple not having a proper unknown value
for subarches.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
[ARM] Use .reloc for dso_local weak symbols in PIC mode instead of GOT indirection (#209660)
In ARM ELF PIC mode, weak symbols referenced via the constant pool use a
PC-relative expression like `.long sym-(.LPC+8)`. The assembler eagerly
resolves this when the symbol and reference are in the same section,
which prevents the linker from overriding a weak definition with a
non-weak one from another object file.
The previous approach forced *all* weak symbols through GOT indirection.
That works, but `dso_local` weak symbols with hidden/protected
visibility are non-preemptible — they don't need GOT indirection, and
the extra load is wasteful. This patch emits a `.reloc` directive for
such symbols instead, forcing the assembler to produce an `R_ARM_REL32`
relocation while keeping a direct PC-relative reference from the
constant pool.
Default-visibility weak symbols (even `dso_local`) remain routed through
the GOT because they stay exported and preemptible in shared objects,
and `R_ARM_REL32` against an external symbol cannot be used when making
[5 lines not shown]
[libc][cpp::string] Allocate fewer temp strings in operator= and +=
This PR generally updates `cpp::string` to avoid incidental allocations. Specifically, it:
- Updates `opreator=(string_view)` to avoid allocating a temporary string: https://github.com/llvm/llvm-project/blob/67ebc4b221c3e94028b33004cd5cd08deee95048/libc/src/__support/CPP/string.h#L106-L108
- Changes `operator+=(const string&)` to accept a `string_view` so that strings may be appended without allocation.
- Makes the `string(string_view)` constructor explicit. Before, there were non-obvious allocations because of the implicit conversion.
This PR assumes that self-assignment and self-appends are not supported with `cpp::string`, and adds debug asserts preventing them. Currently, assignment doesn't work. `cpp::string s = "abc"; s = s;` will just zero out the string. This PR is a slight regression in that `operator+=(const cpp::string&)` previously worked, but now it errors in debug mode, and would result in a use-after-free without the assert statement. I don't think self-append/self-assignment is something `cpp::string` needs to support, so I omitted it, but if a reviewer thinks this behavior is important happy to amend this PR.
[libc][memory_utils] Rename shadowed load/store to avoid ADL ambiguity (#211714)
When compiling `inline_memmove` with MSVC for non-x86 architectures, `op_generic.h` picks
a non-builtin type for generic_v128 and friends:
https://github.com/llvm/llvm-project/blob/cad3c95a89c48d714a71f6e8b4af6f3e3ab100ea/libc/src/string/memory_utils/op_generic.h#L54-L57
This causes calls to `load` and `store` to trigger ADL, which is
ambiguous with `load` definition in `memory_utils/utils.h`.
```
C:\Users\jtstogel\Github\llvm-project\libc\src/string/memory_utils/op_generic.h(348): error C2668: '__llvm_libc_24_0_0_git::generic::store': ambiguous call to overloaded function
C:\Users\jtstogel\Github\llvm-project\libc\src/string/memory_utils/op_generic.h(138): note: could be 'void __llvm_libc_24_0_0_git::generic::store<T>(__llvm_libc_24_0_0_git::Ptr,T)'
with
[
T=__llvm_libc_24_0_0_git::inline_memmove_aarch64::uint512_t
]
C:\Users\jtstogel\Github\llvm-project\libc\src/string/memory_utils/utils.h(221): note: or 'void __llvm_libc_24_0_0_git::store<T>(__llvm_libc_24_0_0_git::Ptr,T)' [found using argument-dependent lookup]
with
[
[7 lines not shown]
[LoongArch] Support i128 operands for LSX inline assembly (#211464)
Allow `i128` values to be used with the `f` inline assembly constraint
when targeting LSX.
Although `i128` is not a legal LSX value type, it naturally maps to a
single 128-bit LSX vector register for inline assembly. This enables
instructions such as `vadd.q` to operate directly on `__int128` operands
without requiring explicit vector types.
(cherry picked from commit cad3c95a89c48d714a71f6e8b4af6f3e3ab100ea)
[LAA] Use dereferenceable assumption for dereferenceable_or_null pointers (#211820)
evaluatePtrAddRecAtMaxBTCWillNotWrap currently bails out when
getPointerDereferenceableBytes reports a size that requires the pointer
to be non-null (as with the dereferenceable_or_null attribute), even
when a stronger dereferenceable assumption is available for the same
pointer.
Reset DerefBytes to 0 in that case so we fall through to
getKnowledgeForValue and pick up any dereferenceable assumption. This
lets early-exit loops guarded by such an assumption vectorize.
[ADT] Skip initial empty string in StringTable iterator (#211808)
StringTable requires the first string to be empty, but this is never
useful for users that iterate over all strings in the table. Skip it by
default before drop_begin() on StringTable iteration scatters further
throughout the code base.
Revert "[analyzer] Fix false positive in strchr/strrchr with constant args" (#211857)
Reverts llvm/llvm-project#210154
Broke some build bots.
https://github.com/llvm/llvm-project/pull/210154#issuecomment-5071830822https://lab.llvm.org/buildbot/#/builders/144/builds/60200
```
# | error: 'expected-error' diagnostics seen but not expected:
# | File /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/string-search-modeling.c Line 515: use of undeclared identifier 'u'
# | File /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/string-search-modeling.c Line 527: use of undeclared identifier 'u'
# | File /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/string-search-modeling.c Line 538: use of undeclared identifier 'U'
# | File /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/string-search-modeling.c Line 550: use of undeclared identifier 'u'
# | File /home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Analysis/string-search-modeling.c Line 578: use of undeclared identifier 'u'
```
[Hexagon] Lower fcmp oeq to vcmp_(s|h)f_eq. (#211570)
Before this commit, the following error persisted in the hexagon
backend.
Consider the `file.ll` with the following contents.
```
define <32 x float> @setoeq_v32f32(<32 x float> %a, <32 x float> %b,
<32 x float> %c, <32 x float> %d) {
%cmp = fcmp oeq <32 x float> %a, %b
%r = select <32 x i1> %cmp, <32 x float> %c, <32 x float> %d
ret <32 x float> %r
}
```
Compiling it as `hexagon-llc -march=hexagon
-mattr=+hvxv81,+hvx-length128b file.ll`, we get
```
[23 lines not shown]