no-discriminators.ll 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ; RUN: opt < %s -add-discriminators -S | FileCheck %s
  2. ; We should not generate discriminators for DWARF versions prior to 4.
  3. ;
  4. ; Original code:
  5. ;
  6. ; int foo(long i) {
  7. ; if (i < 5) return 2; else return 90;
  8. ; }
  9. ;
  10. ; None of the !dbg nodes associated with the if() statement should be
  11. ; altered. If they are, it means that the discriminators pass added a
  12. ; new lexical scope.
  13. define i32 @foo(i64 %i) #0 {
  14. entry:
  15. %retval = alloca i32, align 4
  16. %i.addr = alloca i64, align 8
  17. store i64 %i, i64* %i.addr, align 8
  18. call void @llvm.dbg.declare(metadata i64* %i.addr, metadata !13, metadata !DIExpression()), !dbg !14
  19. %0 = load i64, i64* %i.addr, align 8, !dbg !15
  20. ; CHECK: %0 = load i64, i64* %i.addr, align 8, !dbg ![[ENTRY:[0-9]+]]
  21. %cmp = icmp slt i64 %0, 5, !dbg !15
  22. ; CHECK: %cmp = icmp slt i64 %0, 5, !dbg ![[ENTRY:[0-9]+]]
  23. br i1 %cmp, label %if.then, label %if.else, !dbg !15
  24. ; CHECK: br i1 %cmp, label %if.then, label %if.else, !dbg ![[ENTRY:[0-9]+]]
  25. if.then: ; preds = %entry
  26. store i32 2, i32* %retval, !dbg !15
  27. br label %return, !dbg !15
  28. if.else: ; preds = %entry
  29. store i32 90, i32* %retval, !dbg !15
  30. br label %return, !dbg !15
  31. return: ; preds = %if.else, %if.then
  32. %1 = load i32, i32* %retval, !dbg !17
  33. ret i32 %1, !dbg !17
  34. }
  35. ; Function Attrs: nounwind readnone
  36. declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
  37. 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" }
  38. attributes #1 = { nounwind readnone }
  39. !llvm.dbg.cu = !{!0}
  40. !llvm.module.flags = !{!10, !11}
  41. !llvm.ident = !{!12}
  42. !0 = !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
  43. !1 = !DIFile(filename: "no-discriminators", 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: i32 (i64)* @foo, variables: !2)
  47. ; CHECK: ![[FOO:[0-9]+]] = !DISubprogram(name: "foo"
  48. !5 = !DIFile(filename: "no-discriminators", directory: ".")
  49. !6 = !DISubroutineType(types: !7)
  50. !7 = !{!8, !9}
  51. !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  52. !9 = !DIBasicType(tag: DW_TAG_base_type, name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
  53. !10 = !{i32 2, !"Dwarf Version", i32 2}
  54. ; CHECK: !{i32 2, !"Dwarf Version", i32 2}
  55. !11 = !{i32 1, !"Debug Info Version", i32 3}
  56. !12 = !{!"clang version 3.5.0 "}
  57. !13 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "i", line: 1, arg: 1, scope: !4, file: !5, type: !9)
  58. !14 = !DILocation(line: 1, scope: !4)
  59. !15 = !DILocation(line: 2, scope: !16)
  60. ; CHECK: ![[ENTRY]] = !DILocation(line: 2, scope: ![[BLOCK:[0-9]+]])
  61. !16 = distinct !DILexicalBlock(line: 2, column: 0, file: !1, scope: !4)
  62. ; CHECK: ![[BLOCK]] = distinct !DILexicalBlock(scope: ![[FOO]],{{.*}} line: 2)
  63. !17 = !DILocation(line: 3, scope: !4)