diff options
| author | 2016-09-03 22:46:54 +0000 | |
|---|---|---|
| committer | 2016-09-03 22:46:54 +0000 | |
| commit | b5500b9ca0102f1ccaf32f0e77e96d0739aded9b (patch) | |
| tree | e1b7ebb5a0231f9e6d8d3f6f719582cebd64dc98 /gnu/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp | |
| parent | clarify purpose of src/gnu/ directory. (diff) | |
| download | wireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.tar.xz wireguard-openbsd-b5500b9ca0102f1ccaf32f0e77e96d0739aded9b.zip | |
Use the space freed up by sparc and zaurus to import LLVM.
ok hackroom@
Diffstat (limited to 'gnu/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp')
| -rw-r--r-- | gnu/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gnu/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp b/gnu/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp new file mode 100644 index 00000000000..9dbe4dbc56d --- /dev/null +++ b/gnu/llvm/unittests/Transforms/Utils/ValueMapperTest.cpp @@ -0,0 +1,58 @@ +//===- ValueMapper.cpp - Unit tests for ValueMapper -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Metadata.h" +#include "llvm/Transforms/Utils/ValueMapper.h" +#include "gtest/gtest.h" + +using namespace llvm; + +namespace { + +TEST(ValueMapperTest, MapMetadataUnresolved) { + LLVMContext Context; + TempMDTuple T = MDTuple::getTemporary(Context, None); + + ValueToValueMapTy VM; + EXPECT_EQ(T.get(), MapMetadata(T.get(), VM, RF_NoModuleLevelChanges)); +} + +TEST(ValueMapperTest, MapMetadataDistinct) { + LLVMContext Context; + auto *D = MDTuple::getDistinct(Context, None); + + { + // The node should be cloned. + ValueToValueMapTy VM; + EXPECT_NE(D, MapMetadata(D, VM, RF_None)); + } + { + // The node should be moved. + ValueToValueMapTy VM; + EXPECT_EQ(D, MapMetadata(D, VM, RF_MoveDistinctMDs)); + } +} + +TEST(ValueMapperTest, MapMetadataDistinctOperands) { + LLVMContext Context; + Metadata *Old = MDTuple::getDistinct(Context, None); + auto *D = MDTuple::getDistinct(Context, Old); + ASSERT_EQ(Old, D->getOperand(0)); + + Metadata *New = MDTuple::getDistinct(Context, None); + ValueToValueMapTy VM; + VM.MD()[Old].reset(New); + + // Make sure operands are updated. + EXPECT_EQ(D, MapMetadata(D, VM, RF_MoveDistinctMDs)); + EXPECT_EQ(New, D->getOperand(0)); +} + +} |
