SuccessChanges

Summary

  1. [SVE] Replace / operator in TypeSize/ElementCount with divideCoefficientBy (details)
  2. [Coroutines] Reuse storage for local variables with non-overlapping lifetimes (details)
  3. [lldb] Remove nothreadallow from SWIG's __str__ wrappers to work around a Python>=3.7 crash (details)
  4. [ARM] Expand cannotInsertWDLSTPBetween to the last instruction (details)
  5. [ARM][MVE] tail-predication: overflow checks for elementcount, cont'd (details)
  6. [Coroutines] Remove unused includes. NFC. (details)
  7. [obj2yaml][yaml2obj] - Stop recognizing SHT_MIPS_ABIFLAGS on non-MIPS targets. (details)
  8. [lldb] Reference STL types in import-std-module tests (details)
  9. [yaml2obj][obj2yaml] - Add a support for SHT_ARM_EXIDX section. (details)
  10. [InstCombine] Add tests for vector rotate by constants with undefs. (details)
  11. [AMDGPU] Split R600 and GCN bfi patterns (details)
  12. [AMDGPU] Make bfi patterns divergence-aware (details)
  13. [AMDGPU] Add bfi immediate pattern (details)
Commit bafdd11326a46421b68f68c794fd189c77a32e15 by david.sherwood
[SVE] Replace / operator in TypeSize/ElementCount with divideCoefficientBy

After some recent upstream discussion we decided that it was best
to avoid having the / operator for both ElementCount and TypeSize,
since this could give the impression that these classes can be used
in the same way as basic integer integer types. However, division
for scalable types is a bit odd because we are only dividing the
minimum quantity by a value, as opposed to something like:

  (MinSize * Vscale) / SomeValue

This is why when performing division it's important the caller
first establishes whether the operation makes sense, perhaps by
calling isKnownMultipleOf() prior to division. The caller must now
explictly call divideCoefficientBy() on the class to perform the
operation.

Differential Revision: https://reviews.llvm.org/D87700
The file was modifiedllvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
The file was modifiedclang/lib/CodeGen/CGBuiltin.cpp
The file was modifiedllvm/include/llvm/Support/MachineValueType.h
The file was modifiedllvm/include/llvm/Support/TypeSize.h
The file was modifiedllvm/include/llvm/CodeGen/ValueTypes.h
The file was modifiedllvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
The file was modifiedllvm/include/llvm/IR/DerivedTypes.h
The file was modifiedllvm/unittests/IR/VectorTypesTest.cpp
The file was modifiedllvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
The file was modifiedllvm/lib/CodeGen/TargetLoweringBase.cpp
The file was modifiedllvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Commit b3a722e66b75328ab5e2eb5c8572022cb083855b by yedeng.yd
[Coroutines] Reuse storage for local variables with non-overlapping lifetimes

bug 45566 shows the process of building coroutine frame won't consider
that the lifetimes of different local variables are not overlapped,
which means the compiler could generates smaller frame.

This patch calculate the lifetime range of each alloca by StackLifetime
class. Then the patch build non-overlapped sets for allocas whose
lifetime ranges are not overlapped. We use the largest type in a
non-overlapped set as the field type in the frame. In insertSpills
process, if we find the type of field is not the same with the alloca,
we cast the pointer to the field type to the pointer to the alloca type.
Since the lifetime range of alloca in one non-overlapped set is not
overlapped with each other, it should be ok to reuse the storage space
in the frame.

Test plan: check-llvm, check-clang, cppcoro, folly

Reviewers: junparser, lxfind, modocache

Differential Revision: https://reviews.llvm.org/D87596
The file was modifiedllvm/lib/Transforms/Coroutines/CoroInternal.h
The file was addedllvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-03.ll
The file was modifiedllvm/include/llvm/Transforms/Coroutines.h
The file was addedllvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-01.ll
The file was modifiedllvm/lib/Transforms/Coroutines/CoroSplit.cpp
The file was modifiedllvm/lib/Transforms/Coroutines/Coroutines.cpp
The file was modifiedllvm/lib/Transforms/Coroutines/CMakeLists.txt
The file was modifiedllvm/lib/Passes/PassBuilder.cpp
The file was modifiedllvm/lib/Transforms/Coroutines/CoroFrame.cpp
The file was modifiedllvm/include/llvm/Transforms/Coroutines/CoroSplit.h
The file was addedllvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-00.ll
The file was addedllvm/test/Transforms/Coroutines/coro-frame-reuse-alloca-02.ll
Commit 070a1d562b303e564e40d831f6dc125793e19b38 by Raphael Isemann
[lldb] Remove nothreadallow from SWIG's __str__ wrappers to work around a Python>=3.7 crash

Usually when we enter a SWIG wrapper function from Python, SWIG automatically
adds a `Py_BEGIN_ALLOW_THREADS`/`Py_END_ALLOW_THREADS` around the call to the SB
API C++ function. This will ensure that Python's GIL is released when we enter
LLDB and locked again when we return to the wrapper code.

