From 4c5e43da7792f75567b693105cc53e3f1992ad98 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Wed, 8 Apr 2015 08:55:49 -0700 Subject: Update aosp/master llvm for rebase to r233350 Change-Id: I07d935f8793ee8ec6b7da003f6483046594bca49 --- unittests/ADT/APFloatTest.cpp | 7 +- unittests/ADT/APIntTest.cpp | 240 ++++++++++++++++++++++ unittests/ADT/ArrayRefTest.cpp | 28 +-- unittests/ADT/DeltaAlgorithmTest.cpp | 2 +- unittests/ADT/DenseMapTest.cpp | 1 + unittests/ADT/HashingTest.cpp | 1 - unittests/ADT/MapVectorTest.cpp | 25 +++ unittests/ADT/SCCIteratorTest.cpp | 4 +- unittests/ADT/SmallVectorTest.cpp | 19 ++ unittests/ADT/TripleTest.cpp | 10 + unittests/ADT/TwineTest.cpp | 10 + unittests/ADT/ilistTest.cpp | 3 +- unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp | 75 +++++++ unittests/ExecutionEngine/ExecutionEngineTest.cpp | 1 + unittests/IR/ConstantRangeTest.cpp | 65 +++++- unittests/IR/ConstantsTest.cpp | 4 +- unittests/IR/DebugInfoTest.cpp | 20 +- unittests/IR/IRBuilderTest.cpp | 6 +- unittests/IR/InstructionsTest.cpp | 30 +-- unittests/IR/LegacyPassManagerTest.cpp | 10 - unittests/IR/MetadataTest.cpp | 177 +++++++++++++++- unittests/Linker/LinkModulesTest.cpp | 5 +- unittests/Support/AlignOfTest.cpp | 6 + unittests/Support/Path.cpp | 43 ++++ unittests/Support/YAMLIOTest.cpp | 86 ++++++++ unittests/Transforms/IPO/LowerBitSets.cpp | 90 ++++++-- unittests/Transforms/Utils/CMakeLists.txt | 1 + unittests/Transforms/Utils/Cloning.cpp | 3 +- unittests/Transforms/Utils/ValueMapperTest.cpp | 27 +++ 29 files changed, 912 insertions(+), 87 deletions(-) create mode 100644 unittests/Transforms/Utils/ValueMapperTest.cpp (limited to 'unittests') diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp index 8b82fb2..a4445f6 100644 --- a/unittests/ADT/APFloatTest.cpp +++ b/unittests/ADT/APFloatTest.cpp @@ -13,6 +13,7 @@ #include "llvm/ADT/SmallVector.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" +#include #include #include @@ -1305,13 +1306,13 @@ TEST(APFloatTest, roundToIntegral) { EXPECT_EQ(-0.0, P.convertToDouble()); P = APFloat::getNaN(APFloat::IEEEdouble); P.roundToIntegral(APFloat::rmTowardZero); - EXPECT_TRUE(IsNAN(P.convertToDouble())); + EXPECT_TRUE(std::isnan(P.convertToDouble())); P = APFloat::getInf(APFloat::IEEEdouble); P.roundToIntegral(APFloat::rmTowardZero); - EXPECT_TRUE(IsInf(P.convertToDouble()) && P.convertToDouble() > 0.0); + EXPECT_TRUE(std::isinf(P.convertToDouble()) && P.convertToDouble() > 0.0); P = APFloat::getInf(APFloat::IEEEdouble, true); P.roundToIntegral(APFloat::rmTowardZero); - EXPECT_TRUE(IsInf(P.convertToDouble()) && P.convertToDouble() < 0.0); + EXPECT_TRUE(std::isinf(P.convertToDouble()) && P.convertToDouble() < 0.0); } diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp index 3b7ac5b..acdc1ec 100644 --- a/unittests/ADT/APIntTest.cpp +++ b/unittests/ADT/APIntTest.cpp @@ -209,6 +209,206 @@ TEST(APIntTest, i1) { } } +TEST(APIntTest, divrem_big1) { + // Tests KnuthDiv rare step D6 + APInt a{256, "1ffffffffffffffff", 16}; + APInt b{256, "1ffffffffffffffff", 16}; + APInt c{256, 0}; + + auto p = a * b + c; + auto q = p.udiv(a); + auto r = p.urem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::udivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.udiv(b); + r = p.urem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::udivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = p.sdiv(a); + r = p.srem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::sdivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.sdiv(b); + r = p.srem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::sdivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); +} + +TEST(APIntTest, divrem_big2) { + // Tests KnuthDiv rare step D6 + APInt a{1024, "111111ffffffffffffffff" + "ffffffffffffffffffffffffffffffff" + "fffffffffffffffffffffffffffffccf" + "ffffffffffffffffffffffffffffff00", 16}; + APInt b{1024, "112233ceff" + "cecece000000ffffffffffffffffffff" + "ffffffffffffffffffffffffffffffff" + "ffffffffffffffffffffffffffffffff" + "ffffffffffffffffffffffffffffff33", 16}; + APInt c{1024, 7919}; + + auto p = a * b + c; + auto q = p.udiv(a); + auto r = p.urem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::udivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.udiv(b); + r = p.urem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::udivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = p.sdiv(a); + r = p.srem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::sdivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.sdiv(b); + r = p.srem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::sdivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); +} + +TEST(APIntTest, divrem_big3) { + // Tests KnuthDiv case without shift + APInt a{256, "ffffffffffffff0000000", 16}; + APInt b{256, "80000001ffffffffffffffff", 16}; + APInt c{256, 4219}; + + auto p = a * b + c; + auto q = p.udiv(a); + auto r = p.urem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::udivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.udiv(b); + r = p.urem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::udivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = p.sdiv(a); + r = p.srem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::sdivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.sdiv(b); + r = p.srem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::sdivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); +} + +TEST(APIntTest, divrem_big4) { + // Tests heap allocation in divide() enfoced by huge numbers + auto a = APInt{4096, 1}.shl(2000); + auto b = APInt{4096, 5}.shl(2001); + auto c = APInt{4096, 4219*13}; + + auto p = a * b + c; + auto q = p.udiv(a); + auto r = p.urem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = APInt{1024, 0}; // test non-single word APInt conversion in divide() + r = APInt{1024, 0}; + APInt::udivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.udiv(b); + r = p.urem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = APInt{1024, 0}; + r = APInt{1024, 0}; + APInt::udivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = p.sdiv(a); + r = p.srem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = APInt{1024, 0}; + r = APInt{1024, 0}; + APInt::sdivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.sdiv(b); + r = p.srem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = APInt{1024, 0}; + r = APInt{1024, 0}; + APInt::sdivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); +} + +TEST(APIntTest, divrem_big5) { + // Tests one word divisor case of divide() + auto a = APInt{1024, 19}.shl(811); + auto b = APInt{1024, 4356013}; // one word + auto c = APInt{1024, 1}; + + auto p = a * b + c; + auto q = p.udiv(a); + auto r = p.urem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::udivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.udiv(b); + r = p.urem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::udivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + q = p.sdiv(a); + r = p.srem(a); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + APInt::sdivrem(p, a, q, r); + EXPECT_EQ(q, b); + EXPECT_EQ(r, c); + q = p.sdiv(b); + r = p.srem(b); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); + APInt::sdivrem(p, b, q, r); + EXPECT_EQ(q, a); + EXPECT_EQ(r, c); +} + TEST(APIntTest, fromString) { EXPECT_EQ(APInt(32, 0), APInt(32, "0", 2)); EXPECT_EQ(APInt(32, 1), APInt(32, "1", 2)); @@ -678,6 +878,46 @@ TEST(APIntTest, nearestLogBase2) { EXPECT_EQ(A9.nearestLogBase2(), UINT32_MAX); } +TEST(APIntTest, IsSplat) { + APInt A(32, 0x01010101); + EXPECT_FALSE(A.isSplat(1)); + EXPECT_FALSE(A.isSplat(2)); + EXPECT_FALSE(A.isSplat(4)); + EXPECT_TRUE(A.isSplat(8)); + EXPECT_TRUE(A.isSplat(16)); + EXPECT_TRUE(A.isSplat(32)); + + APInt B(24, 0xAAAAAA); + EXPECT_FALSE(B.isSplat(1)); + EXPECT_TRUE(B.isSplat(2)); + EXPECT_TRUE(B.isSplat(4)); + EXPECT_TRUE(B.isSplat(8)); + EXPECT_TRUE(B.isSplat(24)); + + APInt C(24, 0xABAAAB); + EXPECT_FALSE(C.isSplat(1)); + EXPECT_FALSE(C.isSplat(2)); + EXPECT_FALSE(C.isSplat(4)); + EXPECT_FALSE(C.isSplat(8)); + EXPECT_TRUE(C.isSplat(24)); + + APInt D(32, 0xABBAABBA); + EXPECT_FALSE(D.isSplat(1)); + EXPECT_FALSE(D.isSplat(2)); + EXPECT_FALSE(D.isSplat(4)); + EXPECT_FALSE(D.isSplat(8)); + EXPECT_TRUE(D.isSplat(16)); + EXPECT_TRUE(D.isSplat(32)); + + APInt E(32, 0); + EXPECT_TRUE(E.isSplat(1)); + EXPECT_TRUE(E.isSplat(2)); + EXPECT_TRUE(E.isSplat(4)); + EXPECT_TRUE(E.isSplat(8)); + EXPECT_TRUE(E.isSplat(16)); + EXPECT_TRUE(E.isSplat(32)); +} + #if defined(__clang__) // Disable the pragma warning from versions of Clang without -Wself-move #pragma clang diagnostic push diff --git a/unittests/ADT/ArrayRefTest.cpp b/unittests/ADT/ArrayRefTest.cpp index 70f8208..6955036 100644 --- a/unittests/ADT/ArrayRefTest.cpp +++ b/unittests/ADT/ArrayRefTest.cpp @@ -57,24 +57,24 @@ TEST(ArrayRefTest, DropBack) { TEST(ArrayRefTest, Equals) { static const int A1[] = {1, 2, 3, 4, 5, 6, 7, 8}; ArrayRef AR1(A1); - EXPECT_TRUE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 8)); - EXPECT_FALSE(AR1.equals(8, 1, 2, 4, 5, 6, 6, 7)); - EXPECT_FALSE(AR1.equals(2, 4, 5, 6, 6, 7, 8, 1)); - EXPECT_FALSE(AR1.equals(0, 1, 2, 4, 5, 6, 6, 7)); - EXPECT_FALSE(AR1.equals(1, 2, 42, 4, 5, 6, 7, 8)); - EXPECT_FALSE(AR1.equals(42, 2, 3, 4, 5, 6, 7, 8)); - EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 42)); - EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7)); - EXPECT_FALSE(AR1.equals(1, 2, 3, 4, 5, 6, 7, 8, 9)); + EXPECT_TRUE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 8})); + EXPECT_FALSE(AR1.equals({8, 1, 2, 4, 5, 6, 6, 7})); + EXPECT_FALSE(AR1.equals({2, 4, 5, 6, 6, 7, 8, 1})); + EXPECT_FALSE(AR1.equals({0, 1, 2, 4, 5, 6, 6, 7})); + EXPECT_FALSE(AR1.equals({1, 2, 42, 4, 5, 6, 7, 8})); + EXPECT_FALSE(AR1.equals({42, 2, 3, 4, 5, 6, 7, 8})); + EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 42})); + EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7})); + EXPECT_FALSE(AR1.equals({1, 2, 3, 4, 5, 6, 7, 8, 9})); ArrayRef AR1a = AR1.drop_back(); - EXPECT_TRUE(AR1a.equals(1, 2, 3, 4, 5, 6, 7)); - EXPECT_FALSE(AR1a.equals(1, 2, 3, 4, 5, 6, 7, 8)); + EXPECT_TRUE(AR1a.equals({1, 2, 3, 4, 5, 6, 7})); + EXPECT_FALSE(AR1a.equals({1, 2, 3, 4, 5, 6, 7, 8})); ArrayRef AR1b = AR1a.slice(2, 4); - EXPECT_TRUE(AR1b.equals(3, 4, 5, 6)); - EXPECT_FALSE(AR1b.equals(2, 3, 4, 5, 6)); - EXPECT_FALSE(AR1b.equals(3, 4, 5, 6, 7)); + EXPECT_TRUE(AR1b.equals({3, 4, 5, 6})); + EXPECT_FALSE(AR1b.equals({2, 3, 4, 5, 6})); + EXPECT_FALSE(AR1b.equals({3, 4, 5, 6, 7})); } TEST(ArrayRefTest, EmptyEquals) { diff --git a/unittests/ADT/DeltaAlgorithmTest.cpp b/unittests/ADT/DeltaAlgorithmTest.cpp index a1884cd..a33f2b4 100644 --- a/unittests/ADT/DeltaAlgorithmTest.cpp +++ b/unittests/ADT/DeltaAlgorithmTest.cpp @@ -32,7 +32,7 @@ std::ostream &operator<<(std::ostream &OS, namespace { -class FixedDeltaAlgorithm : public DeltaAlgorithm { +class FixedDeltaAlgorithm final : public DeltaAlgorithm { changeset_ty FailingSet; unsigned NumTests; diff --git a/unittests/ADT/DenseMapTest.cpp b/unittests/ADT/DenseMapTest.cpp index f497983..9780777 100644 --- a/unittests/ADT/DenseMapTest.cpp +++ b/unittests/ADT/DenseMapTest.cpp @@ -46,6 +46,7 @@ public: CtorTester(const CtorTester &Arg) : Value(Arg.Value) { EXPECT_TRUE(Constructed.insert(this).second); } + CtorTester &operator=(const CtorTester &) = default; ~CtorTester() { EXPECT_EQ(1u, Constructed.erase(this)); } diff --git a/unittests/ADT/HashingTest.cpp b/unittests/ADT/HashingTest.cpp index 34eb5a5..b28561b 100644 --- a/unittests/ADT/HashingTest.cpp +++ b/unittests/ADT/HashingTest.cpp @@ -33,7 +33,6 @@ struct LargeTestInteger { uint64_t arr[8]; }; struct NonPOD { uint64_t x, y; NonPOD(uint64_t x, uint64_t y) : x(x), y(y) {} - ~NonPOD() {} friend hash_code hash_value(const NonPOD &obj) { return hash_combine(obj.x, obj.y); } diff --git a/unittests/ADT/MapVectorTest.cpp b/unittests/ADT/MapVectorTest.cpp index 2caa8c7..ff84642 100644 --- a/unittests/ADT/MapVectorTest.cpp +++ b/unittests/ADT/MapVectorTest.cpp @@ -14,6 +14,31 @@ using namespace llvm; +TEST(MapVectorTest, swap) { + MapVector MV1, MV2; + std::pair::iterator, bool> R; + + R = MV1.insert(std::make_pair(1, 2)); + ASSERT_EQ(R.first, MV1.begin()); + EXPECT_EQ(R.first->first, 1); + EXPECT_EQ(R.first->second, 2); + EXPECT_TRUE(R.second); + + EXPECT_FALSE(MV1.empty()); + EXPECT_TRUE(MV2.empty()); + MV2.swap(MV1); + EXPECT_TRUE(MV1.empty()); + EXPECT_FALSE(MV2.empty()); + + auto I = MV1.find(1); + ASSERT_EQ(MV1.end(), I); + + I = MV2.find(1); + ASSERT_EQ(I, MV2.begin()); + EXPECT_EQ(I->first, 1); + EXPECT_EQ(I->second, 2); +} + TEST(MapVectorTest, insert_pop) { MapVector MV; std::pair::iterator, bool> R; diff --git a/unittests/ADT/SCCIteratorTest.cpp b/unittests/ADT/SCCIteratorTest.cpp index 3f1ba1c..da8c044 100644 --- a/unittests/ADT/SCCIteratorTest.cpp +++ b/unittests/ADT/SCCIteratorTest.cpp @@ -39,8 +39,6 @@ public: NodeSubset() : Elements(0) { assert(N <= sizeof(BitVector)*CHAR_BIT && "Graph too big!"); } - /// NodeSubset - Copy constructor. - NodeSubset(const NodeSubset &other) : Elements(other.Elements) {} /// Comparison operators. bool operator==(const NodeSubset &other) const { @@ -252,7 +250,7 @@ TEST(SCCIteratorTest, AllSmallGraphs) { typedef Graph GT; /// Enumerate all graphs using NUM_GRAPHS bits. - assert(NUM_GRAPHS < sizeof(unsigned) * CHAR_BIT && "Too many graphs!"); + static_assert(NUM_GRAPHS < sizeof(unsigned) * CHAR_BIT, "Too many graphs!"); for (unsigned GraphDescriptor = 0; GraphDescriptor < (1U << NUM_GRAPHS); ++GraphDescriptor) { GT G; diff --git a/unittests/ADT/SmallVectorTest.cpp b/unittests/ADT/SmallVectorTest.cpp index 2bbb4ed..97ff90b 100644 --- a/unittests/ADT/SmallVectorTest.cpp +++ b/unittests/ADT/SmallVectorTest.cpp @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Compiler.h" #include "gtest/gtest.h" @@ -906,4 +907,22 @@ TEST(SmallVectorTest, EmplaceBack) { } } +TEST(SmallVectorTest, InitializerList) { + SmallVector V1 = {}; + EXPECT_TRUE(V1.empty()); + V1 = {0, 0}; + EXPECT_TRUE(makeArrayRef(V1).equals({0, 0})); + V1 = {-1, -1}; + EXPECT_TRUE(makeArrayRef(V1).equals({-1, -1})); + + SmallVector V2 = {1, 2, 3, 4}; + EXPECT_TRUE(makeArrayRef(V2).equals({1, 2, 3, 4})); + V2.assign({4}); + EXPECT_TRUE(makeArrayRef(V2).equals({4})); + V2.append({3, 2}); + EXPECT_TRUE(makeArrayRef(V2).equals({4, 3, 2})); + V2.insert(V2.begin() + 1, 5); + EXPECT_TRUE(makeArrayRef(V2).equals({4, 5, 3, 2})); +} + } // end namespace diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index 1f9aa32..1113bb6 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -159,6 +159,12 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); EXPECT_EQ(Triple::UnknownOS, T.getOS()); + T = Triple("x86_64-unknown-cloudabi"); + EXPECT_EQ(Triple::x86_64, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::CloudABI, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("huh"); EXPECT_EQ(Triple::UnknownArch, T.getArch()); } @@ -663,6 +669,10 @@ TEST(TripleTest, getARMCPUForArch) { EXPECT_STREQ("cortex-a8", Triple.getARMCPUForArch()); EXPECT_STREQ("swift", Triple.getARMCPUForArch("armv7s")); } + { + llvm::Triple Triple("arm--nacl"); + EXPECT_STREQ("cortex-a8", Triple.getARMCPUForArch("arm")); + } } } diff --git a/unittests/ADT/TwineTest.cpp b/unittests/ADT/TwineTest.cpp index 39d3b56..9683e97 100644 --- a/unittests/ADT/TwineTest.cpp +++ b/unittests/ADT/TwineTest.cpp @@ -29,6 +29,7 @@ TEST(TwineTest, Construction) { EXPECT_EQ("hi", Twine(StringRef("hi")).str()); EXPECT_EQ("hi", Twine(StringRef(std::string("hi"))).str()); EXPECT_EQ("hi", Twine(StringRef("hithere", 2)).str()); + EXPECT_EQ("hi", Twine(SmallString<4>("hi")).str()); } TEST(TwineTest, Numbers) { @@ -62,6 +63,10 @@ TEST(TwineTest, Concat) { repr(Twine("hi").concat(Twine()))); EXPECT_EQ("(Twine cstring:\"hi\" empty)", repr(Twine().concat(Twine("hi")))); + EXPECT_EQ("(Twine smallstring:\"hi\" empty)", + repr(Twine().concat(Twine(SmallString<5>("hi"))))); + EXPECT_EQ("(Twine smallstring:\"hey\" cstring:\"there\")", + repr(Twine(SmallString<7>("hey")).concat(Twine("there")))); // Concatenation of unary ropes. EXPECT_EQ("(Twine cstring:\"a\" cstring:\"b\")", @@ -72,6 +77,8 @@ TEST(TwineTest, Concat) { repr(Twine("a").concat(Twine("b")).concat(Twine("c")))); EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine cstring:\"b\" cstring:\"c\"))", repr(Twine("a").concat(Twine("b").concat(Twine("c"))))); + EXPECT_EQ("(Twine cstring:\"a\" rope:(Twine smallstring:\"b\" cstring:\"c\"))", + repr(Twine("a").concat(Twine(SmallString<3>("b")).concat(Twine("c"))))); } TEST(TwineTest, toNullTerminatedStringRef) { @@ -79,6 +86,9 @@ TEST(TwineTest, toNullTerminatedStringRef) { EXPECT_EQ(0, *Twine("hello").toNullTerminatedStringRef(storage).end()); EXPECT_EQ(0, *Twine(StringRef("hello")).toNullTerminatedStringRef(storage).end()); + EXPECT_EQ(0, *Twine(SmallString<11>("hello")) + .toNullTerminatedStringRef(storage) + .end()); } // I suppose linking in the entire code generator to add a unit test to check diff --git a/unittests/ADT/ilistTest.cpp b/unittests/ADT/ilistTest.cpp index 44442eb..9127b05 100644 --- a/unittests/ADT/ilistTest.cpp +++ b/unittests/ADT/ilistTest.cpp @@ -21,7 +21,8 @@ struct Node : ilist_node { int Value; Node() {} - Node(int _Value) : Value(_Value) {} + Node(int Value) : Value(Value) {} + Node(const Node&) = default; ~Node() { Value = -1; } }; diff --git a/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp b/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp index 4521132..371e2af 100644 --- a/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp +++ b/unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp @@ -8,8 +8,12 @@ //===----------------------------------------------------------------------===// #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" +#include "llvm/ADT/SmallString.h" #include "llvm/Support/Dwarf.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/LEB128.h" #include "gtest/gtest.h" +#include using namespace llvm; using namespace dwarf; @@ -46,4 +50,75 @@ TEST(DWARFFormValue, FormClass) { EXPECT_TRUE(isFormClass(DW_FORM_ref_sig8, DWARFFormValue::FC_Reference)); } +template +DWARFFormValue createDataXFormValue(uint16_t Form, RawTypeT Value) { + char Raw[sizeof(RawTypeT)]; + memcpy(Raw, &Value, sizeof(RawTypeT)); + uint32_t Offset = 0; + DWARFFormValue Result(Form); + DataExtractor Data(StringRef(Raw, sizeof(RawTypeT)), + sys::IsLittleEndianHost, sizeof(void*)); + Result.extractValue(Data, &Offset, nullptr); + return Result; +} + +DWARFFormValue createULEBFormValue(uint64_t Value) { + SmallString<10> RawData; + raw_svector_ostream OS(RawData); + encodeULEB128(Value, OS); + uint32_t Offset = 0; + DWARFFormValue Result(DW_FORM_udata); + DataExtractor Data(OS.str(), sys::IsLittleEndianHost, sizeof(void*)); + Result.extractValue(Data, &Offset, nullptr); + return Result; +} + +DWARFFormValue createSLEBFormValue(int64_t Value) { + SmallString<10> RawData; + raw_svector_ostream OS(RawData); + encodeSLEB128(Value, OS); + uint32_t Offset = 0; + DWARFFormValue Result(DW_FORM_sdata); + DataExtractor Data(OS.str(), sys::IsLittleEndianHost, sizeof(void*)); + Result.extractValue(Data, &Offset, nullptr); + return Result; +} + +TEST(DWARFFormValue, SignedConstantForms) { + // Check that we correctly sign extend fixed size forms. + auto Sign1 = createDataXFormValue(DW_FORM_data1, -123); + auto Sign2 = createDataXFormValue(DW_FORM_data2, -12345); + auto Sign4 = createDataXFormValue(DW_FORM_data4, -123456789); + auto Sign8 = createDataXFormValue(DW_FORM_data8, -1); + EXPECT_EQ(Sign1.getAsSignedConstant().getValue(), -123); + EXPECT_EQ(Sign2.getAsSignedConstant().getValue(), -12345); + EXPECT_EQ(Sign4.getAsSignedConstant().getValue(), -123456789); + EXPECT_EQ(Sign8.getAsSignedConstant().getValue(), -1); + + // Check that we can handle big positive values, but that we return + // an error just over the limit. + auto UMax = createULEBFormValue(LLONG_MAX); + auto TooBig = createULEBFormValue(uint64_t(LLONG_MAX) + 1); + EXPECT_EQ(UMax.getAsSignedConstant().getValue(), LLONG_MAX); + EXPECT_EQ(TooBig.getAsSignedConstant().hasValue(), false); + + // Sanity check some other forms. + auto Data1 = createDataXFormValue(DW_FORM_data1, 120); + auto Data2 = createDataXFormValue(DW_FORM_data2, 32000); + auto Data4 = createDataXFormValue(DW_FORM_data4, 2000000000); + auto Data8 = createDataXFormValue(DW_FORM_data8, 0x1234567812345678LL); + auto LEBMin = createSLEBFormValue(LLONG_MIN); + auto LEBMax = createSLEBFormValue(LLONG_MAX); + auto LEB1 = createSLEBFormValue(-42); + auto LEB2 = createSLEBFormValue(42); + EXPECT_EQ(Data1.getAsSignedConstant().getValue(), 120); + EXPECT_EQ(Data2.getAsSignedConstant().getValue(), 32000); + EXPECT_EQ(Data4.getAsSignedConstant().getValue(), 2000000000); + EXPECT_EQ(Data8.getAsSignedConstant().getValue(), 0x1234567812345678LL); + EXPECT_EQ(LEBMin.getAsSignedConstant().getValue(), LLONG_MIN); + EXPECT_EQ(LEBMax.getAsSignedConstant().getValue(), LLONG_MAX); + EXPECT_EQ(LEB1.getAsSignedConstant().getValue(), -42); + EXPECT_EQ(LEB2.getAsSignedConstant().getValue(), 42); +} + } // end anonymous namespace diff --git a/unittests/ExecutionEngine/ExecutionEngineTest.cpp b/unittests/ExecutionEngine/ExecutionEngineTest.cpp index 19917a4..8ffc1c8 100644 --- a/unittests/ExecutionEngine/ExecutionEngineTest.cpp +++ b/unittests/ExecutionEngine/ExecutionEngineTest.cpp @@ -9,6 +9,7 @@ #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/LLVMContext.h" diff --git a/unittests/IR/ConstantRangeTest.cpp b/unittests/IR/ConstantRangeTest.cpp index fa03302..de4eec4 100644 --- a/unittests/IR/ConstantRangeTest.cpp +++ b/unittests/IR/ConstantRangeTest.cpp @@ -400,6 +400,13 @@ TEST_F(ConstantRangeTest, Multiply) { EXPECT_EQ(ConstantRange(APInt(4, 1), APInt(4, 6)).multiply( ConstantRange(APInt(4, 6), APInt(4, 2))), ConstantRange(4, /*isFullSet=*/true)); + + EXPECT_EQ(ConstantRange(APInt(8, 254), APInt(8, 0)).multiply( + ConstantRange(APInt(8, 252), APInt(8, 4))), + ConstantRange(APInt(8, 250), APInt(8, 9))); + EXPECT_EQ(ConstantRange(APInt(8, 254), APInt(8, 255)).multiply( + ConstantRange(APInt(8, 2), APInt(8, 4))), + ConstantRange(APInt(8, 250), APInt(8, 253))); } TEST_F(ConstantRangeTest, UMax) { @@ -502,11 +509,63 @@ TEST_F(ConstantRangeTest, Lshr) { EXPECT_EQ(Wrap.lshr(Wrap), Full); } -TEST(ConstantRange, MakeICmpRegion) { +TEST(ConstantRange, MakeAllowedICmpRegion) { // PR8250 ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(32)); - EXPECT_TRUE(ConstantRange::makeICmpRegion(ICmpInst::ICMP_SGT, - SMax).isEmptySet()); + EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGT, SMax) + .isEmptySet()); +} + +TEST(ConstantRange, MakeSatisfyingICmpRegion) { + ConstantRange LowHalf(APInt(8, 0), APInt(8, 128)); + ConstantRange HighHalf(APInt(8, 128), APInt(8, 0)); + ConstantRange EmptySet(8, /* isFullSet = */ false); + + EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_NE, LowHalf), + HighHalf); + + EXPECT_EQ( + ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_NE, HighHalf), + LowHalf); + + EXPECT_TRUE(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_EQ, + HighHalf).isEmptySet()); + + ConstantRange UnsignedSample(APInt(8, 5), APInt(8, 200)); + + EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_ULT, + UnsignedSample), + ConstantRange(APInt(8, 0), APInt(8, 5))); + + EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_ULE, + UnsignedSample), + ConstantRange(APInt(8, 0), APInt(8, 6))); + + EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_UGT, + UnsignedSample), + ConstantRange(APInt(8, 200), APInt(8, 0))); + + EXPECT_EQ(ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_UGE, + UnsignedSample), + ConstantRange(APInt(8, 199), APInt(8, 0))); + + ConstantRange SignedSample(APInt(8, -5), APInt(8, 5)); + + EXPECT_EQ( + ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SLT, SignedSample), + ConstantRange(APInt(8, -128), APInt(8, -5))); + + EXPECT_EQ( + ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SLE, SignedSample), + ConstantRange(APInt(8, -128), APInt(8, -4))); + + EXPECT_EQ( + ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SGT, SignedSample), + ConstantRange(APInt(8, 5), APInt(8, -128))); + + EXPECT_EQ( + ConstantRange::makeSatisfyingICmpRegion(ICmpInst::ICMP_SGE, SignedSample), + ConstantRange(APInt(8, 4), APInt(8, -128))); } } // anonymous namespace diff --git a/unittests/IR/ConstantsTest.cpp b/unittests/IR/ConstantsTest.cpp index 5d271e2..0e040bc 100644 --- a/unittests/IR/ConstantsTest.cpp +++ b/unittests/IR/ConstantsTest.cpp @@ -248,9 +248,9 @@ TEST(ConstantsTest, AsInstructionsTest) { // FIXME: getGetElementPtr() actually creates an inbounds ConstantGEP, // not a normal one! //CHECK(ConstantExpr::getGetElementPtr(Global, V, false), - // "getelementptr i32** @dummy, i32 1"); + // "getelementptr i32*, i32** @dummy, i32 1"); CHECK(ConstantExpr::getInBoundsGetElementPtr(Global, V), - "getelementptr inbounds i32** @dummy, i32 1"); + "getelementptr inbounds i32*, i32** @dummy, i32 1"); CHECK(ConstantExpr::getExtractElement(P6, One), "extractelement <2 x i16> " P6STR ", i32 1"); diff --git a/unittests/IR/DebugInfoTest.cpp b/unittests/IR/DebugInfoTest.cpp index 3c6c786..a957b99 100644 --- a/unittests/IR/DebugInfoTest.cpp +++ b/unittests/IR/DebugInfoTest.cpp @@ -117,17 +117,17 @@ TEST(DIDescriptorTest, splitFlags) { { \ SmallVector V; \ EXPECT_EQ(REMAINDER, DIDescriptor::splitFlags(FLAGS, V)); \ - EXPECT_TRUE(makeArrayRef(V).equals VECTOR); \ + EXPECT_TRUE(makeArrayRef(V).equals(VECTOR)); \ } - CHECK_SPLIT(DIDescriptor::FlagPublic, (DIDescriptor::FlagPublic), 0u); - CHECK_SPLIT(DIDescriptor::FlagProtected, (DIDescriptor::FlagProtected), 0u); - CHECK_SPLIT(DIDescriptor::FlagPrivate, (DIDescriptor::FlagPrivate), 0u); - CHECK_SPLIT(DIDescriptor::FlagVector, (DIDescriptor::FlagVector), 0u); - CHECK_SPLIT(DIDescriptor::FlagRValueReference, (DIDescriptor::FlagRValueReference), 0u); - CHECK_SPLIT(DIDescriptor::FlagFwdDecl | DIDescriptor::FlagVector, - (DIDescriptor::FlagFwdDecl, DIDescriptor::FlagVector), 0u); - CHECK_SPLIT(0x100000u, (), 0x100000u); - CHECK_SPLIT(0x100000u | DIDescriptor::FlagVector, (DIDescriptor::FlagVector), + CHECK_SPLIT(DIDescriptor::FlagPublic, {DIDescriptor::FlagPublic}, 0u); + CHECK_SPLIT(DIDescriptor::FlagProtected, {DIDescriptor::FlagProtected}, 0u); + CHECK_SPLIT(DIDescriptor::FlagPrivate, {DIDescriptor::FlagPrivate}, 0u); + CHECK_SPLIT(DIDescriptor::FlagVector, {DIDescriptor::FlagVector}, 0u); + CHECK_SPLIT(DIDescriptor::FlagRValueReference, {DIDescriptor::FlagRValueReference}, 0u); + unsigned Flags[] = {DIDescriptor::FlagFwdDecl, DIDescriptor::FlagVector}; + CHECK_SPLIT(DIDescriptor::FlagFwdDecl | DIDescriptor::FlagVector, Flags, 0u); + CHECK_SPLIT(0x100000u, {}, 0x100000u); + CHECK_SPLIT(0x100000u | DIDescriptor::FlagVector, {DIDescriptor::FlagVector}, 0x100000u); #undef CHECK_SPLIT } diff --git a/unittests/IR/IRBuilderTest.cpp b/unittests/IR/IRBuilderTest.cpp index 08a729a..ca378a3 100644 --- a/unittests/IR/IRBuilderTest.cpp +++ b/unittests/IR/IRBuilderTest.cpp @@ -111,9 +111,9 @@ TEST_F(IRBuilderTest, LandingPadName) { TEST_F(IRBuilderTest, DataLayout) { std::unique_ptr M(new Module("test", Ctx)); M->setDataLayout("e-n32"); - EXPECT_TRUE(M->getDataLayout()->isLegalInteger(32)); + EXPECT_TRUE(M->getDataLayout().isLegalInteger(32)); M->setDataLayout("e"); - EXPECT_FALSE(M->getDataLayout()->isLegalInteger(32)); + EXPECT_FALSE(M->getDataLayout().isLegalInteger(32)); } TEST_F(IRBuilderTest, GetIntTy) { @@ -122,7 +122,7 @@ TEST_F(IRBuilderTest, GetIntTy) { EXPECT_EQ(Ty1, IntegerType::get(Ctx, 1)); DataLayout* DL = new DataLayout(M.get()); - IntegerType *IntPtrTy = Builder.getIntPtrTy(DL); + IntegerType *IntPtrTy = Builder.getIntPtrTy(*DL); unsigned IntPtrBitSize = DL->getPointerSizeInBits(0); EXPECT_EQ(IntPtrTy, IntegerType::get(Ctx, IntPtrBitSize)); delete DL; diff --git a/unittests/IR/InstructionsTest.cpp b/unittests/IR/InstructionsTest.cpp index 7ec9b62..3ca3ad2 100644 --- a/unittests/IR/InstructionsTest.cpp +++ b/unittests/IR/InstructionsTest.cpp @@ -291,8 +291,10 @@ TEST(InstructionsTest, VectorGep) { LLVMContext &C(getGlobalContext()); // Type Definitions - PointerType *Ptri8Ty = PointerType::get(IntegerType::get(C, 8), 0); - PointerType *Ptri32Ty = PointerType::get(IntegerType::get(C, 32), 0); + Type *I8Ty = IntegerType::get(C, 8); + Type *I32Ty = IntegerType::get(C, 32); + PointerType *Ptri8Ty = PointerType::get(I8Ty, 0); + PointerType *Ptri32Ty = PointerType::get(I32Ty, 0); VectorType *V2xi8PTy = VectorType::get(Ptri8Ty, 2); VectorType *V2xi32PTy = VectorType::get(Ptri32Ty, 2); @@ -318,10 +320,10 @@ TEST(InstructionsTest, VectorGep) { ICmpInst *ICmp2 = new ICmpInst(*BB0, ICmpInst::ICMP_SGE, PtrVecA, PtrVecB); EXPECT_NE(ICmp0, ICmp2); // suppress warning. - GetElementPtrInst *Gep0 = GetElementPtrInst::Create(PtrVecA, C2xi32a); - GetElementPtrInst *Gep1 = GetElementPtrInst::Create(PtrVecA, C2xi32b); - GetElementPtrInst *Gep2 = GetElementPtrInst::Create(PtrVecB, C2xi32a); - GetElementPtrInst *Gep3 = GetElementPtrInst::Create(PtrVecB, C2xi32b); + GetElementPtrInst *Gep0 = GetElementPtrInst::Create(I32Ty, PtrVecA, C2xi32a); + GetElementPtrInst *Gep1 = GetElementPtrInst::Create(I32Ty, PtrVecA, C2xi32b); + GetElementPtrInst *Gep2 = GetElementPtrInst::Create(I32Ty, PtrVecB, C2xi32a); + GetElementPtrInst *Gep3 = GetElementPtrInst::Create(I32Ty, PtrVecB, C2xi32b); CastInst *BTC0 = new BitCastInst(Gep0, V2xi8PTy); CastInst *BTC1 = new BitCastInst(Gep1, V2xi8PTy); @@ -343,16 +345,16 @@ TEST(InstructionsTest, VectorGep) { "2:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-s:64:64-f80" ":128:128-n8:16:32:64-S128"); // Make sure we don't crash - GetPointerBaseWithConstantOffset(Gep0, Offset, &TD); - GetPointerBaseWithConstantOffset(Gep1, Offset, &TD); - GetPointerBaseWithConstantOffset(Gep2, Offset, &TD); - GetPointerBaseWithConstantOffset(Gep3, Offset, &TD); + GetPointerBaseWithConstantOffset(Gep0, Offset, TD); + GetPointerBaseWithConstantOffset(Gep1, Offset, TD); + GetPointerBaseWithConstantOffset(Gep2, Offset, TD); + GetPointerBaseWithConstantOffset(Gep3, Offset, TD); // Gep of Geps - GetElementPtrInst *GepII0 = GetElementPtrInst::Create(Gep0, C2xi32b); - GetElementPtrInst *GepII1 = GetElementPtrInst::Create(Gep1, C2xi32a); - GetElementPtrInst *GepII2 = GetElementPtrInst::Create(Gep2, C2xi32b); - GetElementPtrInst *GepII3 = GetElementPtrInst::Create(Gep3, C2xi32a); + GetElementPtrInst *GepII0 = GetElementPtrInst::Create(I32Ty, Gep0, C2xi32b); + GetElementPtrInst *GepII1 = GetElementPtrInst::Create(I32Ty, Gep1, C2xi32a); + GetElementPtrInst *GepII2 = GetElementPtrInst::Create(I32Ty, Gep2, C2xi32b); + GetElementPtrInst *GepII3 = GetElementPtrInst::Create(I32Ty, Gep3, C2xi32a); EXPECT_EQ(GepII0->getNumIndices(), 1u); EXPECT_EQ(GepII1->getNumIndices(), 1u); diff --git a/unittests/IR/LegacyPassManagerTest.cpp b/unittests/IR/LegacyPassManagerTest.cpp index 9cb9414..66fd1cc 100644 --- a/unittests/IR/LegacyPassManagerTest.cpp +++ b/unittests/IR/LegacyPassManagerTest.cpp @@ -98,7 +98,6 @@ namespace llvm { initializeModuleNDMPass(*PassRegistry::getPassRegistry()); } bool runOnModule(Module &M) override { - EXPECT_TRUE(getAnalysisIfAvailable()); run++; return false; } @@ -175,7 +174,6 @@ namespace llvm { initializeCGPassPass(*PassRegistry::getPassRegistry()); } bool runOnSCC(CallGraphSCC &SCMM) override { - EXPECT_TRUE(getAnalysisIfAvailable()); run(); return false; } @@ -214,7 +212,6 @@ namespace llvm { return false; } bool runOnLoop(Loop *L, LPPassManager &LPM) override { - EXPECT_TRUE(getAnalysisIfAvailable()); run(); return false; } @@ -251,7 +248,6 @@ namespace llvm { return false; } bool runOnBasicBlock(BasicBlock &BB) override { - EXPECT_TRUE(getAnalysisIfAvailable()); run(); return false; } @@ -276,7 +272,6 @@ namespace llvm { initializeFPassPass(*PassRegistry::getPassRegistry()); } bool runOnModule(Module &M) override { - EXPECT_TRUE(getAnalysisIfAvailable()); for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) { Function &F = *I; { @@ -302,7 +297,6 @@ namespace llvm { mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0; legacy::PassManager Passes; - Passes.add(new DataLayoutPass()); Passes.add(mNDM2); Passes.add(mNDM); Passes.add(mNDNM); @@ -326,7 +320,6 @@ namespace llvm { mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0; legacy::PassManager Passes; - Passes.add(new DataLayoutPass()); Passes.add(mNDM); Passes.add(mNDNM); Passes.add(mNDM2);// invalidates mNDM needed by mDNM @@ -348,7 +341,6 @@ namespace llvm { std::unique_ptr M(makeLLVMModule()); T *P = new T(); legacy::PassManager Passes; - Passes.add(new DataLayoutPass()); Passes.add(P); Passes.run(*M); T::finishedOK(run); @@ -359,7 +351,6 @@ namespace llvm { Module *M = makeLLVMModule(); T *P = new T(); legacy::PassManager Passes; - Passes.add(new DataLayoutPass()); Passes.add(P); Passes.run(*M); T::finishedOK(run, N); @@ -397,7 +388,6 @@ namespace llvm { SCOPED_TRACE("Running OnTheFlyTest"); struct OnTheFlyTest *O = new OnTheFlyTest(); legacy::PassManager Passes; - Passes.add(new DataLayoutPass()); Passes.add(O); Passes.run(*M); diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp index 6f2372d..51a9e0b 100644 --- a/unittests/IR/MetadataTest.cpp +++ b/unittests/IR/MetadataTest.cpp @@ -9,6 +9,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/DebugInfo.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" @@ -68,6 +69,12 @@ protected: Metadata *MDs[] = {MD1, MD2}; return MDNode::get(Context, MDs); } + + MDSubprogram *getSubprogram() { + return MDSubprogram::getDistinct(Context, nullptr, "", "", nullptr, 0, + nullptr, false, false, 0, nullptr, 0, 0, 0, + 0); + } }; typedef MetadataTest MDStringTest; @@ -220,7 +227,7 @@ TEST_F(MDNodeTest, Print) { std::string Expected; { raw_string_ostream OS(Expected); - OS << "!{"; + OS << "<" << (void *)N << "> = !{"; C->printAsOperand(OS); OS << ", "; S->printAsOperand(OS); @@ -240,6 +247,105 @@ TEST_F(MDNodeTest, Print) { EXPECT_EQ(Expected, Actual); } +#define EXPECT_PRINTER_EQ(EXPECTED, PRINT) \ + do { \ + std::string Actual_; \ + raw_string_ostream OS(Actual_); \ + PRINT; \ + OS.flush(); \ + std::string Expected_(EXPECTED); \ + EXPECT_EQ(Expected_, Actual_); \ + } while (false) + +TEST_F(MDNodeTest, PrintTemporary) { + MDNode *Arg = getNode(); + TempMDNode Temp = MDNode::getTemporary(Context, Arg); + MDNode *N = getNode(Temp.get()); + Module M("test", Context); + NamedMDNode *NMD = M.getOrInsertNamedMetadata("named"); + NMD->addOperand(N); + + EXPECT_PRINTER_EQ("!0 = !{!1}", N->print(OS, &M)); + EXPECT_PRINTER_EQ("!1 = !{!2}", Temp->print(OS, &M)); + EXPECT_PRINTER_EQ("!2 = !{}", Arg->print(OS, &M)); + + // Cleanup. + Temp->replaceAllUsesWith(Arg); +} + +TEST_F(MDNodeTest, PrintFromModule) { + Constant *C = ConstantInt::get(Type::getInt32Ty(Context), 7); + MDString *S = MDString::get(Context, "foo"); + MDNode *N0 = getNode(); + MDNode *N1 = getNode(N0); + MDNode *N2 = getNode(N0, N1); + + Metadata *Args[] = {ConstantAsMetadata::get(C), S, nullptr, N0, N1, N2}; + MDNode *N = MDNode::get(Context, Args); + Module M("test", Context); + NamedMDNode *NMD = M.getOrInsertNamedMetadata("named"); + NMD->addOperand(N); + + std::string Expected; + { + raw_string_ostream OS(Expected); + OS << "!0 = !{"; + C->printAsOperand(OS); + OS << ", "; + S->printAsOperand(OS); + OS << ", null, !1, !2, !3}"; + } + + EXPECT_PRINTER_EQ(Expected, N->print(OS, &M)); +} + +TEST_F(MDNodeTest, PrintFromFunction) { + Module M("test", Context); + auto *FTy = FunctionType::get(Type::getVoidTy(Context), false); + auto *F0 = Function::Create(FTy, GlobalValue::ExternalLinkage, "F0", &M); + auto *F1 = Function::Create(FTy, GlobalValue::ExternalLinkage, "F1", &M); + auto *BB0 = BasicBlock::Create(Context, "entry", F0); + auto *BB1 = BasicBlock::Create(Context, "entry", F1); + auto *R0 = ReturnInst::Create(Context, BB0); + auto *R1 = ReturnInst::Create(Context, BB1); + auto *N0 = MDNode::getDistinct(Context, None); + auto *N1 = MDNode::getDistinct(Context, None); + R0->setMetadata("md", N0); + R1->setMetadata("md", N1); + + EXPECT_PRINTER_EQ("!0 = distinct !{}", N0->print(OS, &M)); + EXPECT_PRINTER_EQ("!1 = distinct !{}", N1->print(OS, &M)); +} + +TEST_F(MDNodeTest, PrintFromMetadataAsValue) { + Module M("test", Context); + + auto *Intrinsic = + Function::Create(FunctionType::get(Type::getVoidTy(Context), + Type::getMetadataTy(Context), false), + GlobalValue::ExternalLinkage, "llvm.intrinsic", &M); + + auto *FTy = FunctionType::get(Type::getVoidTy(Context), false); + auto *F0 = Function::Create(FTy, GlobalValue::ExternalLinkage, "F0", &M); + auto *F1 = Function::Create(FTy, GlobalValue::ExternalLinkage, "F1", &M); + auto *BB0 = BasicBlock::Create(Context, "entry", F0); + auto *BB1 = BasicBlock::Create(Context, "entry", F1); + auto *N0 = MDNode::getDistinct(Context, None); + auto *N1 = MDNode::getDistinct(Context, None); + auto *MAV0 = MetadataAsValue::get(Context, N0); + auto *MAV1 = MetadataAsValue::get(Context, N1); + CallInst::Create(Intrinsic, MAV0, "", BB0); + CallInst::Create(Intrinsic, MAV1, "", BB1); + + EXPECT_PRINTER_EQ("!0 = distinct !{}", MAV0->print(OS)); + EXPECT_PRINTER_EQ("!1 = distinct !{}", MAV1->print(OS)); + EXPECT_PRINTER_EQ("!0", MAV0->printAsOperand(OS, false)); + EXPECT_PRINTER_EQ("!1", MAV1->printAsOperand(OS, false)); + EXPECT_PRINTER_EQ("metadata !0", MAV0->printAsOperand(OS, true)); + EXPECT_PRINTER_EQ("metadata !1", MAV1->printAsOperand(OS, true)); +} +#undef EXPECT_PRINTER_EQ + TEST_F(MDNodeTest, NullOperand) { // metadata !{} MDNode *Empty = MDNode::get(Context, None); @@ -571,7 +677,7 @@ TEST_F(MDNodeTest, deleteTemporaryWithTrackingRef) { typedef MetadataTest MDLocationTest; TEST_F(MDLocationTest, Overflow) { - MDNode *N = MDNode::get(Context, None); + MDSubprogram *N = getSubprogram(); { MDLocation *L = MDLocation::get(Context, 2, 7, N); EXPECT_EQ(2u, L->getLine()); @@ -596,7 +702,7 @@ TEST_F(MDLocationTest, Overflow) { } TEST_F(MDLocationTest, getDistinct) { - MDNode *N = MDNode::get(Context, None); + MDNode *N = getSubprogram(); MDLocation *L0 = MDLocation::getDistinct(Context, 2, 7, N); EXPECT_TRUE(L0->isDistinct()); MDLocation *L1 = MDLocation::get(Context, 2, 7, N); @@ -730,6 +836,48 @@ TEST_F(MDBasicTypeTest, getWithLargeValues) { EXPECT_EQ(UINT64_MAX - 1, N->getAlignInBits()); } +TEST_F(MDBasicTypeTest, getUnspecified) { + auto *N = + MDBasicType::get(Context, dwarf::DW_TAG_unspecified_type, "unspecified"); + EXPECT_EQ(dwarf::DW_TAG_unspecified_type, N->getTag()); + EXPECT_EQ("unspecified", N->getName()); + EXPECT_EQ(0u, N->getSizeInBits()); + EXPECT_EQ(0u, N->getAlignInBits()); + EXPECT_EQ(0u, N->getEncoding()); + EXPECT_EQ(0u, N->getLine()); +} + +typedef MetadataTest MDTypeTest; + +TEST_F(MDTypeTest, clone) { + // Check that MDType has a specialized clone that returns TempMDType. + MDType *N = MDBasicType::get(Context, dwarf::DW_TAG_base_type, "int", 32, 32, + dwarf::DW_ATE_signed); + + TempMDType Temp = N->clone(); + EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); +} + +TEST_F(MDTypeTest, setFlags) { + // void (void) + Metadata *TypesOps[] = {nullptr}; + Metadata *Types = MDTuple::get(Context, TypesOps); + + MDType *D = MDSubroutineType::getDistinct(Context, 0u, Types); + EXPECT_EQ(0u, D->getFlags()); + D->setFlags(DIDescriptor::FlagRValueReference); + EXPECT_EQ(DIDescriptor::FlagRValueReference, D->getFlags()); + D->setFlags(0u); + EXPECT_EQ(0u, D->getFlags()); + + TempMDType T = MDSubroutineType::getTemporary(Context, 0u, Types); + EXPECT_EQ(0u, T->getFlags()); + T->setFlags(DIDescriptor::FlagRValueReference); + EXPECT_EQ(DIDescriptor::FlagRValueReference, T->getFlags()); + T->setFlags(0u); + EXPECT_EQ(0u, T->getFlags()); +} + typedef MetadataTest MDDerivedTypeTest; TEST_F(MDDerivedTypeTest, get) { @@ -1041,6 +1189,12 @@ TEST_F(MDFileTest, get) { EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); } +TEST_F(MDFileTest, ScopeGetFile) { + // Ensure that MDScope::getFile() returns itself. + MDScope *N = MDFile::get(Context, "file", "dir"); + EXPECT_EQ(N, N->getFile()); +} + typedef MetadataTest MDCompileUnitTest; TEST_F(MDCompileUnitTest, get) { @@ -1568,7 +1722,9 @@ TEST_F(MDLocalVariableTest, get) { Metadata *Type = MDTuple::getDistinct(Context, None); unsigned Arg = 6; unsigned Flags = 7; - Metadata *InlinedAt = MDTuple::getDistinct(Context, None); + Metadata *InlinedAtScope = MDTuple::getDistinct(Context, None); + Metadata *InlinedAt = + MDLocation::getDistinct(Context, 10, 20, InlinedAtScope); auto *N = MDLocalVariable::get(Context, Tag, Scope, Name, File, Line, Type, Arg, Flags, InlinedAt); @@ -1606,6 +1762,19 @@ TEST_F(MDLocalVariableTest, get) { TempMDLocalVariable Temp = N->clone(); EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp))); + + auto *Inlined = N->withoutInline(); + EXPECT_NE(N, Inlined); + EXPECT_EQ(N->getTag(), Inlined->getTag()); + EXPECT_EQ(N->getScope(), Inlined->getScope()); + EXPECT_EQ(N->getName(), Inlined->getName()); + EXPECT_EQ(N->getFile(), Inlined->getFile()); + EXPECT_EQ(N->getLine(), Inlined->getLine()); + EXPECT_EQ(N->getType(), Inlined->getType()); + EXPECT_EQ(N->getArg(), Inlined->getArg()); + EXPECT_EQ(N->getFlags(), Inlined->getFlags()); + EXPECT_EQ(nullptr, Inlined->getInlinedAt()); + EXPECT_EQ(N, Inlined->withInline(cast(InlinedAt))); } typedef MetadataTest MDExpressionTest; diff --git a/unittests/Linker/LinkModulesTest.cpp b/unittests/Linker/LinkModulesTest.cpp index 91f97d7..fbd0363 100644 --- a/unittests/Linker/LinkModulesTest.cpp +++ b/unittests/Linker/LinkModulesTest.cpp @@ -35,7 +35,7 @@ protected: SwitchCase2BB = BasicBlock::Create(Ctx, "switch.case.2", F); ExitBB = BasicBlock::Create(Ctx, "exit", F); - ArrayType *AT = ArrayType::get(Type::getInt8PtrTy(Ctx), 3); + AT = ArrayType::get(Type::getInt8PtrTy(Ctx), 3); GV = new GlobalVariable(*M.get(), AT, false /*=isConstant*/, GlobalValue::InternalLinkage, nullptr,"switch.bas"); @@ -61,6 +61,7 @@ protected: LLVMContext Ctx; std::unique_ptr M; Function *F; + ArrayType *AT; GlobalVariable *GV; BasicBlock *EntryBB; BasicBlock *SwitchCase1BB; @@ -75,7 +76,7 @@ TEST_F(LinkModuleTest, BlockAddress) { GEPIndices.push_back(ConstantInt::get(Type::getInt32Ty(Ctx), 0)); GEPIndices.push_back(F->arg_begin()); - Value *GEP = Builder.CreateGEP(GV, GEPIndices, "switch.gep"); + Value *GEP = Builder.CreateGEP(AT, GV, GEPIndices, "switch.gep"); Value *Load = Builder.CreateLoad(GEP, "switch.load"); Builder.CreateRet(Load); diff --git a/unittests/Support/AlignOfTest.cpp b/unittests/Support/AlignOfTest.cpp index 1119019..d209086 100644 --- a/unittests/Support/AlignOfTest.cpp +++ b/unittests/Support/AlignOfTest.cpp @@ -7,6 +7,12 @@ // //===----------------------------------------------------------------------===// +#ifdef _MSC_VER +// Disable warnings about alignment-based structure padding. +// This must be above the includes to suppress warnings in included templates. +#pragma warning(disable:4324) +#endif + #include "llvm/Support/AlignOf.h" #include "llvm/Support/Compiler.h" #include "gtest/gtest.h" diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index 00af989..479812c 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -168,6 +168,26 @@ TEST(Support, RelativePathIterator) { } } +TEST(Support, RelativePathDotIterator) { + SmallString<64> Path(StringRef(".c/.d/../.")); + typedef SmallVector PathComponents; + PathComponents ExpectedPathComponents; + PathComponents ActualPathComponents; + + StringRef(Path).split(ExpectedPathComponents, "/"); + + for (path::const_iterator I = path::begin(Path), E = path::end(Path); I != E; + ++I) { + ActualPathComponents.push_back(*I); + } + + ASSERT_EQ(ExpectedPathComponents.size(), ActualPathComponents.size()); + + for (size_t i = 0; i Path(StringRef("/c/d/e/foo.txt")); typedef SmallVector PathComponents; @@ -191,6 +211,29 @@ TEST(Support, AbsolutePathIterator) { } } +TEST(Support, AbsolutePathDotIterator) { + SmallString<64> Path(StringRef("/.c/.d/../.")); + typedef SmallVector PathComponents; + PathComponents ExpectedPathComponents; + PathComponents ActualPathComponents; + + StringRef(Path).split(ExpectedPathComponents, "/"); + + // The root path will also be a component when iterating + ExpectedPathComponents[0] = "/"; + + for (path::const_iterator I = path::begin(Path), E = path::end(Path); I != E; + ++I) { + ActualPathComponents.push_back(*I); + } + + ASSERT_EQ(ExpectedPathComponents.size(), ActualPathComponents.size()); + + for (size_t i = 0; i Path(StringRef("c:\\c\\e\\foo.txt")); diff --git a/unittests/Support/YAMLIOTest.cpp b/unittests/Support/YAMLIOTest.cpp index 074e27f..3104726 100644 --- a/unittests/Support/YAMLIOTest.cpp +++ b/unittests/Support/YAMLIOTest.cpp @@ -46,6 +46,9 @@ typedef std::vector FooBarSequence; LLVM_YAML_IS_SEQUENCE_VECTOR(FooBar) +struct FooBarContainer { + FooBarSequence fbs; +}; namespace llvm { namespace yaml { @@ -56,6 +59,12 @@ namespace yaml { io.mapRequired("bar", fb.bar); } }; + + template <> struct MappingTraits { + static void mapping(IO &io, FooBarContainer &fb) { + io.mapRequired("fbs", fb.fbs); + } + }; } } @@ -109,6 +118,83 @@ TEST(YAMLIO, TestSequenceMapRead) { EXPECT_EQ(map2.bar, 9); } +// +// Test the reading of a map containing a yaml sequence of mappings +// +TEST(YAMLIO, TestContainerSequenceMapRead) { + { + FooBarContainer cont; + Input yin2("---\nfbs:\n - foo: 3\n bar: 5\n - foo: 7\n bar: 9\n...\n"); + yin2 >> cont; + + EXPECT_FALSE(yin2.error()); + EXPECT_EQ(cont.fbs.size(), 2UL); + EXPECT_EQ(cont.fbs[0].foo, 3); + EXPECT_EQ(cont.fbs[0].bar, 5); + EXPECT_EQ(cont.fbs[1].foo, 7); + EXPECT_EQ(cont.fbs[1].bar, 9); + } + + { + FooBarContainer cont; + Input yin("---\nfbs:\n...\n"); + yin >> cont; + // Okay: Empty node represents an empty array. + EXPECT_FALSE(yin.error()); + EXPECT_EQ(cont.fbs.size(), 0UL); + } + + { + FooBarContainer cont; + Input yin("---\nfbs: !!null null\n...\n"); + yin >> cont; + // Okay: null represents an empty array. + EXPECT_FALSE(yin.error()); + EXPECT_EQ(cont.fbs.size(), 0UL); + } + + { + FooBarContainer cont; + Input yin("---\nfbs: ~\n...\n"); + yin >> cont; + // Okay: null represents an empty array. + EXPECT_FALSE(yin.error()); + EXPECT_EQ(cont.fbs.size(), 0UL); + } + + { + FooBarContainer cont; + Input yin("---\nfbs: null\n...\n"); + yin >> cont; + // Okay: null represents an empty array. + EXPECT_FALSE(yin.error()); + EXPECT_EQ(cont.fbs.size(), 0UL); + } +} + +// +// Test the reading of a map containing a malformed yaml sequence +// +TEST(YAMLIO, TestMalformedContainerSequenceMapRead) { + { + FooBarContainer cont; + Input yin("---\nfbs:\n foo: 3\n bar: 5\n...\n", nullptr, + suppressErrorMessages); + yin >> cont; + // Error: fbs is not a sequence. + EXPECT_TRUE(!!yin.error()); + EXPECT_EQ(cont.fbs.size(), 0UL); + } + + { + FooBarContainer cont; + Input yin("---\nfbs: 'scalar'\n...\n", nullptr, suppressErrorMessages); + yin >> cont; + // This should be an error. + EXPECT_TRUE(!!yin.error()); + EXPECT_EQ(cont.fbs.size(), 0UL); + } +} // // Test writing then reading back a sequence of mappings diff --git a/unittests/Transforms/IPO/LowerBitSets.cpp b/unittests/Transforms/IPO/LowerBitSets.cpp index 26a4252..49a42cd 100644 --- a/unittests/Transforms/IPO/LowerBitSets.cpp +++ b/unittests/Transforms/IPO/LowerBitSets.cpp @@ -15,27 +15,39 @@ using namespace llvm; TEST(LowerBitSets, BitSetBuilder) { struct { std::vector Offsets; - std::vector Bits; + std::set Bits; uint64_t ByteOffset; uint64_t BitSize; unsigned AlignLog2; bool IsSingleOffset; bool IsAllOnes; } BSBTests[] = { - {{}, {0}, 0, 1, 0, false, false}, - {{0}, {1}, 0, 1, 0, true, true}, - {{4}, {1}, 4, 1, 0, true, true}, - {{37}, {1}, 37, 1, 0, true, true}, - {{0, 1}, {3}, 0, 2, 0, false, true}, - {{0, 4}, {3}, 0, 2, 2, false, true}, - {{0, uint64_t(1) << 33}, {3}, 0, 2, 33, false, true}, - {{3, 7}, {3}, 3, 2, 2, false, true}, - {{0, 1, 7}, {131}, 0, 8, 0, false, false}, - {{0, 2, 14}, {131}, 0, 8, 1, false, false}, - {{0, 1, 8}, {3, 1}, 0, 9, 0, false, false}, - {{0, 2, 16}, {3, 1}, 0, 9, 1, false, false}, - {{0, 1, 2, 3, 4, 5, 6, 7}, {255}, 0, 8, 0, false, true}, - {{0, 1, 2, 3, 4, 5, 6, 7, 8}, {255, 1}, 0, 9, 0, false, true}, + {{}, std::set{}, 0, 1, 0, false, false}, + {{0}, {0}, 0, 1, 0, true, true}, + {{4}, {0}, 4, 1, 0, true, true}, + {{37}, {0}, 37, 1, 0, true, true}, + {{0, 1}, {0, 1}, 0, 2, 0, false, true}, + {{0, 4}, {0, 1}, 0, 2, 2, false, true}, + {{0, uint64_t(1) << 33}, {0, 1}, 0, 2, 33, false, true}, + {{3, 7}, {0, 1}, 3, 2, 2, false, true}, + {{0, 1, 7}, {0, 1, 7}, 0, 8, 0, false, false}, + {{0, 2, 14}, {0, 1, 7}, 0, 8, 1, false, false}, + {{0, 1, 8}, {0, 1, 8}, 0, 9, 0, false, false}, + {{0, 2, 16}, {0, 1, 8}, 0, 9, 1, false, false}, + {{0, 1, 2, 3, 4, 5, 6, 7}, + {0, 1, 2, 3, 4, 5, 6, 7}, + 0, + 8, + 0, + false, + true}, + {{0, 1, 2, 3, 4, 5, 6, 7, 8}, + {0, 1, 2, 3, 4, 5, 6, 7, 8}, + 0, + 9, + 0, + false, + true}, }; for (auto &&T : BSBTests) { @@ -93,3 +105,51 @@ TEST(LowerBitSets, GlobalLayoutBuilder) { EXPECT_EQ(T.WantLayout, ComputedLayout); } } + +TEST(LowerBitSets, ByteArrayBuilder) { + struct BABAlloc { + std::set Bits; + uint64_t BitSize; + uint64_t WantByteOffset; + uint8_t WantMask; + }; + + struct { + std::vector Allocs; + std::vector WantBytes; + } BABTests[] = { + {{{{0}, 1, 0, 1}, {{0}, 1, 0, 2}}, {3}}, + {{{{0}, 16, 0, 1}, + {{1}, 15, 0, 2}, + {{2}, 14, 0, 4}, + {{3}, 13, 0, 8}, + {{4}, 12, 0, 0x10}, + {{5}, 11, 0, 0x20}, + {{6}, 10, 0, 0x40}, + {{7}, 9, 0, 0x80}, + {{0}, 7, 9, 0x80}, + {{0}, 6, 10, 0x40}, + {{0}, 5, 11, 0x20}, + {{0}, 4, 12, 0x10}, + {{0}, 3, 13, 8}, + {{0}, 2, 14, 4}, + {{0}, 1, 15, 2}}, + {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80, 0, 0x80, 0x40, 0x20, 0x10, 8, 4, + 2}}, + }; + + for (auto &&T : BABTests) { + ByteArrayBuilder BABuilder; + + for (auto &&A : T.Allocs) { + uint64_t GotByteOffset; + uint8_t GotMask; + + BABuilder.allocate(A.Bits, A.BitSize, GotByteOffset, GotMask); + EXPECT_EQ(A.WantByteOffset, GotByteOffset); + EXPECT_EQ(A.WantMask, GotMask); + } + + EXPECT_EQ(T.WantBytes, BABuilder.Bytes); + } +} diff --git a/unittests/Transforms/Utils/CMakeLists.txt b/unittests/Transforms/Utils/CMakeLists.txt index ffa1d49..517ff99 100644 --- a/unittests/Transforms/Utils/CMakeLists.txt +++ b/unittests/Transforms/Utils/CMakeLists.txt @@ -9,4 +9,5 @@ add_llvm_unittest(UtilsTests Cloning.cpp IntegerDivision.cpp Local.cpp + ValueMapperTest.cpp ) diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index 1d22d5b..8374099 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/unittests/Transforms/Utils/Cloning.cpp @@ -135,7 +135,8 @@ TEST_F(CloneInstruction, Inbounds) { Constant *Z = Constant::getNullValue(Type::getInt32Ty(context)); std::vector ops; ops.push_back(Z); - GetElementPtrInst *GEP = GetElementPtrInst::Create(V, ops); + GetElementPtrInst *GEP = + GetElementPtrInst::Create(Type::getInt32Ty(context), V, ops); EXPECT_FALSE(this->clone(GEP)->isInBounds()); GEP->setIsInBounds(); diff --git a/unittests/Transforms/Utils/ValueMapperTest.cpp b/unittests/Transforms/Utils/ValueMapperTest.cpp new file mode 100644 index 0000000..137a260 --- /dev/null +++ b/unittests/Transforms/Utils/ValueMapperTest.cpp @@ -0,0 +1,27 @@ +//===- 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)); +} + +} -- cgit v1.1