@@ -109,6 +109,62 @@ TEST(BasicBlockDbgInfoTest, InsertAfterSelf) {
109
109
UseNewDbgInfoFormat = false ;
110
110
}
111
111
112
+ TEST (BasicBlockDbgInfoTest, SplitBasicBlockBefore) {
113
+ LLVMContext C;
114
+ UseNewDbgInfoFormat = true ;
115
+
116
+ std::unique_ptr<Module> M = parseIR (C, R"---(
117
+ define dso_local void @func() #0 !dbg !10 {
118
+ %1 = alloca i32, align 4
119
+ tail call void @llvm.dbg.declare(metadata ptr %1, metadata !14, metadata !DIExpression()), !dbg !16
120
+ store i32 2, ptr %1, align 4, !dbg !16
121
+ ret void, !dbg !17
122
+ }
123
+
124
+ declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
125
+
126
+ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
127
+
128
+ !llvm.dbg.cu = !{!0}
129
+ !llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
130
+ !llvm.ident = !{!9}
131
+
132
+ !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "dummy", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
133
+ !1 = !DIFile(filename: "dummy", directory: "dummy")
134
+ !2 = !{i32 7, !"Dwarf Version", i32 5}
135
+ !3 = !{i32 2, !"Debug Info Version", i32 3}
136
+ !4 = !{i32 1, !"wchar_size", i32 4}
137
+ !5 = !{i32 8, !"PIC Level", i32 2}
138
+ !6 = !{i32 7, !"PIE Level", i32 2}
139
+ !7 = !{i32 7, !"uwtable", i32 2}
140
+ !8 = !{i32 7, !"frame-pointer", i32 2}
141
+ !9 = !{!"dummy"}
142
+ !10 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !13)
143
+ !11 = !DISubroutineType(types: !12)
144
+ !12 = !{null}
145
+ !13 = !{}
146
+ !14 = !DILocalVariable(name: "a", scope: !10, file: !1, line: 2, type: !15)
147
+ !15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
148
+ !16 = !DILocation(line: 2, column: 6, scope: !10)
149
+ !17 = !DILocation(line: 3, column: 2, scope: !10)
150
+ )---" );
151
+ ASSERT_TRUE (M);
152
+
153
+ M->convertToNewDbgValues ();
154
+
155
+ Function *F = M->getFunction (" func" );
156
+
157
+ BasicBlock &BB = F->getEntryBlock ();
158
+ auto I = std::prev (BB.end (), 2 );
159
+ BB.splitBasicBlockBefore (I, " before" );
160
+
161
+ BasicBlock &BBBefore = F->getEntryBlock ();
162
+ auto I2 = std::prev (BBBefore.end (), 2 );
163
+ ASSERT_TRUE (I2->hasDbgRecords ());
164
+
165
+ UseNewDbgInfoFormat = false ;
166
+ }
167
+
112
168
TEST (BasicBlockDbgInfoTest, MarkerOperations) {
113
169
LLVMContext C;
114
170
UseNewDbgInfoFormat = true ;
0 commit comments