coverage2-dbg.ll 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. ; Test that coverage instrumentation does not lose debug location.
  2. ; RUN: opt < %s -sancov -sanitizer-coverage-level=2 -S | FileCheck %s
  3. ; C++ source:
  4. ; 1: void foo(int *a) {
  5. ; 2: if (a)
  6. ; 3: *a = 0;
  7. ; 4: }
  8. ; clang++ if.cc -O3 -g -S -emit-llvm
  9. ; and add sanitize_address to @_Z3fooPi
  10. target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  11. target triple = "x86_64-unknown-linux-gnu"
  12. ; Check that __sanitizer_cov call has !dgb pointing to the beginning
  13. ; of appropriate basic blocks.
  14. ; CHECK-LABEL:_Z3fooPi
  15. ; CHECK: call void @__sanitizer_cov(i32*{{.*}}), !dbg [[A:!.*]]
  16. ; CHECK: call void @__sanitizer_cov(i32*{{.*}}), !dbg [[B:!.*]]
  17. ; CHECK: call void @__sanitizer_cov(i32*{{.*}}), !dbg [[C:!.*]]
  18. ; CHECK: ret void
  19. ; CHECK: [[A]] = !DILocation(line: 1, scope: !{{.*}})
  20. ; CHECK: [[B]] = !DILocation(line: 3, column: 5, scope: !{{.*}})
  21. ; CHECK: [[C]] = !DILocation(line: 4, column: 1, scope: !{{.*}})
  22. define void @_Z3fooPi(i32* %a) #0 {
  23. entry:
  24. tail call void @llvm.dbg.value(metadata i32* %a, i64 0, metadata !11, metadata !DIExpression()), !dbg !15
  25. %tobool = icmp eq i32* %a, null, !dbg !16
  26. br i1 %tobool, label %if.end, label %if.then, !dbg !16
  27. if.then: ; preds = %entry
  28. store i32 0, i32* %a, align 4, !dbg !18, !tbaa !19
  29. br label %if.end, !dbg !18
  30. if.end: ; preds = %entry, %if.then
  31. ret void, !dbg !23
  32. }
  33. ; Function Attrs: nounwind readnone
  34. declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
  35. attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" sanitize_address}
  36. attributes #1 = { nounwind readnone }
  37. !llvm.dbg.cu = !{!0}
  38. !llvm.module.flags = !{!12, !13}
  39. !llvm.ident = !{!14}
  40. !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (217079)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
  41. !1 = !DIFile(filename: "if.cc", directory: "FOO")
  42. !2 = !{}
  43. !3 = !{!4}
  44. !4 = !DISubprogram(name: "foo", linkageName: "_Z3fooPi", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 1, file: !1, scope: !5, type: !6, function: void (i32*)* @_Z3fooPi, variables: !10)
  45. !5 = !DIFile(filename: "if.cc", directory: "FOO")
  46. !6 = !DISubroutineType(types: !7)
  47. !7 = !{null, !8}
  48. !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
  49. !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  50. !10 = !{!11}
  51. !11 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 1, arg: 1, scope: !4, file: !5, type: !8)
  52. !12 = !{i32 2, !"Dwarf Version", i32 4}
  53. !13 = !{i32 2, !"Debug Info Version", i32 3}
  54. !14 = !{!"clang version 3.6.0 (217079)"}
  55. !15 = !DILocation(line: 1, column: 15, scope: !4)
  56. !16 = !DILocation(line: 2, column: 7, scope: !17)
  57. !17 = distinct !DILexicalBlock(line: 2, column: 7, file: !1, scope: !4)
  58. !18 = !DILocation(line: 3, column: 5, scope: !17)
  59. !19 = !{!20, !20, i64 0}
  60. !20 = !{!"int", !21, i64 0}
  61. !21 = !{!"omnipotent char", !22, i64 0}
  62. !22 = !{!"Simple C/C++ TBAA"}
  63. !23 = !DILocation(line: 4, column: 1, scope: !4)