[libc++] std::byteswap support for _BitInt(N) (#196512)
Add a byte-reversal loop fallback for `std::byteswap` when `sizeof(T) >
16`,
so the function works for `_BitInt(N)` with `N > 128` and any future
wider
integer type. Without it, those calls hit `static_assert(sizeof(_Tp) ==
0)`
and fail to compile.
Reject `_BitInt(N)` where `N` is not a multiple of `CHAR_BIT`. The
existing
`__builtin_bswap{16,32,64,128}` paths swap the storage representation
including padding bits, and the resulting value's meaning is
unspecified.
A new `static_assert` catches that case and reports it. Size-1 types are
exempt from the check, since no bytes move there.
Part of the [_BitInt(N) libc++
[6 lines not shown]
Handle sections that specify alignment as 0 when loading an ELF interpreter
(i.e. ld.so). Since the smallest possible alignment actually is a the
page size just start with that and only increase it if a larger alignment
is requested. Also reject interpreters without loadable segments, just
like we did for ld.so a few weeks ago.
Distilled from a report by Andrew Griffiths.
ok jsg@, deraadt@
[Clang][test] Fix leading slash (#200549)
A reviewer in #200012 required checking for a leading (back-)slash to
the test despite none of the other tests doing so. Turns out, the slash
isn't there if the driver is unable to resolve the full path to the
linker. Remove the leading slash from the test.
Fixes reported buildbot failures:
* clang-solaris11-sparcv9
* clang-solaris11-amd64
Validate size of chunks copied to piglet during hibernate unpack
Ensure that the compressed size of the chunk read from the hibernate image
will fit into the reserved space in the piglet for such chunks. Prevents
chunks with invalid sizes from overrunning the piglet. Such corrupted
chunks could be present in tampered or corrupt on-disk hibernate images.
Reported by Frank Denis
[MergeICmps] Don't merge comparisons whose width isn't a byte multiple (#200346)
MergeICmps looks for cases like
struct S { char x; char y; }
A.x == B.x && A.y == B.y
If `x` and `y` are stored adjacent to one another, we can convert the
above into a memcmp, which can then be converted into a single 16-bit
compare.
This pass currently does the wrong thing if the struct members' sizes
are not multiples of 8 bits. To fix this, we simply bail if the elements
in question are not multiples of one byte.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
[LICM] Drop poison-generating flags when reassociating an icmp (#200344)
`hoistAdd`/`hoistSub` turn `LV + C1 <pred> C2` into `LV <pred> C2 - C1`,
changing the icmp's LHS. A `samesign` flag asserted about the old
operands need not hold for the new LHS, so keeping it can turn a defined
comparison into poison (e.g. for `%iv = -3`, `samesign slt(2, 100)` is
true but the reassociated `samesign slt(-3, 95)` has
opposite-sign operands → poison). Drop the icmp's poison-generating
flags after the rewrite, as `hoistMulAddAssociation` already does.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
Co-authored-by: Claude Opus 4.8 (1M context) <noreply at anthropic.com>
[SelectionDAG] Preserve IR alignment on atomicrmw/cmpxchg MMOs (#200332)
Previously SelectionDAG used the natural alignment of the value type,
even if the instruction specified a different alignment.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
Validate sizes against integer overflow when reading chunks in unhibernate
Validate that chunk sizes stored in the chunktable don't result in integer
overflow. Such invalid chunk sizes could be present in tampered or corrupt
on-disk hibernate images.
Reported by Frank Denis
Revert "[X86] matchBinaryPermuteShuffle - match to X86ISD::SHLD funnel shift patterns" (#200546)
Reverts llvm/llvm-project#200136 while I investigate a miscompilation report
[Flang][OpenMP] Reject array sections and subobjects in LINEAR clause (#197430)
Array sections like a(:,1,1) and array elements like a(1) in a LINEAR
clause cause a crash during MLIR-to-LLVM IR translation because the
semantic checker doesn't catch them.
This adds a call to CheckVarIsNotPartOfAnotherVar for the LINEAR clause,
which is the same check used by PRIVATE and FIRSTPRIVATE to reject
subobject designators.
Fixes :
[https://github.com/llvm/llvm-project/issues/196068](https://github.com/llvm/llvm-project/issues/196068)
Co-authored-by: Chandra Ghale <ghale at pe34genoa.hpc.amslabs.hpecorp.net>
[Flang][Parser] Handle compiler directives inside INTERFACE blocks (#198516)
Unrecognized !DIR$ directives between interface specifications currently
cause cascading parse errors because the grammar for
InterfaceSpecification has no path to consume them. This patch adds
CompilerDirective as a valid alternative — matching how
InternalSubprogram and ModuleSubprogram already handle this — so that
unrecognized directives produce the expected warning instead of a fatal
parse failure.
Fixes :
[https://github.com/llvm/llvm-project/issues/198289](https://github.com/llvm/llvm-project/issues/198289)
---------
Co-authored-by: Chandra Ghale <ghale at pe34genoa.hpc.amslabs.hpecorp.net>