[mlir][arith] Fix folds crashing on dynamic-shaped tensors (#212072)
`Builder::getZeroAttr` asserts when asked to build a constant of a
ranked tensor with a dynamic shape (`DenseElementsAttr` requires a
static shape). Three self-identity folds/patterns reached it without a
guard and aborted on dynamic-shaped operands:
```mlir
arith.xori %x, %x : tensor<?xi32>
arith.subui_extended %x, %x : tensor<?xi32>, tensor<?xi1>
arith.subi (arith.subi %a, %b), %a : tensor<?xi32> (SubISubILHSRHSLHS)
```
Guard each with a static-shape check (as `arith.subi(x,x)` already does)
so they leave the op unfolded instead of crashing. The TableGen pattern
gets a new `IsScalarOrHasStaticShape` constraint.
Signed-off-by: Víctor Pérez Carrasco <victor.pc.upm at gmail.com>
[ELF,SPARC] Support ABS and RELATIVE dynamic relocations (#212155)
... and test some previously uncovered GOT relocation types.
Test convention follows ppc32-*, which I added in 2019.
The SPARC psABI only defines Elf64_Rela. Add EM_SPARCV9 to getIsRela so
that dynamic relocations use .rela.dyn/.rela.plt instead of the
unsupported SHT_REL form.
Co-authored-by: Kirill A. Korinsky <kirill at korins.ky>
Co-authored-by: Kirill A. Korinsky <kirill at korins.ky>
[libc][test][NFC] Fix compiler warnings in libc tests (#212100)
Resolved compiler warnings in several libc unit and integration tests:
- Fixed -Wmissing-designated-field-initializers in localtime_r_test.cpp
by using zero-initialisation instead of partial designated initialisers.
- Fixed -Wimplicit-int-conversion in sigaltstack_test.cpp by explicitly
casting the loop index to uint8_t.
- Fixed -Wunused-parameter in pthread_barrier_test.cpp by omitting
unused parameter names in function definitions.
Assisted-by: Automated tooling, human reviewed.
[ELF] Fix dynamic relocations in .eh_frame (#210967)
scanEhSection translates input offsets to merged .eh_frame offsets
before creating dynamic relocations. DynamicReloc::getOffset translated
them a second time through EhInputSection.
Use the synthetic parent for already merged offsets, and use the
finalized relocation offset when verifying applied addends.
---------
Co-authored-by: Fangrui Song <i at maskray.me>
[CIR][NFC] Reorganize coroutine tests (#211152)
Move the coroutine tests into a dedicated CodeGenCoroutines directory.
This is a test only reorganization in preparation for upcoming
coroutine-related changes.
Revert "[analyzer] Model strchr/strrchr/memchr/strstr/strpbrk/strchrnul (#207267)"
This reverts commit a34cb573eae65f48f0e51147289e042a86b55d16.
This feature caused some issues (#209905), so the best course of
action is to postpone it to clang-24 and revert from this branch.
The #210154 tried to fix the surfaced issue, and considered to nominate
it for backport in #211832, but ultimately we had to revert it from
main in #211857 - this confirms that probably the best action is to
revert the half-baked feature from the release branch.
This means that #203260 won't be fixed in clang-23, and that's fine.
Reapply "[VPlan] Re-use VPSlotTracker when printing recipes for costs (NFC)." (#209003) (#211763)
This reverts commit 4c7948d06c93e8d233cd4733fd4107f3b68bc7bc. The commit
always constructs slot on first use, to fix compile-time regressions in
release builds.
Original message:
VPRecipeBase::dump() constructs a fresh VPSlotTracker instance on each
call. VPSlotTracker construction requires iterating over all recipes in
the plan, to number all VPValues.
To avoid doing lots of unnecessary work when printing VPlan costs,
construct a shared VPSlotTracker in VPCostContext, re-used by all
prints.
This can speed up debug output for large loops.
PR: https://github.com/llvm/llvm-project/pull/203386
[ConstraintElim] Re-organize tests with decomposition failures (NFC). (#212130)
Add more tests for failed decomposition, consolidate them in
partial-decomposition.ll.
[mlir][arith] Fold trivial integer division and remainder (#212074)
Add value-preserving folds mirroring LLVM's InstructionSimplify for the
integer division and remainder ops:
```
divui/divsi/ceildivui/ceildivsi/floordivsi(0, x) -> 0
divui/divsi/ceildivui/ceildivsi/floordivsi(x, x) -> 1
remui/remsi(0, x) -> 0
remui/remsi(x, x) -> 0
```
The self and zero-dividend cases are valid refinements because division
or remainder by zero is undefined behaviour; no overflow flags are
required. The folds return a scalar or splat constant and bail out on
shaped types with a dynamic shape.
Folding `x / 0` and `x % 0` to poison is left as a TODO: it would make
the arith dialect depend on the ub dialect to materialize `ub.poison`.
[20 lines not shown]
[libc++][chrono] Implement LWG 4274: Allow chrono::hh_mm_ss to be constructed from unsigned durations (#209686)
**_Implementation details_**:
- Use `is_unsigned_v` instead of `numeric_limits<Rep>::is_signed`, which
is used by `chrono::abs`. `numeric_limits<Rep>::is_signed` may return
false when a custom `Rep` does not specialize `numeric_limits`. Relying
on it to detect the unsigned case could therefore be unreliable for such
a type. `is_unsigned_v` instead gives a compile-time path for built-in
unsigned types, while the sign check keeps signed types correct.
- The constructor calls `__abs_d` four times because each member is
initialized separately. This should not affect runtime performance
because the compiler should inline `__abs_d` and eliminate the repeated
calculations. We could use another helper function or helper class to
explicitly compute the absolute duration only once. However, this would
add extra glue code, and the added complexity is not worthwhile I think.
---------
Co-authored-by: A. Jiang <de34 at live.cn>
[libc++][NFC] Inline fstream functions into the class body (#211738)
The `fstream` member functions are all really short, so inlining them
removes quite a bit of boiler plate code.
[flang][OpenMP] Split DEFAULT into DEFAULT(dsa) and DEFAULT(variant)
The 5.0 and 5.1 specs used DEFAULT clause for what is now OTHERWISE.
Separate these two claues to be able to specify their properties
independently.