diff options
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/ADT/STLForwardCompatTest.cpp | 25 | ||||
-rw-r--r-- | llvm/unittests/CodeGen/LexicalScopesTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/DebugInfoTest.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/Transforms/Utils/DebugifyTest.cpp | 9 | ||||
-rw-r--r-- | llvm/unittests/Transforms/Utils/LocalTest.cpp | 56 |
5 files changed, 29 insertions, 65 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/CodeGen/LexicalScopesTest.cpp b/llvm/unittests/CodeGen/LexicalScopesTest.cpp index 3d707462..563d496 100644 --- a/llvm/unittests/CodeGen/LexicalScopesTest.cpp +++ b/llvm/unittests/CodeGen/LexicalScopesTest.cpp @@ -67,7 +67,7 @@ public: BeanInst.Opcode = 1; BeanInst.Size = 1; - memset(&DbgValueInst, 0, sizeof(DbgValueInst)); + memset(&DbgValueInst, 0, sizeof(MCInstrDesc)); DbgValueInst.Opcode = TargetOpcode::DBG_VALUE; DbgValueInst.Size = 1; DbgValueInst.Flags = 1U << MCID::Meta; diff --git a/llvm/unittests/IR/DebugInfoTest.cpp b/llvm/unittests/IR/DebugInfoTest.cpp index 41bf863..baa13e1 100644 --- a/llvm/unittests/IR/DebugInfoTest.cpp +++ b/llvm/unittests/IR/DebugInfoTest.cpp @@ -188,6 +188,7 @@ TEST(MetadataTest, DeleteInstUsedByDbgRecord) { SmallVector<DbgValueInst *, 1> DVIs; SmallVector<DbgVariableRecord *, 1> DVRs; findDbgValues(DVIs, &I, &DVRs); + assert(DVIs.empty()); // Delete %b. The dbg.value should now point to undef. I.eraseFromParent(); @@ -314,6 +315,7 @@ TEST(MetadataTest, DeleteInstUsedByDbgVariableRecord) { SmallVector<DbgValueInst *, 2> DVIs; SmallVector<DbgVariableRecord *, 2> DVRs; findDbgValues(DVIs, &I, &DVRs); + assert(DVIs.empty()); ASSERT_EQ(DVRs.size(), 2u); // Delete %b. The DbgVariableRecord should now point to undef. diff --git a/llvm/unittests/Transforms/Utils/DebugifyTest.cpp b/llvm/unittests/Transforms/Utils/DebugifyTest.cpp index 0b00734..1daf381 100644 --- a/llvm/unittests/Transforms/Utils/DebugifyTest.cpp +++ b/llvm/unittests/Transforms/Utils/DebugifyTest.cpp @@ -54,20 +54,13 @@ struct DebugInfoDrop : public FunctionPass { struct DebugValueDrop : public FunctionPass { static char ID; bool runOnFunction(Function &F) override { - SmallVector<DbgVariableIntrinsic *, 4> Dbgs; for (BasicBlock &BB : F) { - // Remove dbg var intrinsics. for (Instruction &I : BB) { - if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) - Dbgs.push_back(DVI); - // If there are any non-intrinsic records (DbgRecords), drop those too. + // If there are any debug records, drop them. I.dropDbgRecords(); } } - for (auto &I : Dbgs) - I->eraseFromParent(); - return true; } diff --git a/llvm/unittests/Transforms/Utils/LocalTest.cpp b/llvm/unittests/Transforms/Utils/LocalTest.cpp index b922216e..dd2a624 100644 --- a/llvm/unittests/Transforms/Utils/LocalTest.cpp +++ b/llvm/unittests/Transforms/Utils/LocalTest.cpp @@ -633,62 +633,6 @@ TEST(Local, ChangeToUnreachable) { EXPECT_EQ(DLA, DLB); } -TEST(Local, FindDbgUsers) { - LLVMContext Ctx; - std::unique_ptr<Module> M = parseIR(Ctx, - R"( - define dso_local void @fun(ptr %a) #0 !dbg !11 { - entry: - #dbg_assign(ptr %a, !16, !DIExpression(), !15, ptr %a, !DIExpression(), !19) - ret void - } - - !llvm.dbg.cu = !{!0} - !llvm.module.flags = !{!2, !3, !9} - !llvm.ident = !{!10} - - !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) - !1 = !DIFile(filename: "test.cpp", directory: "/") - !2 = !{i32 7, !"Dwarf Version", i32 5} - !3 = !{i32 2, !"Debug Info Version", i32 3} - !4 = !{i32 1, !"wchar_size", i32 4} - !9 = !{i32 7, !"debug-info-assignment-tracking", i1 true} - !10 = !{!"clang version 17.0.0"} - !11 = distinct !DISubprogram(name: "fun", linkageName: "fun", scope: !1, file: !1, line: 1, type: !12, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !14) - !12 = !DISubroutineType(types: !13) - !13 = !{null} - !14 = !{} - !15 = distinct !DIAssignID() - !16 = !DILocalVariable(name: "x", scope: !11, file: !1, line: 2, type: !17) - !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !18, size: 64) - !18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) - !19 = !DILocation(line: 0, scope: !11) - )"); - - bool BrokenDebugInfo = true; - verifyModule(*M, &errs(), &BrokenDebugInfo); - ASSERT_FALSE(BrokenDebugInfo); - - // Convert to debug intrinsics as we want to test findDbgUsers and - // findDbgValue's debug-intrinsic-finding code here. - // TODO: Remove this test when debug intrinsics are removed. - M->convertFromNewDbgValues(); - - Function &Fun = *cast<Function>(M->getNamedValue("fun")); - Value *Arg = Fun.getArg(0); - SmallVector<DbgVariableIntrinsic *> Users; - // Arg (%a) is used twice by a single dbg.assign. Check findDbgUsers returns - // only 1 pointer to it rather than 2. - findDbgUsers(Users, Arg); - EXPECT_EQ(Users.size(), 1u); - - SmallVector<DbgValueInst *> Vals; - // Arg (%a) is used twice by a single dbg.assign. Check findDbgValues returns - // only 1 pointer to it rather than 2. - findDbgValues(Vals, Arg); - EXPECT_EQ(Vals.size(), 1u); -} - TEST(Local, FindDbgRecords) { // DbgRecord copy of the FindDbgUsers test above. LLVMContext Ctx; |