[analyzer] Fix StdVariantChecker crash on std::get with a non-ptr arg (#210167)
When `std::get` is called on a dereferenced integer-to-pointer cast, the
checker `alpha.core.StdVariant` crashes. Minimal reproducer:
```
std::get<int>(*(std::variant<int, char> *)11);
```
Godbolt reproducer - https://godbolt.org/z/4EKe1PrKb
The root cause is that `StdVariantChecker::handleStdGetCall()` calls
`SVal::getType()` on any non-unknown argument, then calls
`getPointeeType()` on the result while assuming it is a pointer type. In
the case of a concrete integer cast to a pointer and then dereferenced,
it is modeled as `loc::ConcreteInt`, whose recovered type is an integer.
`getPointeeType()` on such an input returns a null QualType, on which
`getTypePtr()` crashes.
Fix the crash by using the argument's static type rather than recovering
its SVal, eliminating the need to guard and call `getPointeeType()`.
[clang] Update diagnostics to include matrices as accepted types (#201237)
Several `err_builtin_invalid_arg_type` call sites still emit "scalar or
vector of ..." even though the underlying checkers already unwrap matrix
types. This extends the diagnostic with a new "scalar, vector, or matrix
of" option (index 6) and migrates the call sites whose checkers do
accept matrices:
Call sites whose checkers only unwrap VectorType are left at index 5 so
their diagnostic text continues to accurately describe what is accepted.
Tests using the old wording are updated to match.
Fixes #189147
Assisted by copilot
---------
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
[llvm][docs] Update TestingGuide with LLVM PR merge advice (#207754)
Add guidance on waiting for LLVM PR merges before test-suite merges to
prevent failures.
Co-authored-by: John Otken john.otken at hpe.com
[SimplifyCFG] Simplify switch default branch when branch proves operand value (#206597)
If the default branch of a switch proves that there is only one value
that can be sent to the default branch, we can transform the default
branch into an explicit case of the switch. This can assist in further
simplification of the CFG during the simplification loop.
For example, we should be able to create an explicit case for the
default block in cases like the following:
```llvm-ir
switch_bb:
switch i8 %x, label %default_bb [...]
default_bb:
%cmp = icmp eq i8 %x, 1
call void llvm.assume(i1 %cmp) ; Implies %x must be 1
```
Related to #50665.
[AArch64][CodeGen] Fix trampoline basic block offset (#202716)
Trampoline basic blocks are initially created with an offset of zero. As
a result, `isBlockInRange()` may operate on incorrect block offset,
potentially causing unnecessary conditional branch inversions or the
insertion of redundant trampolines.
15320 Add support for SMF_EXIT_TEMP_DISABLE
Reviewed by: C Fraire <cfraire at me.com>
Reviewed by: Bill Sommerfeld <sommerfeld at hamachi.org>
Reviewed by: Jason King <jason.brian.king+illumos at gmail.com>
Approved by: Dan McDonald <danmcd at edgecast.io>
hwpmc: Add EXTERROR diagnostics to the hwpmc syscall path
Annotate validation failures in the PMC syscall handlers (allocate,
attach, read/write) with EXTERROR(), so pmc(3) callers see which
precondition failed, not a bare errno.
Register HWPMC_MOD in exterr_cat.h and the generated filenames.h.
Signed-off-by: Andre Silva <andasilv at amd.com>
Reviewed by: Ali Mashtizadeh <ali at mashtizadeh.com>, mhorne
Sponsored by: AMD
Pull Request: https://github.com/freebsd/freebsd-src/pull/2180
hwpmc: Add EXTERROR diagnostics to the AMD and IBS allocators
Replace bare EINVAL in AMD/IBS allocation and config-validation with
EXTERROR(), so a failed pmc(3) allocation names the check and value.
Register HWPMC_AMD in exterr_cat.h and the generated filenames.h.
Signed-off-by: Andre Silva <andasilv at amd.com>
Reviewed by: Ali Mashtizadeh <ali at mashtizadeh.com>, mhorne
Sponsored by: AMD
Pull Request: https://github.com/freebsd/freebsd-src/pull/2180
cad/verilator: Fix run-time error when verilated program couldn't find lz4
/usr/local/share/verilator/include/verilated.mk is patched with relevant
values.
PR: 296673
Reported by: Joel Bodenmann <jbo at FreeBSD.org>
(cherry picked from commit d9a357804e97a3ab009c2f865530226c44eb5ea7)
fetch: Stop setting an alarm
Now that fetchTimeout works reliably, setting an alarm is not only no
longer necessary but counterproductive, as it will trigger even if the
connection is not actually stalled but merely slow.
While here, improve the wording of the manual page's description of the
various options for setting a timeout.
MFC after: 1 week
Reviewed by: op
Differential Revision: https://reviews.freebsd.org/D57911
(cherry picked from commit 3dddfe29248c47d1a80dc96a76a308ae910b2a24)
libfetch: Add read buffering
Previously, we would read FTP control connection messages and HTTP
reponse headers one character at a time. Now, we read as much as will
fit in our buffer and look for a newline. If there is data left over,
it will be reused by the next fetch_getln() call. This also requires
the addition of a fetch_bufread() which takes the buffer into account,
otherwise the start of the HTTP response body will be stuck in the
buffer after we read the last line of the header.
This should noticeably improve HTTP performance, especially for small
transfers.
MFC after: 1 week
Reviewed by: op
Differential Revision: https://reviews.freebsd.org/D57907
(cherry picked from commit a1978277379cf65f1339ab062f335c6f1fa6239f)
libfetch: Apply timeout to connection attempts
Mark the socket non-blocking before connecting and poll for completion,
applying fetchTimeout if set.
MFC after: 1 week
Reviewed by: op
Differential Revision: https://reviews.freebsd.org/D57909
(cherry picked from commit 848f360c8f9ae8d1d97c61f5d63fc624926d5dcd)
libfetch: Overhaul socket read / write
* Make fetch_ssl_read() and fetch_ssl_write() behave more like read(2)
and write(2), and drop fetch_socket_read() in favor of read(2).
* Don't request POLLERR, it's implied.
* Don't needlessly set errno, it's relatively costly.
* Always check for EAGAIN from writev(2), otherwise we will abort on a
short write instead of proceeding to poll(2).
* Always check for EAGAIN from poll(2) even though it can't happen on
FreeBSD; POSIX says it can, and it might in the future.
* Rewrite fetch_read() and fetch_writev() to be more similar to each
other. The main difference is that a partial read is treated as
success while a partial write is treated as failure.
[6 lines not shown]
cad/verilator: Fix run-time error when verilated program couldn't find lz4
/usr/local/share/verilator/include/verilated.mk is patched with relevant
values.
PR: 296673
Reported by: Joel Bodenmann <jbo at FreeBSD.org>
fetch: Stop setting an alarm
Now that fetchTimeout works reliably, setting an alarm is not only no
longer necessary but counterproductive, as it will trigger even if the
connection is not actually stalled but merely slow.
While here, improve the wording of the manual page's description of the
various options for setting a timeout.
MFC after: 1 week
Reviewed by: op
Differential Revision: https://reviews.freebsd.org/D57911
(cherry picked from commit 3dddfe29248c47d1a80dc96a76a308ae910b2a24)
libfetch: Apply timeout to connection attempts
Mark the socket non-blocking before connecting and poll for completion,
applying fetchTimeout if set.
MFC after: 1 week
Reviewed by: op
Differential Revision: https://reviews.freebsd.org/D57909
(cherry picked from commit 848f360c8f9ae8d1d97c61f5d63fc624926d5dcd)
libfetch: Overhaul socket read / write
* Make fetch_ssl_read() and fetch_ssl_write() behave more like read(2)
and write(2), and drop fetch_socket_read() in favor of read(2).
* Don't request POLLERR, it's implied.
* Don't needlessly set errno, it's relatively costly.
* Always check for EAGAIN from writev(2), otherwise we will abort on a
short write instead of proceeding to poll(2).
* Always check for EAGAIN from poll(2) even though it can't happen on
FreeBSD; POSIX says it can, and it might in the future.
* Rewrite fetch_read() and fetch_writev() to be more similar to each
other. The main difference is that a partial read is treated as
success while a partial write is treated as failure.
[6 lines not shown]