D51569 changed this behaviour but only for the generated `__str__` wrappers. The
added `nothreadallow` disables the injection of the GIL release/re-acquire code
and the GIL is now kept locked when entering LLDB and is expected to be still
locked when returning from the LLDB implementation. The main reason for that was
that back when D51569 landed the wrapper itself created a Python string. These
days it just creates a std::string and SWIG itself takes care of getting the GIL
and creating the Python string from the std::string, so that workaround isn't
necessary anymore.

This patch just removes `nothreadallow` so that our `__str__` functions now
behave like all other wrapper functions in that they release the GIL when
calling into the SB API implementation.

The motivation here is actually to work around another potential bug in LLDB.
When one calls into the LLDB SB API while holding the GIL and that call causes
LLDB to interpret some Python script via `ScriptInterpreterPython`, then the GIL
will be unlocked when the control flow returns from the SB API. In the case of
the `__str__` wrapper this would cause that the next call to a Python function
requiring the GIL would fail (as SWIG will not try to reacquire the GIL as it
isn't aware that LLDB removed it).

The reason for this unexpected GIL release seems to be a workaround for recent
Python versions:
```
    // The only case we should go further and acquire the GIL: it is unlocked.
    if (PyGILState_Check())
      return;
```

The early-exit here causes `InitializePythonRAII::m_was_already_initialized` to
be always false and that causes that `InitializePythonRAII`'s destructor always
directly unlocks the GIL via `PyEval_SaveThread`. I'm investigating how to
properly fix this bug in a follow up patch, but for now this straightforward
patch seems to be enough to unblock my other patches (and it also has the
benefit of removing this workaround).

The test for this is just a simple test for `std::deque` which has a synthetic
child provider implemented as a Python script. Inspecting the deque object will
cause `expect_expr` to create a string error message by calling
`str(deque_object)`. Printing the ValueObject causes the Python script for the
synthetic children to execute which then triggers the bug described above where
the GIL ends up being unlocked.

Reviewed By: JDevlieghere

Differential Revision: https://reviews.llvm.org/D88302
The file was addedlldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
The file was addedlldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/Makefile
The file was modifiedlldb/bindings/macros.swig
The file was addedlldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/main.cpp
Commit e4b9867cb69acc272157ef1baaecd9848ad18ecc by david.green
[ARM] Expand cannotInsertWDLSTPBetween to the last instruction

9d9a11c7be037 added this check for predicatable instructions between the
D/WLSTP and the loop's start, but it was missing the last instruction in
the block. Change it to use some iterators instead.

Differential Revision: https://reviews.llvm.org/D88354
The file was modifiedllvm/test/CodeGen/Thumb2/LowOverheadLoops/mov-operand.ll
The file was modifiedllvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
The file was modifiedllvm/test/CodeGen/Thumb2/LowOverheadLoops/it-block-mov.mir
Commit f39f92c1f610fcdfad74730a3e3df881e32a28c2 by sjoerd.meijer
[ARM][MVE] tail-predication: overflow checks for elementcount, cont'd

This is a reimplementation of the overflow checks for the elementcount,
i.e. the 2nd argument of intrinsic get.active.lane.mask. The element
count is lowered in each iteration of the tail-predicated loop, and
we must prove that this expression doesn't overflow.

Many thanks to Eli Friedman and Sam Parker for all their help with
this work.

Differential Revision: https://reviews.llvm.org/D88086
The file was modifiedllvm/test/CodeGen/Thumb2/LowOverheadLoops/tail-pred-const.ll
The file was modifiedllvm/lib/Target/ARM/MVETailPredication.cpp
The file was modifiedllvm/test/CodeGen/Thumb2/LowOverheadLoops/tail-pred-basic.ll
The file was removedllvm/test/CodeGen/Thumb2/LowOverheadLoops/tail-pred-forced.ll
Commit 7e5a356d2bd232267aac2484519ac2c5658eca08 by benny.kra
[Coroutines] Remove unused includes. NFC.
The file was modifiedllvm/include/llvm/Transforms/Coroutines/CoroSplit.h
The file was modifiedllvm/lib/Transforms/Coroutines/CoroSplit.cpp
Commit ea0f66e84856519e08b255fd1010d7f07ad0dabd by grimar
[obj2yaml][yaml2obj] - Stop recognizing SHT_MIPS_ABIFLAGS on non-MIPS targets.

Currently we are always recognizing the `SHT_MIPS_ABIFLAGS` section,
even on non-MIPS targets.

The problem of doing this is briefly discussed in D88228 which does the same for `SHT_ARM_EXIDX`:

"The problem is that `SHT_ARM_EXIDX` shares the value with `SHT_X86_64_UNWIND (0x70000001U)`.
We might have other machine specific conflicts, e.g.
`SHT_ARM_ATTRIBUTES` vs `SHT_MSP430_ATTRIBUTES` vs `SHT_RISCV_ATTRIBUTES (0x70000003U)`."

I think we should only recognize target specific sections when the machine type
matches. I.e. `SHT_MIPS_*` should be recognized only on `MIPS`, `SHT_ARM_*`
only on `ARM` etc.

This patch stops recognizing `SHT_MIPS_ABIFLAGS` on `non-MIPS` targets.

Note: I had to update `ScalarEnumerationTraits<ELFYAML::MIPS_ISA>::enumeration`, because
otherwise test crashes, calling `llvm_unreachable`.

Differential revision: https://reviews.llvm.org/D88294
The file was modifiedllvm/tools/obj2yaml/elf2yaml.cpp
The file was modifiedllvm/test/tools/yaml2obj/ELF/mips-abi-flags.yaml
The file was modifiedllvm/test/tools/obj2yaml/ELF/mips-abi-flags.yaml
The file was modifiedllvm/lib/ObjectYAML/ELFYAML.cpp
Commit cabee89bed69ce37c9e588f9190ed9c33f6bfdee by Raphael Isemann
[lldb] Reference STL types in import-std-module tests

With the recent patches to the ASTImporter that improve template type importing
(D87444), most of the import-std-module tests can now finally import the
type of the STL container they are testing. This patch removes most of the casts
that were added to simplify types to something the ASTImporter can import
(for example, std::vector<int>::size_type was casted to `size_t` until now).
Also adds the missing tests that require referencing the container type (for
example simply printing the whole container) as here we couldn't use a casting
workaround.

The only casts that remain are in the forward_list tests that reference
the iterator and the stack test. Both tests are still failing to import the
respective container type correctly (or crash while trying to import).
The file was modifiedlldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/sysroot/TestStdModuleSysroot.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/conflicts/TestStdModuleWithConflicts.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/forward_decl_from_module/TestForwardDeclFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/basic/TestImportStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/vector-bool/TestVectorBoolFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/unique_ptr/main.cpp
The file was modifiedlldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/vector/TestVectorFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/no-std-module/TestMissingStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/pair/TestPairFromStdModule.py
The file was modifiedlldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/main.cpp
Commit dab991716483f2b80bf8dbf8e7ba26ba3d49855d by grimar
[yaml2obj][obj2yaml] - Add a support for SHT_ARM_EXIDX section.

This adds the support for SHT_ARM_EXIDX sections to obj2yaml/yaml2obj tools.

SHT_ARM_EXIDX is a ARM specific index table filled with entries.
Each entry consists of two 4-bytes values (words).
(https://developer.arm.com/documentation/ihi0038/c/?lang=en#index-table-entries)

Differential revision: https://reviews.llvm.org/D88228
The file was addedllvm/test/tools/obj2yaml/ELF/arm-exidx-section.yaml
The file was modifiedllvm/tools/obj2yaml/elf2yaml.cpp
The file was modifiedllvm/include/llvm/ObjectYAML/ELFYAML.h
The file was modifiedllvm/lib/ObjectYAML/ELFYAML.cpp
The file was modifiedllvm/lib/ObjectYAML/ELFEmitter.cpp
The file was modifiedllvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test
The file was addedllvm/test/tools/yaml2obj/ELF/arm-exidx-section.yaml
Commit 0c671bfe00a120131c0fe070e5e7b7b613e823f1 by llvm-dev
[InstCombine] Add tests for vector rotate by constants with undefs.
The file was modifiedllvm/test/Transforms/InstCombine/rotate.ll
Commit 286d3fc7500dfa6a947b217d0e87d1764d2242b8 by jay.foad
[AMDGPU] Split R600 and GCN bfi patterns

This is in preparation for making the GCN patterns divergence-aware.
NFC.

Differential Revision: https://reviews.llvm.org/D88244
The file was modifiedllvm/lib/Target/AMDGPU/AMDGPUInstructions.td
The file was modifiedllvm/lib/Target/AMDGPU/EvergreenInstructions.td
The file was modifiedllvm/lib/Target/AMDGPU/SIInstructions.td
Commit 2806f586dca78756cc2fbadf09c0859dda4a760e by jay.foad
[AMDGPU] Make bfi patterns divergence-aware

This tends to increase code size but more importantly it reduces vgpr
usage, and could avoid costly readfirstlanes if the result needs to be
in an sgpr.

Differential Revision: https://reviews.llvm.org/D88245
The file was modifiedllvm/test/CodeGen/AMDGPU/bfi_int.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/insert_vector_dynelt.ll
The file was modifiedllvm/test/CodeGen/AMDGPU/insert_vector_elt.ll
The file was modifiedllvm/lib/Target/AMDGPU/SOPInstructions.td
The file was modifiedllvm/test/CodeGen/AMDGPU/insert_vector_elt.v2i16.ll
The file was modifiedllvm/lib/Target/AMDGPU/SIInstructions.td
Commit bab1a17ad7761ae61e5841c2fb905de59cb8c2da by jay.foad
[AMDGPU] Add bfi immediate pattern

Differential Revision: https://reviews.llvm.org/D88246
The file was modifiedllvm/test/CodeGen/AMDGPU/insert_vector_elt.v2i16.ll
The file was modifiedllvm/lib/Target/AMDGPU/SIInstructions.td
The file was modifiedllvm/test/CodeGen/AMDGPU/shrink-add-sub-constant.ll