[analyzer] Order UninitializedObject notes deterministically (#214208)
UninitFieldMap is keyed by FieldRegion pointers, so iterating it to emit
the notes ordered them by where those regions happened to be allocated.
The order therefore varied between runs: on cxx-uninitialized-object.cpp
the two notes of the report at line 363 swapped in roughly 3 of 12 runs.
- Emit the notes in source order instead, tie-broken by the note message.
- `-verify` matches notes by line, text and count and ignores their order,
so the new test pins the order down with FileCheck.
Assisted-By: claude
[compiler-rt] Create a combined compiler-rt builtin bitcode for SPIRV64 target (#214149)
This PR re-lands the compiler-rt builtin part from
https://github.com/llvm/llvm-project/pull/196656
Signed-off-by: jinge90 <ge.jin at intel.com>
[NFC][llvm][object][GOFF] cleanup GOFFObjectTests (#212286)
This change cleans up the GOFF object file reading unit test based on
suggestions from #211632, and a few minor fixes for other issues
identified
Namely these are:
1. Remove global data from the test, making all data local to the test
being run
2. Fix erroneous reference to XCOFF rather than GOFF
3. Use vector rather statically size arrays for the test data
4. Use helpers to construct the data for repeated record types (we leave
trivial and one off cases as-is)
5. Swap uses of dyn_cast for static_cast
Assisted by: IBM Bob 2.0.1
---------
Co-authored-by: James Henderson <James.Henderson at sony.com>
AMDGPU/GlobalISel: Switch more FP opcodes to extended LLTs (part 6) (#214031)
Migrate G_LROUND, G_LLROUND, G_INTRINSIC_LRINT, G_INTRINSIC_LLRINT,
G_FCOPYSIGN, and G_ATOMICRMW_FADD to extended LLTs.
Update the relevant MIR tests.
[libc++][pstl] Implementation of parallel std::destroy() and std::destroy_n() (#211888)
This PR adds an implementation of parallel versions of `std::destroy`
and `std::destroy_n`. The implementations are based on `for_each` and
`for_each_n`, effectively one-liners
Fixes #134588.
Fixes #134589.
Fixes #101693.
[AMDGPU] Perform scalar FMUL with bf16 more efficiently (#213969)
Perform scalar FMUL with bf16 more efficiently. Utilize v2bf16 patterns.
Signed-off-by: John Lu <John.Lu at amd.com>
[OpenMP] Preview of auto-generating OpenMP definitions
The components of this commit:
1. Definitions of descriptors that will hold relevant data in LLVM
and declarations of associated functions.
2. "Auto-generated" enum definitions and descriptor data
3. Changes to flang's modifier verification to use the new data
instead of the previously hand-coded modifier information.
This does not contain the actual auto-generation infrastructure.
The included descriptors were generated directly from JSON files by
a custom python script.
[OpenMP] Preview of auto-generating OpenMP definitions
The components of this commit:
1. Definitions of descriptors that will hold relevant data in LLVM
and declarations of associated functions.
2. "Auto-generated" enum definitions and descriptor data
3. Changes to flang's modifier verification to use the new data
instead of the previously hand-coded modifier information.
This does not contain the actual auto-generation infrastructure.
The included descriptors were generated directly from JSON files by
a custom python script.
[LifetimeSafety] Suppress dangling field warnings for RAII resetters in permissive mode
(#214212)
In `-Wlifetime-safety-permissive` mode, suppress dangling field warnings
(`-Wlifetime-safety-dangling-field`) when `this` or the escaping field
declaration is captured by a lambda within the function. This accounts
for common RAII field resetters that clean up dangling pointers on scope
exit.
### Motivating Example
Dangling field analysis can report false positives when an RAII field
resetter (such as `absl::MakeCleanup` or `absl::Cleanup`) captures
`this` or the field to reset the pointer before function exit:
```cpp
struct TimeServerInstance {
Handler* handler_;
void init() {
[8 lines not shown]
[OpenMP] Preview of auto-generating OpenMP definitions
The components of this commit:
1. Definitions of descriptors that will hold relevant data in LLVM
and declarations of associated functions.
2. "Auto-generated" enum definitions and descriptor data
3. Changes to flang's modifier verification to use the new data
instead of the previously hand-coded modifier information.
This does not contain the actual auto-generation infrastructure.
The included descriptors were generated directly from JSON files by
a custom python script.
[Sparc][clang] make `_Complex` ABI GCC-compatible (#212340)
Modify the ABI of `_Complex` so that it matches GCC for all types,
specifically:
- On SPARC, a `_Complex` value with an integer element type is now
passed and
returned packed into the one or two integer registers it fits in,
matching GCC.
Clang previously passed such a value indirectly and returned it with one
part
per register.
`-fclang-abi-compat=23` restores the previous behavior.
- On SPARC64, a `_Complex char` or `_Complex short` is now
right-justified in its slot in the parameter array, like every other
scalar
narrower than a slot, rather than left-justified the way a small struct
is.
[14 lines not shown]
[CIR]/[OGCG] Fix handling of bool-backed-scoped-enums (#214084)
This patch primarily fixes the case of a scoped enum with a boolean type
in CIR, which we assume is an 'int' type, whereas this one case, that is
not true. Rather than change the Dialect for what amounts to a very rare
case, we've instead opted to just coerce the bool type into a 1 bit int
type, so that all our passes will consider it the same as the rest of
the switches, and not have to special-case the 'bool' types.
AS A DRIVE-BY: I discovered that classic-codegen manages to assert on
llvm::isUIntN in the case where the storage of a range for
GNU-range-switch is less than 7 bits, so bit-int could possibly hit this
too with gnu-range. This patch would fix any case (as the test for the
'shortcut' is for <64).
[clang][LifetimeSafety] Drop block-local origins at block exit (#213530)
Block-local origins were only discarded in `join`, which the dataflow
driver skips when a successor's in-state is seen for the first time, and
therefore always skips for a block with a single predecessor. In
straight-line code the block-local map was inherited down the whole
chain and never cleared, so it accumulated every expression origin in
the region.
Drop them in a new `exitBlock` hook instead, which runs on every edge.
This also keeps in-states canonical, so state comparison no longer sees
a spurious difference between a first-visit in-state and a joined one.
The per-program-point states the checker queries are unaffected; only
the state propagated across block boundaries changes.
LoanPropagation time below, median of 5-7 interleaved runs of a baseline
and a patched binary. Synthetic cases are from
clang/test/Analysis/LifetimeSafety/benchmark.py:
[26 lines not shown]
[CIR] Verify record_align is a non-zero power of two (#214074)
`#cir.record_layout` carries `record_align`, which CIRGen fills from
`ASTRecordLayout::getAlignment()` and consumers read as an
`llvm::Align`. That constructor asserts the value is a non-zero power of
two, so hand-written CIR naming any other alignment aborted the tool
rather than reporting a parse error. A zero tripped the non-zero assert
and a 3 tripped the power-of-two one, both inside `llvm::Align` with no
indication of which attribute was at fault.
Verify the field where it is parsed. Values CIRGen emits are already
well-formed, so this only affects hand-written input.
Assisted-by: Cursor / claude-opus-5
[analyzer] Discard stack frames that are not on the current live stack (#213779)
When a source's stack frame is not live on the current stack the
`UseAfterLifetimeEnd` checker emitted a false positive. Such sources
outlive the returned value, so they are not dangling stack sources. This
led to multiple false positives when I ran the `UseAfterLifetimeEnd`
checker on the LLVM project.
---------
Co-authored-by: isuckatcs <65320245+isuckatcs at users.noreply.github.com>
[clang][Sema] Handle alloc_align on all HasFunctionProto declarations (#210871)
Fixes #122058.
## Overview
Attribute `alloc_align`'s TableGen subject accepts any declaration
satisfying `HasFunctionProto`, but `AddAllocAlignAttr` unconditionally
casts the declaration to `FunctionDecl` (in
`Sema::AddAllocAlignAttr()`). Since there exist `Decl`'s that have an
underlying `FunctionProtoType` but are not `FunctionDecl` (e.g. function
pointer variables and parameters), the unconditional
`cast<FunctionDecl>` is too narrow and leads to a crash for `Decl`s that
are meant to be compatible with the `alloc_align` attribute.
For example, trying to compile `C` file
```
void *(*allocator)(unsigned long long) __attribute__((alloc_align(1)));
[125 lines not shown]
[flang][MIF] Fix undef reference to a coarray_handle in mif.dealloc_coarray #193157 (#213890)
This PR fixes the behavior reported in issue #193157. The coarray_handle
was only defined if a call to mif.alloc_coarray was present.
If a call to mif.dealloc_coarray was encountered without a prior call to
mif.alloc_coarray, then the coarray_handle was missing, and therefore
llvm.address_of pointed to a non-existent address, which is not allowed.
We now define a coarray_handle that has not been allocated by PRIF for
each coarray variables.