debug_info.ll 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ; RUN: opt < %s -asan -asan-module -asan-use-after-return=0 -S | FileCheck %s
  2. ; Checks that llvm.dbg.declare instructions are updated
  3. ; accordingly as we merge allocas.
  4. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
  5. target triple = "x86_64-unknown-linux-gnu"
  6. define i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address {
  7. entry:
  8. %p.addr = alloca i32, align 4
  9. %r = alloca i32, align 4
  10. store volatile i32 %p, i32* %p.addr, align 4
  11. call void @llvm.dbg.declare(metadata i32* %p.addr, metadata !10, metadata !DIExpression()), !dbg !11
  12. call void @llvm.dbg.declare(metadata i32* %r, metadata !12, metadata !DIExpression()), !dbg !14
  13. %0 = load i32, i32* %p.addr, align 4, !dbg !14
  14. %add = add nsw i32 %0, 1, !dbg !14
  15. store volatile i32 %add, i32* %r, align 4, !dbg !14
  16. %1 = load i32, i32* %r, align 4, !dbg !15
  17. ret i32 %1, !dbg !15
  18. }
  19. ; CHECK: define i32 @_Z3zzzi
  20. ; CHECK: entry:
  21. ; Verify that llvm.dbg.declare calls are in the entry basic block.
  22. ; CHECK-NOT: %entry
  23. ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]], metadata ![[OPDEREF:[0-9]+]])
  24. ; CHECK-NOT: %entry
  25. ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]], metadata ![[OPDEREF:[0-9]+]])
  26. declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
  27. !llvm.dbg.cu = !{!0}
  28. !llvm.module.flags = !{!17}
  29. !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 169314)", isOptimized: true, emissionKind: 0, file: !16, enums: !1, retainedTypes: !1, subprograms: !3, globals: !1)
  30. !1 = !{}
  31. !3 = !{!5}
  32. !5 = !DISubprogram(name: "zzz", linkageName: "_Z3zzzi", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !16, scope: !6, type: !7, function: i32 (i32)* @_Z3zzzi, variables: !1)
  33. !6 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo")
  34. !7 = !DISubroutineType(types: !8)
  35. !8 = !{!9, !9}
  36. !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  37. !10 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "p", line: 1, arg: 1, scope: !5, file: !6, type: !9)
  38. !11 = !DILocation(line: 1, scope: !5)
  39. !12 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "r", line: 2, scope: !13, file: !6, type: !9)
  40. ; Verify that debug descriptors for argument and local variable will be replaced
  41. ; with descriptors that end with OpDeref (encoded as 2).
  42. ; CHECK: ![[ARG_ID]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "p", arg: 1,{{.*}} line: 1
  43. ; CHECK: ![[OPDEREF]] = !DIExpression(DW_OP_deref)
  44. ; CHECK: ![[VAR_ID]] = !DILocalVariable(tag: DW_TAG_auto_variable, name: "r",{{.*}} line: 2
  45. ; Verify that there are no more variable descriptors.
  46. ; CHECK-NOT: !DILocalVariable(tag: DW_TAG_arg_variable
  47. ; CHECK-NOT: !DILocalVariable(tag: DW_TAG_auto_variable
  48. !13 = distinct !DILexicalBlock(line: 1, column: 0, file: !16, scope: !5)
  49. !14 = !DILocation(line: 2, scope: !13)
  50. !15 = !DILocation(line: 3, scope: !13)
  51. !16 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo")
  52. !17 = !{i32 1, !"Debug Info Version", i32 3}