diff options
Diffstat (limited to 'unittests/VMCore')
-rw-r--r-- | unittests/VMCore/DerivedTypesTest.cpp | 26 | ||||
-rw-r--r-- | unittests/VMCore/InstructionsTest.cpp | 14 | ||||
-rw-r--r-- | unittests/VMCore/MetadataTest.cpp | 12 | ||||
-rw-r--r-- | unittests/VMCore/PassManagerTest.cpp | 2 | ||||
-rw-r--r-- | unittests/VMCore/ValueMapTest.cpp | 1 |
5 files changed, 35 insertions, 20 deletions
diff --git a/unittests/VMCore/DerivedTypesTest.cpp b/unittests/VMCore/DerivedTypesTest.cpp index 9dea6ff2a904..956215726cd9 100644 --- a/unittests/VMCore/DerivedTypesTest.cpp +++ b/unittests/VMCore/DerivedTypesTest.cpp @@ -19,13 +19,13 @@ namespace { static void PR7658() { LLVMContext ctx; - + WeakVH NullPtr; PATypeHolder h1; { OpaqueType *o1 = OpaqueType::get(ctx); PointerType *p1 = PointerType::get(o1, 0); - + std::vector<const Type *> t1; t1.push_back(IntegerType::get(ctx, 32)); t1.push_back(p1); @@ -33,41 +33,41 @@ static void PR7658() { OpaqueType *o2 = OpaqueType::get (ctx); PointerType *p2 = PointerType::get (o2, 0); t1.push_back(p2); - - + + StructType *s1 = StructType::get(ctx, t1); h1 = s1; o1->refineAbstractTypeTo(s1); o2->refineAbstractTypeTo(h1.get()); // h1 = { i32, \2*, \2* } } - - + + OpaqueType *o3 = OpaqueType::get(ctx); PointerType *p3 = PointerType::get(o3, 0); // p3 = opaque* - + std::vector<const Type *> t2; t2.push_back(IntegerType::get(ctx, 32)); t2.push_back(p3); - + std::vector<Constant *> v2; v2.push_back(ConstantInt::get(IntegerType::get(ctx, 32), 14)); v2.push_back(ConstantPointerNull::get(p3)); - + OpaqueType *o4 = OpaqueType::get(ctx); { PointerType *p4 = PointerType::get(o4, 0); t2.push_back(p4); v2.push_back(ConstantPointerNull::get(p4)); } - + WeakVH CS = ConstantStruct::get(ctx, v2, false); // { i32 14, opaque* null, opaque* null} - + StructType *s2 = StructType::get(ctx, t2); PATypeHolder h2(s2); o3->refineAbstractTypeTo(s2); o4->refineAbstractTypeTo(h2.get()); } - + TEST(OpaqueTypeTest, RegisterWithContext) { LLVMContext C; @@ -81,7 +81,7 @@ TEST(OpaqueTypeTest, RegisterWithContext) { EXPECT_EQ(2u, pImpl->OpaqueTypes.size()); } EXPECT_EQ(1u, pImpl->OpaqueTypes.size()); - + PR7658(); } diff --git a/unittests/VMCore/InstructionsTest.cpp b/unittests/VMCore/InstructionsTest.cpp index 1d1127d863b8..8edcce40cba7 100644 --- a/unittests/VMCore/InstructionsTest.cpp +++ b/unittests/VMCore/InstructionsTest.cpp @@ -9,6 +9,7 @@ #include "llvm/Instructions.h" #include "llvm/BasicBlock.h" +#include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/LLVMContext.h" #include "llvm/ADT/STLExtras.h" @@ -107,5 +108,18 @@ TEST(InstructionsTest, BranchInst) { delete bb1; } +TEST(InstructionsTest, CastInst) { + LLVMContext &C(getGlobalContext()); + + const Type* Int8Ty = Type::getInt8Ty(C); + const Type* Int64Ty = Type::getInt64Ty(C); + const Type* V8x8Ty = VectorType::get(Int8Ty, 8); + const Type* X86MMXTy = Type::getX86_MMXTy(C); + + EXPECT_TRUE(CastInst::isCastable(V8x8Ty, X86MMXTy)); + EXPECT_TRUE(CastInst::isCastable(X86MMXTy, V8x8Ty)); + EXPECT_FALSE(CastInst::isCastable(Int64Ty, X86MMXTy)); +} + } // end anonymous namespace } // end namespace llvm diff --git a/unittests/VMCore/MetadataTest.cpp b/unittests/VMCore/MetadataTest.cpp index 942b84823250..0b2c012edaac 100644 --- a/unittests/VMCore/MetadataTest.cpp +++ b/unittests/VMCore/MetadataTest.cpp @@ -87,10 +87,10 @@ TEST_F(MDNodeTest, Simple) { V.push_back(CI); V.push_back(s2); - MDNode *n1 = MDNode::get(Context, &V[0], 3); + MDNode *n1 = MDNode::get(Context, V); Value *const c1 = n1; - MDNode *n2 = MDNode::get(Context, &c1, 1); - MDNode *n3 = MDNode::get(Context, &V[0], 3); + MDNode *n2 = MDNode::get(Context, c1); + MDNode *n3 = MDNode::get(Context, V); EXPECT_NE(n1, n2); #ifdef ENABLE_MDNODE_UNIQUING EXPECT_EQ(n1, n3); @@ -112,7 +112,7 @@ TEST_F(MDNodeTest, Delete) { Instruction *I = new BitCastInst(C, Type::getInt32Ty(getGlobalContext())); Value *const V = I; - MDNode *n = MDNode::get(Context, &V, 1); + MDNode *n = MDNode::get(Context, V); WeakVH wvh = n; EXPECT_EQ(n, wvh); @@ -127,8 +127,8 @@ TEST(NamedMDNodeTest, Search) { Value *const V = C; Value *const V2 = C2; - MDNode *n = MDNode::get(Context, &V, 1); - MDNode *n2 = MDNode::get(Context, &V2, 1); + MDNode *n = MDNode::get(Context, V); + MDNode *n2 = MDNode::get(Context, V2); Module M("MyModule", Context); const char *Name = "llvm.NMD1"; diff --git a/unittests/VMCore/PassManagerTest.cpp b/unittests/VMCore/PassManagerTest.cpp index 0073751e4cd6..2f2a200e1d09 100644 --- a/unittests/VMCore/PassManagerTest.cpp +++ b/unittests/VMCore/PassManagerTest.cpp @@ -40,7 +40,7 @@ namespace llvm { void initializeCGPassPass(PassRegistry&); void initializeLPassPass(PassRegistry&); void initializeBPassPass(PassRegistry&); - + namespace { // ND = no deps // NM = no modifications diff --git a/unittests/VMCore/ValueMapTest.cpp b/unittests/VMCore/ValueMapTest.cpp index 152e8eaaf1f1..b4939208e7d4 100644 --- a/unittests/VMCore/ValueMapTest.cpp +++ b/unittests/VMCore/ValueMapTest.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/ValueMap.h" +#include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/ADT/OwningPtr.h" |