Skip to content

Add unit test for CloneModule and #dbg_label #91463

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions llvm/unittests/Transforms/Utils/CloningTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,4 +1122,42 @@ TEST_F(CloneModule, IFunc) {
EXPECT_EQ("resolver", Resolver->getName());
EXPECT_EQ(GlobalValue::PrivateLinkage, Resolver->getLinkage());
}

TEST_F(CloneModule, CloneDbgLabel) {
LLVMContext Context;

std::unique_ptr<Module> M = parseIR(
Context,
R"M(
define void @noop(ptr nocapture noundef writeonly align 4 %dst) local_unnamed_addr !dbg !3 {
entry:
%call = tail call spir_func i64 @foo(i32 noundef 0)
#dbg_label(!11, !12)
store i64 %call, ptr %dst, align 4
ret void
}

declare i64 @foo(i32 noundef) local_unnamed_addr

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2}

!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "<stdin>", directory: "foo")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = distinct !DISubprogram(name: "noop", scope: !4, file: !4, line: 17, type: !5, scopeLine: 17, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !9)
!4 = !DIFile(filename: "file", directory: "foo")
!5 = !DISubroutineType(types: !6)
!6 = !{null, !7}
!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
!8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!9 = !{}
!11 = !DILabel(scope: !3, name: "foo", file: !4, line: 23)
!12 = !DILocation(line: 23, scope: !3)
)M");

ASSERT_FALSE(verifyModule(*M, &errs()));
auto NewM = llvm::CloneModule(*M);
EXPECT_FALSE(verifyModule(*NewM, &errs()));
}
}