diff options
| author | Serge Guelton <sguelton@quarkslab.com> | 2019-01-20 21:19:56 +0000 |
|---|---|---|
| committer | Serge Guelton <sguelton@quarkslab.com> | 2019-01-20 21:19:56 +0000 |
| commit | be88539b85204041f727ec6499315884b3d886b0 (patch) | |
| tree | c6fcb530c4555e3ea4efa1bbbeced22ed7572a57 /llvm/unittests/IR | |
| parent | 7ac79ed8f0b50640e2809b9f230f87f1b68baa53 (diff) | |
| download | bcm5719-llvm-be88539b85204041f727ec6499315884b3d886b0.tar.gz bcm5719-llvm-be88539b85204041f727ec6499315884b3d886b0.zip | |
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
llvm-svn: 351701
Diffstat (limited to 'llvm/unittests/IR')
| -rw-r--r-- | llvm/unittests/IR/CFGBuilder.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/unittests/IR/CFGBuilder.cpp b/llvm/unittests/IR/CFGBuilder.cpp index ca7a0555dd0..a2016f7e6cb 100644 --- a/llvm/unittests/IR/CFGBuilder.cpp +++ b/llvm/unittests/IR/CFGBuilder.cpp @@ -8,6 +8,7 @@ #include "CFGBuilder.h" +#include "llvm/IR/CFG.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Support/Debug.h" @@ -265,3 +266,11 @@ TEST(CFGBuilder, Rebuild) { EXPECT_TRUE(isa<SwitchInst>(B.getOrAddBlock("c")->getTerminator())); EXPECT_TRUE(isa<SwitchInst>(B.getOrAddBlock("d")->getTerminator())); } + +static_assert(is_trivially_copyable<succ_iterator>::value, + "trivially copyable"); +static_assert(is_trivially_copyable<succ_const_iterator>::value, + "trivially copyable"); +static_assert(is_trivially_copyable<succ_range>::value, "trivially copyable"); +static_assert(is_trivially_copyable<succ_const_range>::value, + "trivially copyable"); |

