[Support] Remove llvm::is_trivially_{copy/move}_constructible
authorFangrui Song <i@maskray.me>
Wed, 26 Jul 2023 00:21:16 +0000 (17:21 -0700)
committerTobias Hieta <tobias@hieta.se>
Thu, 27 Jul 2023 13:29:23 +0000 (15:29 +0200)
commitcd2570ae9cdd399e54af029cf1dc51350462d2fd
treec6e37d3fa536e83571843d2db97e79431de30946
parent52647ad0275c9bf76a78b6cb2575fd0be697819f
[Support] Remove llvm::is_trivially_{copy/move}_constructible

This restores D132311, which was reverted in
29c841ce93e087fa4e0c5f3abae94edd460bc24a (Sep 2022) due to certain files
not buildable with GCC 7.3.0. The previous attempt was reverted by
6cd9608fb37ca2418fb44b57ec955bb5efe10689 (Dec 2020).

This time, GCC 7.3.0 has existing build errors for a long time due to
structured bindings for many files, e.g.

```
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9098:13: error: cannot decompose class type ‘std::pair<llvm::Value*, const llvm::SCEV*>’: both it and it
s base class ‘std::pair<llvm::Value*, const llvm::SCEV*>’ have non-static data members
   for (auto [_, Stride] : Legal->getLAI()->getSymbolicStrides()) {
             ^~~~~~~~~~~
```

... and also some `error: duplicate initialization of` instances due to llvm/Transforms/IPO/Attributor.h.

---

GCC 7.5.0 has a bug that, without this change, certain `SmallVector` with a `std::pair` element type like `SmallVector<std::pair<Instruction * const, Info>, 0> X;` lead to spurious

```
/tmp/opt/gcc-7.5.0/include/c++/7.5.0/type_traits:878:48: error: constructor required before non-static data member for ‘...’ has been parsed
```

Switching to std::is_trivially_{copy/move}_constructible fixes the error.

(cherry picked from commit 6a684dbc4433a33e5f94fb15c9e378a2408021e0)
llvm/include/llvm/ADT/FunctionExtras.h
llvm/include/llvm/ADT/SmallVector.h
llvm/include/llvm/Support/type_traits.h
llvm/unittests/Support/TypeTraitsTest.cpp
mlir/lib/Dialect/SparseTensor/IR/Detail/TemplateExtras.h