debug-info-duplicate-calls.ll 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ; RUN: opt < %s -always-inline -S | FileCheck %s
  2. ; Original input generated from clang -emit-llvm -S -c -mllvm -disable-llvm-optzns
  3. ;
  4. ; #define CALLS1 f2(); f2();
  5. ; #define CALLS2 f4(); f4();
  6. ; void f1();
  7. ; inline __attribute__((always_inline)) void f2() {
  8. ; f1();
  9. ; }
  10. ; inline __attribute__((always_inline)) void f3() {
  11. ; CALLS1
  12. ; }
  13. ; inline __attribute__((always_inline)) void f4() {
  14. ; f3();
  15. ; }
  16. ; void f() {
  17. ; CALLS2
  18. ; }
  19. ; There should be unique locations for all 4 of these instructions, correctly
  20. ; describing the inlining that has occurred, even in the face of duplicate call
  21. ; site locations.
  22. ; The nomenclature used for the tags here is <function name>[cs<number>] where
  23. ; 'cs' is an abbreviation for 'call site' and the number indicates which call
  24. ; site from within the named function this is. (so, given the above inlining, we
  25. ; should have 4 calls to 'f1', two from the first call to f4 and two from the
  26. ; second call to f4)
  27. ; CHECK: call void @_Z2f1v(), !dbg [[fcs1_f4_f3cs1_f2:![0-9]+]]
  28. ; CHECK: call void @_Z2f1v(), !dbg [[fcs1_f4_f3cs2_f2:![0-9]+]]
  29. ; CHECK: call void @_Z2f1v(), !dbg [[fcs2_f4_f3cs1_f2:![0-9]+]]
  30. ; CHECK: call void @_Z2f1v(), !dbg [[fcs2_f4_f3cs2_f2:![0-9]+]]
  31. ; CHECK-DAG: [[F:![0-9]+]] = !DISubprogram(name: "f"
  32. ; CHECK-DAG: [[F2:![0-9]+]] = !DISubprogram(name: "f2"
  33. ; CHECK-DAG: [[F3:![0-9]+]] = !DISubprogram(name: "f3"
  34. ; CHECK-DAG: [[F4:![0-9]+]] = !DISubprogram(name: "f4"
  35. ; CHECK: [[fcs1_f4_f3cs1_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs1_f4_f3cs1:![0-9]+]])
  36. ; CHECK: [[fcs1_f4_f3cs1]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs1_f4:![0-9]+]])
  37. ; CHECK: [[fcs1_f4]] = {{.*}}, scope: [[F4]], inlinedAt: [[fcs1:![0-9]+]])
  38. ; CHECK: [[fcs1]] = {{.*}}, scope: [[F]])
  39. ; CHECK: [[fcs1_f4_f3cs2_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs1_f4_f3cs2:![0-9]+]])
  40. ; CHECK: [[fcs1_f4_f3cs2]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs1_f4]])
  41. ; CHECK: [[fcs2_f4_f3cs1_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs2_f4_f3cs1:![0-9]+]])
  42. ; CHECK: [[fcs2_f4_f3cs1]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs2_f4:![0-9]+]])
  43. ; CHECK: [[fcs2_f4]] = {{.*}}, scope: [[F4]], inlinedAt: [[fcs2:![0-9]+]])
  44. ; CHECK: [[fcs2]] = {{.*}}, scope: [[F]])
  45. ; CHECK: [[fcs2_f4_f3cs2_f2]] = {{.*}}, scope: [[F2]], inlinedAt: [[fcs2_f4_f3cs2:![0-9]+]])
  46. ; CHECK: [[fcs2_f4_f3cs2]] = {{.*}}, scope: [[F3]], inlinedAt: [[fcs2_f4]])
  47. $_Z2f4v = comdat any
  48. $_Z2f3v = comdat any
  49. $_Z2f2v = comdat any
  50. ; Function Attrs: uwtable
  51. define void @_Z1fv() #0 {
  52. entry:
  53. call void @_Z2f4v(), !dbg !13
  54. call void @_Z2f4v(), !dbg !13
  55. ret void, !dbg !14
  56. }
  57. ; Function Attrs: alwaysinline inlinehint uwtable
  58. define linkonce_odr void @_Z2f4v() #1 comdat {
  59. entry:
  60. call void @_Z2f3v(), !dbg !15
  61. ret void, !dbg !16
  62. }
  63. ; Function Attrs: alwaysinline inlinehint uwtable
  64. define linkonce_odr void @_Z2f3v() #1 comdat {
  65. entry:
  66. call void @_Z2f2v(), !dbg !17
  67. call void @_Z2f2v(), !dbg !17
  68. ret void, !dbg !18
  69. }
  70. ; Function Attrs: alwaysinline inlinehint uwtable
  71. define linkonce_odr void @_Z2f2v() #1 comdat {
  72. entry:
  73. call void @_Z2f1v(), !dbg !19
  74. ret void, !dbg !20
  75. }
  76. declare void @_Z2f1v() #2
  77. attributes #0 = { 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" }
  78. attributes #1 = { alwaysinline inlinehint 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" }
  79. attributes #2 = { "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" }
  80. !llvm.dbg.cu = !{!0}
  81. !llvm.module.flags = !{!10, !11}
  82. !llvm.ident = !{!12}
  83. !0 = !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.7.0 (trunk 226474) (llvm/trunk 226478)", isOptimized: false, emissionKind: 2, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
  84. !1 = !DIFile(filename: "debug-info-duplicate-calls.cpp", directory: "/tmp/dbginfo")
  85. !2 = !{}
  86. !3 = !{!4, !7, !8, !9}
  87. !4 = !DISubprogram(name: "f", line: 13, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 13, file: !1, scope: !5, type: !6, function: void ()* @_Z1fv, variables: !2)
  88. !5 = !DIFile(filename: "debug-info-duplicate-calls.cpp", directory: "/tmp/dbginfo")
  89. !6 = !DISubroutineType(types: !2)
  90. !7 = !DISubprogram(name: "f4", line: 10, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 10, file: !1, scope: !5, type: !6, function: void ()* @_Z2f4v, variables: !2)
  91. !8 = !DISubprogram(name: "f3", line: 7, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !1, scope: !5, type: !6, function: void ()* @_Z2f3v, variables: !2)
  92. !9 = !DISubprogram(name: "f2", line: 4, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 4, file: !1, scope: !5, type: !6, function: void ()* @_Z2f2v, variables: !2)
  93. !10 = !{i32 2, !"Dwarf Version", i32 4}
  94. !11 = !{i32 2, !"Debug Info Version", i32 3}
  95. !12 = !{!"clang version 3.7.0 (trunk 226474) (llvm/trunk 226478)"}
  96. !13 = !DILocation(line: 14, column: 3, scope: !4)
  97. !14 = !DILocation(line: 15, column: 1, scope: !4)
  98. !15 = !DILocation(line: 11, column: 3, scope: !7)
  99. !16 = !DILocation(line: 12, column: 1, scope: !7)
  100. !17 = !DILocation(line: 8, column: 3, scope: !8)
  101. !18 = !DILocation(line: 9, column: 1, scope: !8)
  102. !19 = !DILocation(line: 5, column: 3, scope: !9)
  103. !20 = !DILocation(line: 6, column: 1, scope: !9)