[libc] Return the written character from putc, fputc and putchar on baremetal and gpu (#240248)
Follow-up to #239980, which changed the generic implementations to
return the character written as an unsigned char converted to int, as C
requires, and updated the shared tests to expect it. The baremetal and
gpu implementations still returned zero.
Each of the six functions now returns `static_cast<int>(uc)` on success.
Assisted-by: Claude
[CIR] Emit no-trapping-math and stack-protector-buffer-size function attribute (#234029)
Mirror classic codegen's `getDefaultFunctionAttributes` by setting
`"no-trapping-math"` (when FP exceptions are ignored) and
`"stack-protector-buffer-size"` on function definitions and
declarations. Both are lowered to LLVM IR through the `passthrough`
attribute array, since `llvm.func` has no dedicated fields for them.
Most changes are related to testing.
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply at anthropic.com>
[libc] Return the written character from putc, fputc and putchar (#239980)
All three returned zero on success. C requires the character written,
taken as an unsigned char and converted to int. A caller comparing the
result against the character it passed reads zero as a failed write.
m4's configure probes ftello by writing a byte after a read reaches end
of file and checking that putc returns it. It concluded LLVM-libc had a
Solaris bug it does not have, then failed to compile the workaround it
selected.
Assisted-by: Claude
[ELF] .note.gnu.property: Require padding for the last piece (#240238)
parseGnuPropertyNote skips pr_datasz rounded up to the alignment but
checks only pr_datasz, reading out of bounds when the padding is
missing. GNU ld reports such a note as corrupt.
Fix #235225
[lldb] Skip TestScriptedFrameProvider expression test on non-x86 Linux (#240233)
`test_expression_at_frame_without_variables` still fails on aarch64
Linux after 58b0fd59e5fb with "Couldn't allocate space for materialized
struct".
The IR interpreter evaluates `1 + 1`, so no code runs in the inferior,
but LLDB still needs to allocate memory there for the expression's
arguments and result. On macOS, debugserver does that itself when it
gets the `_M` packet, using `mach_vm_allocate()`. On x86 Linux,
lldb-server does it by running the `mmap` syscall on the thread's real
registers. Neither path goes through LLDB's frames, so the scripted
frame 0 never matters there.
lldb-server doesn't implement `_M` on other Linux architectures, so on
aarch64 LLDB falls back to calling `mmap` in the inferior. Before making
that call, `Thread::CheckpointThreadState()` saves the registers of
frame 0, which is the scripted frame. Its `RegisterContextMemory` has no
backing address, so `ReadAllRegisterValues()` fails and the call is
[6 lines not shown]
[SLP][NFC] Add tests for dependent seeds in rejected windows (#240208)
Precommit tests for the once-used seeds that depend on each other, such
as x * x and x * (x * x), whose window is rejected and whose users are
bypassed by the window walk.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc] Make a stream unbuffered when setvbuf is given a size of zero (#236517)
`setvbuf(f, nullptr, _IOFBF, 0)` and `setlinebuf(f)`, which is
`setvbuf(f, nullptr, _IOLBF, 0)`, take the branch that stores the
caller's buffer. That buffer is null, but the requested mode is kept, so
the stream is left fully or line buffered with no buffer. A buffer of no
size holds nothing, so this sets the mode to `_IONBF` to match.
Where it came from: with my libc `setlinebuf(stdout)` followed by
another write crashed `bluetoothctl --help` when stdout was a pipe,
through a null buffer in a line buffered stream. I could not reproduce
that crash in a unit test on current main, so the tests added here pass
with and without the change. They pin the behaviour a program can see: a
zero sized stream shows its writes without a flush, and a sized one
still waits for `fflush`. Nothing public reports the buffering mode, so
I can't test the mode directly.
AI disclosure: this patch was written with Claude Code. I reviewed the
change and ran the new tests.
Assisted-by: Claude
[ELF] -r: Create kept SHT_GROUP sections as InputSection (#240234)
* If it has the SHF_MERGE flag, the group becomes a MergeInputSection
and finalizeShtGroup crashes reading symbols from the internal file.
* If it is named .note.GNU-stack, it is incorrectly discarded.
Fix #235240