diff options
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/ADT/STLForwardCompatTest.cpp | 25 | ||||
-rw-r--r-- | llvm/unittests/Analysis/ValueTrackingTest.cpp | 28 | ||||
-rw-r--r-- | llvm/unittests/Frontend/OpenMPDecompositionTest.cpp | 16 | ||||
-rw-r--r-- | llvm/unittests/IR/DebugInfoTest.cpp | 13 | ||||
-rw-r--r-- | llvm/unittests/Transforms/Utils/LocalTest.cpp | 23 |
5 files changed, 56 insertions, 49 deletions
diff --git a/llvm/unittests/ADT/STLForwardCompatTest.cpp b/llvm/unittests/ADT/STLForwardCompatTest.cpp index e3d500a..4a8f53c 100644 --- a/llvm/unittests/ADT/STLForwardCompatTest.cpp +++ b/llvm/unittests/ADT/STLForwardCompatTest.cpp @@ -10,6 +10,11 @@ #include "CountCopyAndMove.h" #include "gtest/gtest.h" +#include <optional> +#include <tuple> +#include <type_traits> +#include <utility> + namespace { template <typename T> @@ -142,6 +147,26 @@ TEST(TransformTest, MoveTransformLlvm) { EXPECT_EQ(0, CountCopyAndMove::Destructions); } +TEST(TransformTest, TransformCategory) { + struct StructA { + int x; + }; + struct StructB : StructA { + StructB(StructA &&A) : StructA(std::move(A)) {} + }; + + std::optional<StructA> A{StructA{}}; + llvm::transformOptional(A, [](auto &&s) { + EXPECT_FALSE(std::is_rvalue_reference_v<decltype(s)>); + return StructB{std::move(s)}; + }); + + llvm::transformOptional(std::move(A), [](auto &&s) { + EXPECT_TRUE(std::is_rvalue_reference_v<decltype(s)>); + return StructB{std::move(s)}; + }); +} + TEST(TransformTest, ToUnderlying) { enum E { A1 = 0, B1 = -1 }; static_assert(llvm::to_underlying(A1) == 0); diff --git a/llvm/unittests/Analysis/ValueTrackingTest.cpp b/llvm/unittests/Analysis/ValueTrackingTest.cpp index 4b47655..6af2006 100644 --- a/llvm/unittests/Analysis/ValueTrackingTest.cpp +++ b/llvm/unittests/Analysis/ValueTrackingTest.cpp @@ -915,11 +915,11 @@ TEST(ValueTracking, propagatesPoison) { {true, "call float @llvm.sin.f32(float %fx)", 0}, {true, "call float @llvm.cos.f32(float %fx)", 0}, {true, "call float @llvm.pow.f32(float %fx, float %fy)", 0}, - {false, "call float @llvm.exp.f32(float %fx)", 0}, - {false, "call float @llvm.exp2.f32(float %fx)", 0}, - {false, "call float @llvm.log.f32(float %fx)", 0}, - {false, "call float @llvm.log10.f32(float %fx)", 0}, - {false, "call float @llvm.log2.f32(float %fx)", 0}, + {true, "call float @llvm.exp.f32(float %fx)", 0}, + {true, "call float @llvm.exp2.f32(float %fx)", 0}, + {true, "call float @llvm.log.f32(float %fx)", 0}, + {true, "call float @llvm.log10.f32(float %fx)", 0}, + {true, "call float @llvm.log2.f32(float %fx)", 0}, {false, "call float @llvm.fma.f32(float %fx, float %fx, float %fy)", 0}, {false, "call float @llvm.fabs.f32(float %fx)", 0}, {false, "call float @llvm.minnum.f32(float %fx, float %fy)", 0}, @@ -927,17 +927,17 @@ TEST(ValueTracking, propagatesPoison) { {false, "call float @llvm.minimum.f32(float %fx, float %fy)", 0}, {false, "call float @llvm.maximum.f32(float %fx, float %fy)", 0}, {false, "call float @llvm.copysign.f32(float %fx, float %fy)", 0}, - {false, "call float @llvm.floor.f32(float %fx)", 0}, - {false, "call float @llvm.ceil.f32(float %fx)", 0}, - {false, "call float @llvm.trunc.f32(float %fx)", 0}, - {false, "call float @llvm.rint.f32(float %fx)", 0}, - {false, "call float @llvm.nearbyint.f32(float %fx)", 0}, - {false, "call float @llvm.round.f32(float %fx)", 0}, - {false, "call float @llvm.roundeven.f32(float %fx)", 0}, + {true, "call float @llvm.floor.f32(float %fx)", 0}, + {true, "call float @llvm.ceil.f32(float %fx)", 0}, + {true, "call float @llvm.trunc.f32(float %fx)", 0}, + {true, "call float @llvm.rint.f32(float %fx)", 0}, + {true, "call float @llvm.nearbyint.f32(float %fx)", 0}, + {true, "call float @llvm.round.f32(float %fx)", 0}, + {true, "call float @llvm.roundeven.f32(float %fx)", 0}, {false, "call i32 @llvm.lround.f32(float %fx)", 0}, {false, "call i64 @llvm.llround.f32(float %fx)", 0}, - {false, "call i32 @llvm.lrint.f32(float %fx)", 0}, - {false, "call i64 @llvm.llrint.f32(float %fx)", 0}, + {true, "call i32 @llvm.lrint.f32(float %fx)", 0}, + {true, "call i64 @llvm.llrint.f32(float %fx)", 0}, {false, "call float @llvm.fmuladd.f32(float %fx, float %fx, float %fy)", 0}}; diff --git a/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp b/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp index 6189d09..95c26b1 100644 --- a/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp +++ b/llvm/unittests/Frontend/OpenMPDecompositionTest.cpp @@ -431,8 +431,8 @@ TEST_F(OpenMPDecompositionTest, Firstprivate3) { std::string Dir0 = stringify(Dec.output[0]); std::string Dir1 = stringify(Dec.output[1]); std::string Dir2 = stringify(Dec.output[2]); - ASSERT_EQ(Dir0, "target map(2, , , , (x))"); // (12), (27) - ASSERT_EQ(Dir1, "teams shared(x)"); // (6), (17) + ASSERT_EQ(Dir0, "target map(2, , , , , (x))"); // (12), (27) + ASSERT_EQ(Dir1, "teams shared(x)"); // (6), (17) ASSERT_EQ(Dir2, "distribute firstprivate(x) lastprivate(, (x))"); // (5), (21) } @@ -574,9 +574,9 @@ TEST_F(OpenMPDecompositionTest, Lastprivate3) { std::string Dir0 = stringify(Dec.output[0]); std::string Dir1 = stringify(Dec.output[1]); std::string Dir2 = stringify(Dec.output[2]); - ASSERT_EQ(Dir0, "target map(2, , , , (x))"); // (21), (27) - ASSERT_EQ(Dir1, "parallel shared(x)"); // (22) - ASSERT_EQ(Dir2, "do lastprivate(, (x))"); // (21) + ASSERT_EQ(Dir0, "target map(2, , , , , (x))"); // (21), (27) + ASSERT_EQ(Dir1, "parallel shared(x)"); // (22) + ASSERT_EQ(Dir2, "do lastprivate(, (x))"); // (21) } // SHARED @@ -984,9 +984,9 @@ TEST_F(OpenMPDecompositionTest, Reduction7) { std::string Dir0 = stringify(Dec.output[0]); std::string Dir1 = stringify(Dec.output[1]); std::string Dir2 = stringify(Dec.output[2]); - ASSERT_EQ(Dir0, "target map(2, , , , (x))"); // (36), (10) - ASSERT_EQ(Dir1, "parallel shared(x)"); // (36), (1), (4) - ASSERT_EQ(Dir2, "do reduction(, (3), (x))"); // (36) + ASSERT_EQ(Dir0, "target map(2, , , , , (x))"); // (36), (10) + ASSERT_EQ(Dir1, "parallel shared(x)"); // (36), (1), (4) + ASSERT_EQ(Dir2, "do reduction(, (3), (x))"); // (36) } // IF diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp index baa13e1..0065615 100644 --- a/llvm/unittests/IR/DebugInfoTest.cpp +++ b/llvm/unittests/IR/DebugInfoTest.cpp @@ -185,10 +185,8 @@ TEST(MetadataTest, DeleteInstUsedByDbgRecord) { Instruction &I = *M->getFunction("f")->getEntryBlock().getFirstNonPHIIt(); // Find the dbg.value using %b. - SmallVector<DbgValueInst *, 1> DVIs; SmallVector<DbgVariableRecord *, 1> DVRs; - findDbgValues(DVIs, &I, &DVRs); - assert(DVIs.empty()); + findDbgValues(&I, DVRs); // Delete %b. The dbg.value should now point to undef. I.eraseFromParent(); @@ -230,7 +228,6 @@ TEST(MetadataTest, GlobalConstantMetadataUsedByDbgRecord) { Value *V = M->getNamedValue("x"); // Find the dbg.value - auto DVIs = findDbgDeclares(V); auto DVRs = findDVRDeclares(V); auto DVRVs = findDVRValues(V); @@ -312,10 +309,8 @@ TEST(MetadataTest, DeleteInstUsedByDbgVariableRecord) { Instruction &I = *M->getFunction("f")->getEntryBlock().getFirstNonPHIIt(); // Find the DbgVariableRecords using %b. - SmallVector<DbgValueInst *, 2> DVIs; SmallVector<DbgVariableRecord *, 2> DVRs; - findDbgValues(DVIs, &I, &DVRs); - assert(DVIs.empty()); + findDbgValues(&I, DVRs); ASSERT_EQ(DVRs.size(), 2u); // Delete %b. The DbgVariableRecord should now point to undef. @@ -359,11 +354,9 @@ TEST(MetadataTest, OrderingOfDbgVariableRecords) { Instruction &I = *M->getFunction("f")->getEntryBlock().getFirstNonPHIIt(); - SmallVector<DbgValueInst *, 2> DVIs; SmallVector<DbgVariableRecord *, 2> DVRs; - findDbgValues(DVIs, &I, &DVRs); - ASSERT_EQ(DVIs.size(), 0u); + findDbgValues(&I, DVRs); ASSERT_EQ(DVRs.size(), 2u); // The correct order of dbg.values is given by their use-list, which becomes diff --git a/llvm/unittests/Transforms/Utils/LocalTest.cpp b/llvm/unittests/Transforms/Utils/LocalTest.cpp index dd2a624..0c70feb 100644 --- a/llvm/unittests/Transforms/Utils/LocalTest.cpp +++ b/llvm/unittests/Transforms/Utils/LocalTest.cpp @@ -673,20 +673,17 @@ TEST(Local, FindDbgRecords) { Function &Fun = *cast<Function>(M->getNamedValue("fun")); Value *Arg = Fun.getArg(0); - SmallVector<DbgVariableIntrinsic *> Users; SmallVector<DbgVariableRecord *> Records; // Arg (%a) is used twice by a single dbg_assign. Check findDbgUsers returns // only 1 pointer to it rather than 2. - findDbgUsers(Users, Arg, &Records); - EXPECT_EQ(Users.size(), 0u); + findDbgUsers(Arg, Records); EXPECT_EQ(Records.size(), 1u); SmallVector<DbgValueInst *> Vals; Records.clear(); // Arg (%a) is used twice by a single dbg_assign. Check findDbgValues returns // only 1 pointer to it rather than 2. - findDbgValues(Vals, Arg, &Records); - EXPECT_EQ(Vals.size(), 0u); + findDbgValues(Arg, Records); EXPECT_EQ(Records.size(), 1u); } @@ -787,20 +784,16 @@ TEST(Local, ReplaceAllDbgUsesWith) { // Simulate i32* <-> i64* conversion. EXPECT_TRUE(replaceAllDbgUsesWith(D, C, C, DT)); - SmallVector<DbgVariableIntrinsic *, 2> CDbgVals; SmallVector<DbgVariableRecord *, 2> CDbgRecords; - findDbgUsers(CDbgVals, &C, &CDbgRecords); - EXPECT_EQ(0U, CDbgVals.size()); + findDbgUsers(&C, CDbgRecords); EXPECT_EQ(2U, CDbgRecords.size()); EXPECT_TRUE(all_of( CDbgRecords, [](DbgVariableRecord *DVR) { return DVR->isDbgDeclare(); })); EXPECT_TRUE(replaceAllDbgUsesWith(C, D, D, DT)); - SmallVector<DbgVariableIntrinsic *, 2> DDbgVals; SmallVector<DbgVariableRecord *, 2> DDbgRecords; - findDbgUsers(DDbgVals, &D, &DDbgRecords); - EXPECT_EQ(0U, DDbgVals.size()); + findDbgUsers(&D, DDbgRecords); EXPECT_EQ(2U, DDbgRecords.size()); EXPECT_TRUE(all_of( DDbgRecords, [](DbgVariableRecord *DVR) { return DVR->isDbgDeclare(); })); @@ -824,10 +817,8 @@ TEST(Local, ReplaceAllDbgUsesWith) { EXPECT_EQ(BarrierDbgVal->getNumVariableLocationOps(), 1u); EXPECT_TRUE(BarrierDbgVal->isKillLocation()); - SmallVector<DbgValueInst *, 1> BarrierDbgVals; SmallVector<DbgVariableRecord *, 8> BarrierDbgRecs; - findDbgValues(BarrierDbgVals, &F_, &BarrierDbgRecs); - EXPECT_EQ(0U, BarrierDbgVals.size()); + findDbgValues(&F_, BarrierDbgRecs); EXPECT_EQ(0U, BarrierDbgRecs.size()); // Simulate i32 -> i64 conversion to test sign-extension. Here are some @@ -838,10 +829,8 @@ TEST(Local, ReplaceAllDbgUsesWith) { // 4-6) like (1-3), but with a fragment EXPECT_TRUE(replaceAllDbgUsesWith(B, A, A, DT)); - SmallVector<DbgValueInst *, 8> BDbgVals; SmallVector<DbgVariableRecord *, 8> BDbgRecs; - findDbgValues(BDbgVals, &A, &BDbgRecs); - EXPECT_EQ(0U, BDbgVals.size()); + findDbgValues(&A, BDbgRecs); EXPECT_EQ(6U, BDbgRecs.size()); // Check that %a has a dbg.value with a DIExpression matching \p Ops. |