1; RUN: opt < %s -S -simplifycfg | FileCheck %s
2
3; In 'simplifycfg', during the flattening of a 'br', the instructions for the
4; 'true' and 'false' parts, are moved out from their respective basic blocks.
5; Their original debug locations (DILocations) and debug intrinsic instructions
6; (dbg.values) are removed.
7; As those basic blocks are now empty, their associated labels are removed.
8;
9; For the given test case, the labels 'W' and 'cleanup4' are removed.
10; We're expecting the dbg.label associated with 'W' to disappear, because
11; the 'W' label was removed.
12
13; CHECK-LABEL: _Z7test_itv()
14; CHECK:       entry:
15; CHECK-NEXT:    %retval.0 = select i1 undef, i16 1, i16 0
16; CHECK-NEXT:    ret i16 0
17
18define i16 @_Z7test_itv() {
19entry:
20  br label %sw.bb
21
22sw.bb:                                            ; preds = %entry
23  br i1 undef, label %W, label %cleanup4
24
25W:                                                ; preds = %sw.bb
26  call void @llvm.dbg.label(metadata !1), !dbg !8
27  br label %cleanup4
28
29cleanup4:                                         ; preds = %W, %sw.bb
30  %retval.0 = phi i16 [ 1, %W ], [ 0, %sw.bb ]
31  ret i16 0
32}
33
34; Function Attrs: nounwind readnone speculatable
35declare void @llvm.dbg.label(metadata) #0
36
37attributes #0 = { nounwind readnone speculatable }
38
39!llvm.dbg.cu = !{}
40!llvm.module.flags = !{!0}
41
42!0 = !{i32 2, !"Debug Info Version", i32 3}
43!1 = !DILabel(scope: !2, name: "W", file: !3, line: 47)
44!2 = distinct !DILexicalBlock(scope: !4, file: !3, line: 40, column: 3)
45!3 = !DIFile(filename: "foo.c", directory: "./")
46!4 = distinct !DISubprogram(name: "test_it", scope: !3, file: !3, line: 35, type: !5, scopeLine: 36, unit: !7)
47!5 = !DISubroutineType(types: !6)
48!6 = !{}
49!7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
50!8 = !DILocation(line: 47, column: 2, scope: !2)
51