[clang][bytecode] Fix crash on __builtin_align_up with one-past-end pointers (#178652)
## Summary
Fix assertion failure when evaluating
`__builtin_align_up`/`__builtin_align_down`/`__builtin_is_aligned` with
one-past-end pointers like `&array[size]`.
## Root Cause
`getIndex()` calls `getOffset()` which asserts when `Offset ==
PastEndMark`. This happens for one-past-end element pointers.
## Fix
Check `isElementPastEnd()` before calling `getIndex()`. For past-end
pointers, use `getNumElems()` instead which gives the correct index
value.
## Test
Added test cases in `builtin-align-cxx.cpp` for one-past-end pointer
alignment.
Fixes #178647
InstCombine: Fold bitcast of vector with constant to scalar
Fold bitcast (select cond, val, const) ->
select cond, (bitcast val), (bitcast const)
Rocm device libs has an unfortunate amount of code that does bithacking
on the sign bit of double values by casting to <2 x i32> and operation
on the high element. This breaks value tracking optimizations on the
fp value.
The existing transform would only do this if the input to the select was
also a bitcast with a single use, and if it didn't convert between vector
and scalar.
[clang-tidy] Add new check `modernize-use-structured-binding` (#158462)
This check detect code which can be transfered to c++17 structured
binding, and provides fix-it.
Limitations:
1. Ignore variables with attributes or qualifiers except `const` and `&`
since it's not very common:
```
static auto pair = getPair(); // no warning from this check
static int b = pair.first;
static int c = pair.second;
```
2. Some possibly convertable case:
(1)
```
const auto& results = mapping.try_emplace("hello!");
[27 lines not shown]
[MLIR][Python] Expose TransformOpInterface and MemoryEffectsOpInterfaces
Enables implementing these two interfaces from Python through defining
the relevant methods on a Python class which then serve as callbacks for
a new FallbackModel C++ class that acts as a "trampoline" to Python for
when the Interface's methods are called from C++. Like in the C++
codebase, these FallbackModels are a late-binding mechanism which can be
attached to an operation after its definition.
[clangd] fix compilation errors with newer versions of gRPC (#67258)
in recent versions of gRPC, header files with prefix `grpc++` are
deprecated.
gRPC headers in include/grpc++ are deprecated since gRPC 1.10.0
https://github.com/grpc/grpc/releases/tag/v1.10.0 , this PR should close
https://github.com/clangd/clangd/issues/1603
Co-authored-by: Thibault Monnier <97551402+Thibault-Monnier at users.noreply.github.com>
[NFC] To fix comment in the code as getIntN no longer does truncation. (#178834)
The comment of `getIntN` says it may truncate the result. However, PR
#171456 changed the default of truncation of `ConstantInt::get` to
false, so it no longer truncates. Fix the comments to reflect the
change.
Thread Safety Analysis: Add test for alias reassignment through pointer-to-pointer (#179028)
Alias reassignment through pointer-to-pointer (nor ptr-to-ptr-to-ptr...)
does not invalidate an alias for now. While this may result in either
false positives or negatives, there's rarely a good reason not to just
do direct assignment within the same scope.
For the time being, we retain this as a deliberate "escape hatch":
specifically, this may be used to help the alias analysis to "see
through" complex helper macros that e.g. read a value (such as a
pointer) via inline assembly or other opaque helpers [1].
Add a test to document the current behaviour.
NFC.
[1] https://lore.kernel.org/all/20260130132951.2714396-1-elver@google.com/
[mlir][PDL] PDLToPDLInterp: Use the pdl pattern name in the generated rewriter. (#149481)
Before, the rewriters generated by `convert-pdl-to-pdl-interp` had a
generic `"pdl_generated_rewriter"` name. With this change, the name from
the original pdl pattern is kept for the rewriter. This makes it easier
to relate the two.
---------
Co-authored-by: Mehdi Amini <joker-eph at gmail.com>
AMDGPU: Implement computeKnownFPClass for llvm.amdgcn.trig.preop
Surprisingly this doesn't consider the special cases, and literally
just extracts the exponent and proceeds as normal.
AMDGPU: Fix incorrect fold of undef for llvm.amdgcn.trig.preop
We were folding undef inputs to qnan which is incorrect. The instruction
never returns nan. Out of bounds segment select will return 0, so fold
undef segment to 0.
[OpenMP][MLIR] Modify lowering OpenMP Dialect lowering to support attach mapping
This PR adjusts the LLVM-IR lowering to support the new attach map type that the runtime
uses to link data and pointer together, this swaps the mapping from the older
OMP_MAP_PTR_AND_OBJ map type in most cases and allows slightly more complicated ref_ptr/ptee
and attach semantics.