[LV] Generate SCEV runtime checks for outer loops. (#237780)
Update GenerateRTChecks::create to generate SCEV predicate checks for
outer loops as well. Memory checks are not supported yet, but we must
respect the SCEV predicates added to PSE.
[LV] Add tests with trip counts known less than VF x UF. (#237777)
Add tests where trip counts are known to be less than VF x UF, but we
still pick a VF that exceeds the trip count.
[Clang] Support `--offload-compress` for offload binaries (#227765)
Summary:
https://github.com/llvm/llvm-project/pull/222774 added support for
compressing binaries. This PR does the minimal work required to hook
this up to the existing handling. The end goal is to be able to replace
the bundler in HIP.
The one change is moving the `--verbose` handling from the shared helper
so this can be unified.
[IRNormalizer] Keep memory accesses in program order (#237128)
IRNormalizer can move a load past a store to the same address, changing
the value it reads. Include memory-accessing instructions in the initial
top-down traversal so memory accesses retain their relative order within
each basic block.
Alive2 (IRNormalizer load/store ordering):
Before (miscompiles 42 -> 7): https://alive2.llvm.org/ce/z/6VYPd5
After (verifies): https://alive2.llvm.org/ce/z/pY6t9g
Fixes #236128.
Assisted-by: Claude Code
[AMDGPU] IGLP: introduce instruction cache and fix static variables
Replace global / class-level static variables with a small cache that is
directly attached to the iglp pseudo instruction.
This has been suggested in
https://github.com/llvm/llvm-project/pull/137549#discussion_r3076970527
and the following comment in that thread.
Note that this patch is intended to be NFC and doesn't fix broader
issues with the analysis re-use.
Some tests have been stolen from
https://github.com/llvm/llvm-project/pull/232728.
Claude assisted with this patch.
[analyzer] Reject non-symbolic iterator offsets in alpha iterator checkers (#232622)
`evalBinOp()` can return a concrete value for a constrained iterator
offset. Storing `getAsSymbol()` from that result leaves a null offset in
the model, which is later dereferenced.
Return failure for non-symbolic results and let `++`/`--` fall back to a
fresh offset, preserving the container and the old position for postfix
results.
[Loads] Require step to be a multiple of alignment in isDereferenceable. (#237759)
Add missing check ensuring Step is also a multiple of the alignemnt in
isDereferenceableAndAlignedInLoop. Otherwise the loads in the loop may
not have the required alignment in all iterations.
[compiler-rt][Darwin] Split SANITIZER_IOS into SANITIZER_IOSLIKE and SANITIZER_IOS
SANITIZER_IOS is now TARGET_OS_IOS (iOS only), while the previous
meaning (TARGET_OS_IPHONE, iOS and iOS-like) is renamed SANITIZER_IOSLIKE.
Assisted-By: Claude
rdar://191534752
[Clang][OpenMP] Fix crashes on a `braced-init-list` in the `init` or increment of a loop (#233248)
Fixes #202562
The loop analysis kept the braced-init-list of `int i = {0}` (and of `i
+= {1}`) as the bound or step as written. The loop transformations copy
the trip count through a `TreeTransform`, which rebuilds a list without
a type, so `{0} - 1` fails to build and the transform asserts. Pointer
and aggregate-iterator counters hit a related assert even under plain
`omp for`, and the IRBuilder path crashed on a braced step.
The analysis now never keeps a bare list: a list wrapping one expression
becomes that expression, an empty or class-type list becomes the
`T{...}` node Sema builds for a functional cast. The IRBuilder loop path
uses the same helper for its step.
Assisted-by : LLM tools, reviewed and tested by me.
[CopyProf] Intercept new/delete and track per-object cost.
This intercepts the C++ `new` and `delete` operators, so that all
heap memory owned by a copy is tracked.
Using per-object state tracking, reports now tell the user how much
accumulated memory a copy is worth and whether it allocated.
This is useful for filtering of reports.
RFC: https://discourse.llvm.org/t/rfc-copysanitizer-csan-detecting-unneccessary-object-copies-at-runtime/91038
[CopyProf] Intercept C heap functions.
A copy that owns heap memory is only unnecessary if that memory is not
modified either. This intercepts the libc heap functions and routes them
to the CopyProf allocator, which marks memory allocated while copying as
copy, and checks the shadow memory of memory freed during destruction.
Memory allocated inside a d'tor is marked as copy as well, so that
freeing temporaries does not suppress reports.
Now that `malloc` is intercepted, `strndup` and `realpath` are
intercepted as well.
RFC: https://discourse.llvm.org/t/rfc-copysanitizer-csan-detecting-unneccessary-object-copies-at-runtime/91038
[CopyProf] Add standalone allocator.
Detecting modifications of heap memory owned by a copy requires hooking
all (de)allocations and knowing allocation sizes. This adds a CopyProf
specific allocator based on the sanitizer_common allocator.
It provides surrogates for the libc heap functions, which are hooked up
to interceptors in a subsequent patch.
RFC: https://discourse.llvm.org/t/rfc-copysanitizer-csan-detecting-unneccessary-object-copies-at-runtime/91038
Previous PR: #232851
[CopyProf] Add libc interceptors.
A copy is reported as unnecessary if neither the object nor any memory
it owns is modified before it is destroyed. So far, writes by
uninstrumented code, most importantly library functions (e.g. `memcpy`,
`memset`, etc.), are not accounted for, which leads to false positives.
Interceptors make these writes visible.
Additionally, objects constructed inside a d'tor are now marked as copy,
so that destroying temporaries (e.g. a string built for a log message)
does not suppress reports.
Note that `strndup` and `realpath` are not intercepted yet, as their
interceptors allocate memory via the `malloc` interceptor, which is only
added in a subsequent patch.
RFC:
https://discourse.llvm.org/t/rfc-copysanitizer-csan-detecting-unneccessary-object-copies-at-runtime/91038
Previous PR: #225905