xref: /llvm-project/llvm/test/Analysis/IRSimilarityIdentifier/debug-inst-starts-block.ll (revision e240e6b8b7cc68a29bc8a5d6a7d0e3b7eaa61dc0)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2; RUN: opt -disable-output -S -passes=print-ir-similarity < %s 2>&1 | FileCheck %s
3
4; When a debug instruction is the first instruction in a block, when that block
5; has not been given a canonical numbering, since debug instructions are not
6; counted in similarity matching they must be ignored when creating canonical
7; relations from one region to another.  This checks that this is enforced.
8
9; CHECK: 2 candidates of length 4.  Found in:
10; CHECK-NEXT:   Function: main, Basic Block: entry
11; CHECK-NEXT:     Start Instruction:   %0 = add i32 1, 4
12; CHECK-NEXT:       End Instruction:   %1 = sub i32 1, 4
13; CHECK-NEXT:   Function: main, Basic Block: for.body169
14; CHECK-NEXT:     Start Instruction:   %2 = add i32 1, 4
15; CHECK-NEXT:       End Instruction:   %3 = sub i32 1, 4
16; CHECK-NEXT: 2 candidates of length 3.  Found in:
17; CHECK-NEXT:   Function: main, Basic Block: entry
18; CHECK-NEXT:     Start Instruction:   br label %for.body169
19; CHECK-NEXT:       End Instruction:   %1 = sub i32 1, 4
20; CHECK-NEXT:   Function: main, Basic Block: for.body169
21; CHECK-NEXT:     Start Instruction:   br label %for.end122
22; CHECK-NEXT:       End Instruction:   %3 = sub i32 1, 4
23; CHECK-NEXT: 2 candidates of length 2.  Found in:
24; CHECK-NEXT:   Function: main, Basic Block: for.end122
25; CHECK-NEXT:     Start Instruction:   store i32 30, ptr undef, align 1
26; CHECK-NEXT:       End Instruction:   %1 = sub i32 1, 4
27; CHECK-NEXT:   Function: main, Basic Block: for.end246
28; CHECK-NEXT:     Start Instruction:   store i32 0, ptr undef, align 1
29; CHECK-NEXT:       End Instruction:   %3 = sub i32 1, 4
30
31source_filename = "irsimilarity_crash.ll"
32
33@v_13 = external dso_local global ptr, align 1
34
35; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
36declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
37
38define dso_local i16 @main() {
39entry:
40  %0 = add i32 1, 4
41  br label %for.body169
42
43for.end122:                                       ; preds = %for.cond108
44  store i32 30, ptr undef, align 1
45  %1 = sub i32 1, 4
46  ret i16 1
47
48for.body169:                                      ; preds = %for.cond167
49  %2 = add i32 1, 4
50  br label %for.end122
51
52for.end246:                                     ; preds = %for.cond167
53  call void @llvm.dbg.declare(metadata ptr undef, metadata !1, metadata !DIExpression()), !dbg !11
54  store i32 0, ptr undef, align 1
55  %3 = sub i32 1, 4
56  unreachable
57}
58
59attributes #0 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
60
61!llvm.dbg.cu = !{}
62!llvm.module.flags = !{!0}
63
64!0 = !{i32 2, !"Debug Info Version", i32 3}
65!1 = !DILocalVariable(name: "v_68", scope: !2, file: !3, line: 522, type: !10)
66!2 = distinct !DILexicalBlock(scope: !4, file: !3, line: 522, column: 9)
67!3 = !DIFile(filename: "41097217.c", directory: "rt.outdir")
68!4 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 480, type: !5, scopeLine: 481, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !9)
69!5 = !DISubroutineType(types: !6)
70!6 = !{!7}
71!7 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
72!8 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 15.0.0.prerel", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !9, globals: !9, splitDebugInlining: false, nameTableKind: None)
73!9 = !{}
74!10 = !DIBasicType(name: "long", size: 32, encoding: DW_ATE_signed)
75!11 = !DILocation(line: 522, column: 23, scope: !2)
76;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
77; CHECK: {{.*}}
78