]> granicus.if.org Git - llvm/commit
Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...>
authorSerge Guelton <sguelton@quarkslab.com>
Sun, 20 Jan 2019 21:19:56 +0000 (21:19 +0000)
committerSerge Guelton <sguelton@quarkslab.com>
Sun, 20 Jan 2019 21:19:56 +0000 (21:19 +0000)
commitcb39a85070daf4a13a9596aa5b2c6fa261a2a36b
treed2e1225d0b62d25028db0839c49ec09dfda142fd
parentc1ef295d680d2bd7e934118f59db1ad3ceadd750
Replace llvm::isPodLike<...>  by llvm::is_trivially_copyable<...>

As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for
isPodLike<std::pair<...>> did not match the expectation of
std::is_trivially_copyable which makes the memcpy optimization invalid.

This patch renames the llvm::isPodLike trait into llvm::is_trivially_copyable.
Unfortunately std::is_trivially_copyable is not portable across compiler / STL
versions. So a portable version is provided too.

Note that the following specialization were invalid:

    std::pair<T0, T1>
    llvm::Optional<T>

Tests have been added to assert that former specialization are respected by the
standard usage of llvm::is_trivially_copyable, and that when a decent version
of std::is_trivially_copyable is available, llvm::is_trivially_copyable is
compared to std::is_trivially_copyable.

As of this patch, llvm::Optional is no longer considered trivially copyable,
even if T is. This is to be fixed in a later patch, as it has impact on a
long-running bug (see r347004)

Note that GCC warns about this UB, but this got silented by https://reviews.llvm.org/D50296.

Differential Revision: https://reviews.llvm.org/D54472

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351701 91177308-0d34-0410-b5e6-96231b3b80d8
34 files changed:
docs/ProgrammersManual.rst
include/llvm/ADT/ArrayRef.h
include/llvm/ADT/DenseMap.h
include/llvm/ADT/ImmutableList.h
include/llvm/ADT/Optional.h
include/llvm/ADT/PointerIntPair.h
include/llvm/ADT/SmallVector.h
include/llvm/ADT/StringRef.h
include/llvm/ADT/bit.h
include/llvm/Analysis/BlockFrequencyInfoImpl.h
include/llvm/Bitcode/BitCodes.h
include/llvm/CodeGen/DIE.h
include/llvm/CodeGen/RegisterPressure.h
include/llvm/CodeGen/ScheduleDAG.h
include/llvm/CodeGen/SelectionDAGNodes.h
include/llvm/CodeGen/SlotIndexes.h
include/llvm/CodeGen/TargetPassConfig.h
include/llvm/IR/CFG.h
include/llvm/IR/ValueHandle.h
include/llvm/MC/MCInst.h
include/llvm/Support/ScaledNumber.h
include/llvm/Support/type_traits.h
lib/Transforms/Scalar/SROA.cpp
tools/llvm-diff/DifferenceEngine.cpp
unittests/ADT/ArrayRefTest.cpp
unittests/ADT/ImmutableListTest.cpp
unittests/ADT/PointerIntPairTest.cpp
unittests/ADT/StringRefTest.cpp
unittests/Analysis/BlockFrequencyInfoTest.cpp
unittests/Bitcode/BitstreamReaderTest.cpp
unittests/CodeGen/CMakeLists.txt
unittests/CodeGen/MachineInstrTest.cpp
unittests/IR/CFGBuilder.cpp
unittests/Support/ScaledNumberTest.cpp