stdio: Fix negated wchar scansets
We were recording the start of the scanset before checking if it began
with a caret. We need to check for a caret first, then record whatever
comes next as the start of the scanset.
Note that scanf() did not have this bug, only wscanf(), but this adds
regression tests for both anyway.
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D62328
[clang] Fix crash on trailing comma in vectorize_width (#246804)
With `#pragma clang loop vectorize_width(4, )`, the token after the
comma is the end marker for the loop hint. The parser diagnoses the
missing argument, then lexes past the marker. Error recovery consumes
the following loop and crashes at the end of the file.
```text
Stack dump:
1. <eof> parser at end of file
2. <stdin>:1:10: parsing function body 'f'
3. <stdin>:1:10: in compound statement ('{}')
```
Leave the end marker for the existing recovery path so parsing resumes
at the following loop. Clang now emits only the malformed hint error.
```text
<stdin>:2:40: error: vectorize_width loop hint malformed; use vectorize_width(X, fixed) or vectorize_width(X, scalable) where X is an integer, or vectorize_width('fixed' or 'scalable')
[5 lines not shown]
[AMDGPU][GlobalISel] Use v_cmpx/s_andn2_wrexec form in RegBankLegalize waterfall loops
Port the UseNewExecInstructions path from SIInstrInfo's waterfall emission
to RegBankLegalizeHelper::executeInWaterfallLoop. On subtargets with
no-sdst v_cmpx and s_andn2_wrexec, the loop now narrows exec with deferred
V_CMPX_EQ_*_nosdst_e32_term compares and computes the remaining lanes with
S_ANDN2 from an exec PHI, written back by S_MOV_term. SIOptimizeExecMasking
then folds the pair into s_and_not1_wrexec, matching SelectionDAG.
Co-authored-by: Cursor <cursoragent at cursor.com>
TableGen: Add \x escape to string literals (#248201)
Accept \xHH in string literals, producing the character with the
hexadecimal value HH. This allows writing names that contain control
characters, such as the \01 prefix used to suppress symbol mangling. A
few edge cases in RuntimeLibcallsInfo need to do this (e.g., on Darwin
there is a function named "\01mcount").
Assisted-by: Claude
[tsan] Intercept mremap on Linux to update shadow memory (#230707)
[tsan] Intercept mremap on Linux to update shadow memory
ThreadSanitizer intercepts `mmap`, `mmap64`, and `munmap`, but did not
intercept Linux `mremap`. When a mapping is relocated (`MREMAP_MAYMOVE`
/ `MREMAP_FIXED`), shrunk in-place, or expanded in-place via `mremap`,
TSan's shadow memory became out of sync with the process address space:
- Relocated mappings left stale shadow state at the unmapped old range
(unless `MREMAP_DONTUNMAP` was set) and did not reset or initialize
shadow memory for the destination range.
- In-place shrinks left stale shadow state on the unmapped trailing
pages.
- In-place expansions did not initialize or reset shadow memory for the
newly mapped pages.
Add a Linux `mremap` interceptor that calls `UnmapShadow` on unmapped
old pages and `MemoryRangeImitateWriteOrResetRange` on newly mapped or
expanded ranges.
[7 lines not shown]
[AMDGPU] Fold add into integer wmma accumulator
Integer wmma and swmmac wrap on overflow when clamp is off, so adding X
to the result is the same as adding X to the accumulator. Fold the add
when the accumulator is zero or both are constants. Because wmma is
convergent, the call is only moved to the add when both are in the same block.
```llvm
%d = call <8 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu8.v8i32.v2i32(i1 0, <2 x i32> %a, i1 0, <2 x i32> %b, <8 x i32> zeroinitializer, i1 0)
%r = add <8 x i32> %d, %x
-->
%r = call <8 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu8.v8i32.v2i32(i1 0, <2 x i32> %a, i1 0, <2 x i32> %b, <8 x i32> %x, i1 0)
```
[OpenMP] Detect atomic library requirements (#244783)
Check whether the atomic operations used by libomp link without
additional libraries. If not, retry with libatomic and add -latomic
only if that works. Warn if neither links. Skip the check for MSVC.
The test program uses __sync and __atomic builtins on 8, 16, 32 and
64-bit integers, like kmp_os.h does.
This replaces the unconditional -latomic for mips and mips64 and the
ppc-only check for __atomic_load_8. mips64 has native 64-bit atomics
and kmp_os.h only uses the __atomic builtins for 32-bit MIPS, so it
does not need libatomic.
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull vhost fix from Michael Tsirkin:
"Another high priority bugfix. Working on more"
* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vhost: reject used ring batches larger than the ring
Revert "vhost: split out-of-order used ring batches at every wrap"
[MLGO] Make EmitC Lowering Steps depend on MLIR binaries (#248286)
Otherwise when the MLIR binaries get updated, ninja doesn't think that
any of the inputs get changed so the model does not get recompiled.
[SelectionDAG] Avoid TokenFactor self-reference in memory ordering updates (#246859)
`makeEquivalentMemoryOrdering` can reuse an existing TokenFactor and
then temporarily make it reference itself while replacing the old chain.
Recursive CSE can collide with another TokenFactor and abort with "Node
is not in map!".
Leave the TokenFactor's own operand unchanged and replace only the other
uses of the old chain. The repeated-ordering unit test reproduces the
abort on the unmodified parent; both added tests pass with this fix,
without the X86 changes in #245000.
AI assistance was used for implementation, tests and analysis.
[LLDB] Halt the process before disabling an InstrumentationRuntime plugin
Disabling an InstrumentationRuntime plugin in a process destroys the
plugin instance. The plugins pass a raw `this` pointer as the baton for
their breakpoint callbacks so the plugin's breakpoint must not be hit
while the plugin is being destroyed.
`Process::SetInstrumentationRuntimeEnabled()` now refuses to disable a
plugin unless the process is stopped. When the `plugin disable` command
disables a plugin in a running process it halts the process, disables
the plugin and then resumes the process. The halt is not hidden so
clients see the process stop and then run again.
If the process happens to stop for another reason (e.g. a breakpoint)
at the same time as the halt it is still resumed. This is very unlikely
and is noted in a FIXME.
Enabling a plugin doesn't require the process to be stopped.
Assisted-by: Claude Code
[LLDB] Check for the instrumentation runtime before getting stop info
In `SBThread::GetStopReasonExtendedBacktraces()` check whether the
process still has an instance of the instrumentation runtime before
getting the thread's stop info. The stop info isn't needed if the
runtime has been disabled.
Assisted-by: Claude Code