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