From be88539b85204041f727ec6499315884b3d886b0 Mon Sep 17 00:00:00 2001 From: Serge Guelton Date: Sun, 20 Jan 2019 21:19:56 +0000 Subject: Replace llvm::isPodLike<...> by llvm::is_trivially_copyable<...> As noted in https://bugs.llvm.org/show_bug.cgi?id=36651, the specialization for isPodLike> 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 llvm::Optional 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 llvm-svn: 351701 --- llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp') diff --git a/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp b/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp index 5572f5ba597..2aeba947a74 100644 --- a/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp +++ b/llvm/unittests/Analysis/BlockFrequencyInfoTest.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/BlockFrequencyInfo.h" +#include "llvm/Analysis/BlockFrequencyInfoImpl.h" #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/AsmParser/Parser.h" @@ -90,5 +91,8 @@ TEST_F(BlockFrequencyInfoTest, Basic) { EXPECT_EQ(BFI.getBlockFreq(BB3).getFrequency(), BB3Freq); } +static_assert(is_trivially_copyable::value, + "trivially copyable"); + } // end anonymous namespace } // end namespace llvm -- cgit v1.2.3