first-only.ll 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ; RUN: opt < %s -add-discriminators -S | FileCheck %s
  2. ; Test that the only instructions that receive a new discriminator in
  3. ; the block 'if.then' are those that share the same line number as
  4. ; the branch in 'entry'.
  5. ;
  6. ; Original code:
  7. ;
  8. ; void foo(int i) {
  9. ; int x, y;
  10. ; if (i < 10) { x = i;
  11. ; y = -i;
  12. ; }
  13. ; }
  14. define void @foo(i32 %i) #0 {
  15. entry:
  16. %i.addr = alloca i32, align 4
  17. %x = alloca i32, align 4
  18. %y = alloca i32, align 4
  19. store i32 %i, i32* %i.addr, align 4
  20. %0 = load i32, i32* %i.addr, align 4, !dbg !10
  21. %cmp = icmp slt i32 %0, 10, !dbg !10
  22. br i1 %cmp, label %if.then, label %if.end, !dbg !10
  23. if.then: ; preds = %entry
  24. %1 = load i32, i32* %i.addr, align 4, !dbg !12
  25. store i32 %1, i32* %x, align 4, !dbg !12
  26. %2 = load i32, i32* %i.addr, align 4, !dbg !14
  27. ; CHECK: %2 = load i32, i32* %i.addr, align 4, !dbg ![[THEN:[0-9]+]]
  28. %sub = sub nsw i32 0, %2, !dbg !14
  29. ; CHECK: %sub = sub nsw i32 0, %2, !dbg ![[THEN]]
  30. store i32 %sub, i32* %y, align 4, !dbg !14
  31. ; CHECK: store i32 %sub, i32* %y, align 4, !dbg ![[THEN]]
  32. br label %if.end, !dbg !15
  33. ; CHECK: br label %if.end, !dbg ![[BR:[0-9]+]]
  34. if.end: ; preds = %if.then, %entry
  35. ret void, !dbg !16
  36. ; CHECK: ret void, !dbg ![[END:[0-9]+]]
  37. }
  38. attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  39. !llvm.dbg.cu = !{!0}
  40. !llvm.module.flags = !{!7, !8}
  41. !llvm.ident = !{!9}
  42. !0 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 (trunk 199750) (llvm/trunk 199751)", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
  43. !1 = !DIFile(filename: "first-only.c", directory: ".")
  44. !2 = !{}
  45. !3 = !{!4}
  46. !4 = !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !1, scope: !5, type: !6, function: void (i32)* @foo, variables: !2)
  47. !5 = !DIFile(filename: "first-only.c", directory: ".")
  48. !6 = !DISubroutineType(types: !{null})
  49. !7 = !{i32 2, !"Dwarf Version", i32 4}
  50. !8 = !{i32 1, !"Debug Info Version", i32 3}
  51. !9 = !{!"clang version 3.5 (trunk 199750) (llvm/trunk 199751)"}
  52. !10 = !DILocation(line: 3, scope: !11)
  53. !11 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !4)
  54. ; CHECK: ![[FOO:[0-9]+]] = !DISubprogram(name: "foo"
  55. ; CHECK: ![[BLOCK1:[0-9]+]] = distinct !DILexicalBlock(scope: ![[FOO]],{{.*}} line: 3)
  56. !12 = !DILocation(line: 3, scope: !13)
  57. !13 = distinct !DILexicalBlock(line: 3, column: 0, file: !1, scope: !11)
  58. ; CHECK: !DILexicalBlockFile(scope: ![[BLOCK2:[0-9]+]],{{.*}} discriminator: 1)
  59. !14 = !DILocation(line: 4, scope: !13)
  60. ; CHECK: ![[BLOCK2]] = distinct !DILexicalBlock(scope: ![[BLOCK1]],{{.*}} line: 3)
  61. !15 = !DILocation(line: 5, scope: !13)
  62. ; CHECK: ![[THEN]] = !DILocation(line: 4, scope: ![[BLOCK2]])
  63. !16 = !DILocation(line: 6, scope: !4)
  64. ; CHECK: ![[BR]] = !DILocation(line: 5, scope: ![[BLOCK2]])
  65. ; CHECK: ![[END]] = !DILocation(line: 6, scope: ![[FOO]])