varargs.ll 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ; RUN: %llc_dwarf -O0 -filetype=obj -o %t.o %s
  2. ; RUN: llvm-dwarfdump -v -debug-info %t.o | FileCheck %s
  3. ; REQUIRES: object-emission
  4. ;
  5. ; Test debug info for variadic function arguments.
  6. ; Created from tools/clang/tests/CodeGenCXX/debug-info-varargs.cpp
  7. ;
  8. ; The ... parameter of variadic should be emitted as
  9. ; DW_TAG_unspecified_parameters.
  10. ;
  11. ; Normal variadic function.
  12. ; void b(int c, ...);
  13. ;
  14. ; CHECK: DW_TAG_subprogram
  15. ; CHECK-NOT: DW_TAG
  16. ; CHECK: DW_AT_name {{.*}} "a"
  17. ; CHECK-NOT: DW_TAG
  18. ; CHECK: DW_TAG_formal_parameter
  19. ; CHECK-NOT: DW_TAG
  20. ; CHECK: DW_TAG_formal_parameter
  21. ; CHECK-NOT: DW_TAG
  22. ; CHECK: DW_TAG_unspecified_parameters
  23. ;
  24. ; CHECK: DW_TAG_subprogram
  25. ; CHECK-NOT: DW_TAG
  26. ; CHECK: DW_AT_name {{.*}} "b"
  27. ; CHECK-NOT: DW_TAG
  28. ; CHECK: DW_TAG_formal_parameter
  29. ; CHECK-NOT: DW_TAG
  30. ; CHECK: DW_TAG_variable
  31. ; CHECK-NOT: DW_TAG
  32. ; CHECK: DW_TAG_variable
  33. ; CHECK-NOT: DW_TAG
  34. ; CHECK: DW_TAG_unspecified_parameters
  35. ;
  36. ; Variadic C++ member function.
  37. ; struct A { void a(int c, ...); }
  38. ;
  39. ; Variadic function pointer.
  40. ; void (*fptr)(int, ...);
  41. ;
  42. ; CHECK: DW_TAG_subroutine_type
  43. ; CHECK-NOT: DW_TAG
  44. ; CHECK: DW_TAG_formal_parameter
  45. ; CHECK-NOT: DW_TAG
  46. ; CHECK: DW_TAG_unspecified_parameters
  47. ;
  48. ; ModuleID = 'llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp'
  49. %struct.A = type { i8 }
  50. ; Function Attrs: nounwind ssp uwtable
  51. define void @_Z1biz(i32 %c, ...) #0 !dbg !14 {
  52. %1 = alloca i32, align 4
  53. %a = alloca %struct.A, align 1
  54. %fptr = alloca void (i32, ...)*, align 8
  55. store i32 %c, i32* %1, align 4
  56. call void @llvm.dbg.declare(metadata i32* %1, metadata !21, metadata !DIExpression()), !dbg !22
  57. call void @llvm.dbg.declare(metadata %struct.A* %a, metadata !23, metadata !DIExpression()), !dbg !24
  58. call void @llvm.dbg.declare(metadata void (i32, ...)** %fptr, metadata !25, metadata !DIExpression(DW_OP_deref)), !dbg !27
  59. store void (i32, ...)* @_Z1biz, void (i32, ...)** %fptr, align 8, !dbg !27
  60. ret void, !dbg !28
  61. }
  62. ; Function Attrs: nounwind readnone
  63. declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
  64. attributes #0 = { nounwind ssp uwtable }
  65. attributes #1 = { nounwind readnone }
  66. !llvm.dbg.cu = !{!0}
  67. !llvm.module.flags = !{!18, !19}
  68. !llvm.ident = !{!20}
  69. !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
  70. !1 = !DIFile(filename: "llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", directory: "radar/13690847")
  71. !2 = !{}
  72. !3 = !{!4}
  73. !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 3, size: 8, align: 8, file: !1, elements: !5, identifier: "_ZTS1A")
  74. !5 = !{!6}
  75. !6 = !DISubprogram(name: "a", linkageName: "_ZN1A1aEiz", line: 6, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 6, file: !1, scope: !4, type: !7)
  76. !7 = !DISubroutineType(types: !8)
  77. !8 = !{null, !9, !10, null}
  78. !9 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
  79. !10 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  80. !14 = distinct !DISubprogram(name: "b", linkageName: "_Z1biz", line: 13, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 13, file: !1, scope: !15, type: !16, retainedNodes: !2)
  81. !15 = !DIFile(filename: "llvm/tools/clang/test/CodeGenCXX/debug-info-varargs.cpp", directory: "radar/13690847")
  82. !16 = !DISubroutineType(types: !17)
  83. !17 = !{null, !10, null}
  84. !18 = !{i32 2, !"Dwarf Version", i32 2}
  85. !19 = !{i32 1, !"Debug Info Version", i32 3}
  86. !20 = !{!"clang version 3.5 "}
  87. !21 = !DILocalVariable(name: "c", line: 13, arg: 1, scope: !14, file: !15, type: !10)
  88. !22 = !DILocation(line: 13, scope: !14)
  89. !23 = !DILocalVariable(name: "a", line: 16, scope: !14, file: !15, type: !4)
  90. !24 = !DILocation(line: 16, scope: !14)
  91. ; Manually modifed to avoid dependence on pointer size
  92. !25 = !DILocalVariable(name: "fptr", line: 18, scope: !14, file: !15, type: !26)
  93. !26 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16)
  94. !27 = !DILocation(line: 18, scope: !14)
  95. !28 = !DILocation(line: 22, scope: !14)