diff options
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/ADT/APFloatTest.cpp | 21 | ||||
-rw-r--r-- | unittests/ADT/APIntTest.cpp | 2 | ||||
-rw-r--r-- | unittests/Support/MathExtrasTest.cpp | 2 | ||||
-rw-r--r-- | unittests/Transforms/Utils/Cloning.cpp | 1 | ||||
-rw-r--r-- | unittests/Transforms/Utils/Local.cpp | 6 | ||||
-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 |
10 files changed, 63 insertions, 24 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp index 964b04d..5f05b86 100644 --- a/unittests/ADT/APFloatTest.cpp +++ b/unittests/ADT/APFloatTest.cpp @@ -576,4 +576,25 @@ TEST(APFloatTest, StringHexadecimalExponentDeath) { #endif #endif +TEST(APFloatTest, exactInverse) { + APFloat inv(0.0f); + + // Trivial operation. + EXPECT_TRUE(APFloat(2.0).getExactInverse(&inv)); + EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5))); + EXPECT_TRUE(APFloat(2.0f).getExactInverse(&inv)); + EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5f))); + + // FLT_MIN + EXPECT_TRUE(APFloat(1.17549435e-38f).getExactInverse(&inv)); + EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(8.5070592e+37f))); + + // Large float, inverse is a denormal. + EXPECT_FALSE(APFloat(1.7014118e38f).getExactInverse(0)); + // Zero + EXPECT_FALSE(APFloat(0.0).getExactInverse(0)); + // Denormalized float + EXPECT_FALSE(APFloat(1.40129846e-45f).getExactInverse(0)); +} + } diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp index e05bdbf..dbd0cb7 100644 --- a/unittests/ADT/APIntTest.cpp +++ b/unittests/ADT/APIntTest.cpp @@ -348,6 +348,8 @@ TEST(APIntTest, magicu) { EXPECT_EQ(APInt(32, 5).magicu().s, 2U); EXPECT_EQ(APInt(32, 7).magicu().m, APInt(32, "24924925", 16)); EXPECT_EQ(APInt(32, 7).magicu().s, 3U); + EXPECT_EQ(APInt(64, 25).magicu(1).m, APInt(64, "A3D70A3D70A3D70B", 16)); + EXPECT_EQ(APInt(64, 25).magicu(1).s, 4U); } #ifdef GTEST_HAS_DEATH_TEST diff --git a/unittests/Support/MathExtrasTest.cpp b/unittests/Support/MathExtrasTest.cpp index 3db1f77..0a6724c 100644 --- a/unittests/Support/MathExtrasTest.cpp +++ b/unittests/Support/MathExtrasTest.cpp @@ -73,7 +73,7 @@ TEST(MathExtras, CountLeadingOnes_64) { } TEST(MathExtras, FloatBits) { - static const float kValue = 5632.34; + static const float kValue = 5632.34f; EXPECT_FLOAT_EQ(kValue, BitsToFloat(FloatToBits(kValue))); } diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index b65ac34..1ce549d1 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/unittests/Transforms/Utils/Cloning.cpp @@ -9,6 +9,7 @@ #include "gtest/gtest.h" #include "llvm/Argument.h" +#include "llvm/Constant.h" #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/ADT/SmallPtrSet.h" diff --git a/unittests/Transforms/Utils/Local.cpp b/unittests/Transforms/Utils/Local.cpp index e0322b3..3026b4b 100644 --- a/unittests/Transforms/Utils/Local.cpp +++ b/unittests/Transforms/Utils/Local.cpp @@ -26,7 +26,7 @@ TEST(Local, RecursivelyDeleteDeadPHINodes) { BasicBlock *bb1 = BasicBlock::Create(C); builder.SetInsertPoint(bb0); - PHINode *phi = builder.CreatePHI(Type::getInt32Ty(C)); + PHINode *phi = builder.CreatePHI(Type::getInt32Ty(C), 2); BranchInst *br0 = builder.CreateCondBr(builder.getTrue(), bb0, bb1); builder.SetInsertPoint(bb1); @@ -43,12 +43,12 @@ TEST(Local, RecursivelyDeleteDeadPHINodes) { EXPECT_EQ(&bb1->front(), br1); builder.SetInsertPoint(bb0); - phi = builder.CreatePHI(Type::getInt32Ty(C)); + phi = builder.CreatePHI(Type::getInt32Ty(C), 0); EXPECT_TRUE(RecursivelyDeleteDeadPHINode(phi)); builder.SetInsertPoint(bb0); - phi = builder.CreatePHI(Type::getInt32Ty(C)); + phi = builder.CreatePHI(Type::getInt32Ty(C), 0); builder.CreateAdd(phi, phi); EXPECT_TRUE(RecursivelyDeleteDeadPHINode(phi)); diff --git a/unittests/VMCore/DerivedTypesTest.cpp b/unittests/VMCore/DerivedTypesTest.cpp index 9dea6ff..9562157 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 1d1127d..8edcce4 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 942b848..0b2c012 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 0073751..2f2a200 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 152e8ea..b493920 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" |