xref: /llvm-project/llvm/test/DebugInfo/Generic/assignment-tracking/inline/shared-alloca.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: opt -S %s -passes=inline -o - \
2; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
3; RUN: opt --try-experimental-debuginfo-iterators -S %s -passes=inline -o - \
4; RUN: | FileCheck %s --implicit-check-not="call void @llvm.dbg"
5
6;; The dbg.assign linked to the large alloca describes a variable sitting at
7;; offset 0, size 64. Check:
8;; A) an inlined store to the alloca outside of the bits 0-64 is not attributed
9;;    to the variable.
10;; B) a fragment expression is not created if the inlined store is the size of
11;;    the variable.
12;; C) a fragment expression is created if the inlined store is not the size of
13;;    the variable.
14
15;; Test A:
16; CHECK: %0 = alloca %"struct.llvm::detail::DenseMapPair", i32 0, align 8, !DIAssignID ![[ID1:[0-9]+]]
17; CHECK: #dbg_assign(i1 undef, ![[#]], !DIExpression(), ![[ID1]], ptr %0, !DIExpression(),
18
19;; Test B:
20;; CHECK: store i64 1, ptr %0, align 4, !DIAssignID ![[ID2:[0-9]+]]
21;; CHECK: #dbg_assign(i64 1, ![[#]], !DIExpression(), ![[ID2]], ptr %0, !DIExpression(),
22
23;; Test C:
24;; CHECK: store i32 2, ptr %0, align 4, !DIAssignID ![[ID3:[0-9]+]]
25;; CHECK: #dbg_assign(i32 2, ![[#]], !DIExpression(DW_OP_LLVM_fragment, 0, 32), ![[ID3]], ptr %0, !DIExpression(),
26
27%"struct.llvm::detail::DenseMapPair" = type { %"struct.std::pair" }
28%"struct.std::pair" = type { ptr, %"class.llvm::SmallVector" }
29%"class.llvm::SmallVector" = type { %"class.llvm::SmallVectorImpl", %"struct.llvm::SmallVectorStorage" }
30%"class.llvm::SmallVectorImpl" = type { %"class.llvm::SmallVectorTemplateBase" }
31%"class.llvm::SmallVectorTemplateBase" = type { %"class.llvm::SmallVectorTemplateCommon" }
32%"class.llvm::SmallVectorTemplateCommon" = type { %"class.llvm::SmallVectorBase" }
33%"class.llvm::SmallVectorBase" = type { ptr, i64, i64 }
34%"struct.llvm::SmallVectorStorage" = type { [40 x i8] }
35
36define void @_Z6verifyv() {
37entry:
38  %0 = alloca %"struct.llvm::detail::DenseMapPair", i32 0, align 8, !DIAssignID !5
39  call void @llvm.dbg.assign(metadata i1 undef, metadata !6, metadata !DIExpression(), metadata !5, metadata ptr %0, metadata !DIExpression()), !dbg !14
40  call void @_ZN4llvm6detail12DenseMapPairIP4SCEVNS_11SmallVectorI6FoldIDLj40EEEEC2ERKS7_(ptr %0)
41  ret void
42}
43
44define linkonce_odr void @_ZN4llvm6detail12DenseMapPairIP4SCEVNS_11SmallVectorI6FoldIDLj40EEEEC2ERKS7_(ptr %this) {
45entry:
46  %second.i = getelementptr %"struct.std::pair", ptr %this, i64 0, i32 1
47  store i32 0, ptr %second.i, align 4
48  %test = getelementptr %"struct.std::pair", ptr %this, i64 0, i32 0
49  store i64 1, ptr %test
50  store i32 2, ptr %test
51  ret void
52}
53
54declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
55
56!llvm.dbg.cu = !{!0}
57!llvm.module.flags = !{!3, !4}
58
59!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2, splitDebugInlining: false, nameTableKind: None)
60!1 = !DIFile(filename: "reduce.cpp", directory: "")
61!2 = !{}
62!3 = !{i32 2, !"Debug Info Version", i32 3}
63!4 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
64!5 = distinct !DIAssignID()
65!6 = !DILocalVariable(name: "a", scope: !7, file: !1, line: 10, type: !12)
66!7 = distinct !DILexicalBlock(scope: !8, file: !1, line: 10, column: 3)
67!8 = distinct !DILexicalBlock(scope: !9, file: !1, line: 10, column: 3)
68!9 = distinct !DISubprogram(name: "verify", linkageName: "_Z6verifyv", scope: !1, file: !1, line: 9, type: !10, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
69!10 = !DISubroutineType(types: !11)
70!11 = !{null}
71!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
72!13 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "SCEV", file: !1, line: 3, flags: DIFlagFwdDecl | DIFlagNonTrivial, identifier: "_ZTS4SCEV")
73!14 = !DILocation(line: 0, scope: !7)
74
75