incorrect-variable-debugloc1.ll 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ; REQUIRES: object-emission
  2. ; RUN: %llc_dwarf -O2 -dwarf-version 2 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
  3. ; RUN: %llc_dwarf -O2 -dwarf-version 3 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF23
  4. ; RUN: %llc_dwarf -O2 -dwarf-version 4 -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF4
  5. ; This is a test for PR21176.
  6. ; DW_OP_const <const> doesn't describe a constant value, but a value at a constant address.
  7. ; The proper way to describe a constant value is DW_OP_constu <const>, DW_OP_stack_value.
  8. ; For values < 32 we emit the canonical DW_OP_lit<const>.
  9. ; Generated with clang -S -emit-llvm -g -O2 test.cpp
  10. ; extern int func();
  11. ;
  12. ; int main()
  13. ; {
  14. ; volatile int c = 13;
  15. ; c = func();
  16. ; return c;
  17. ; }
  18. ; CHECK: DW_TAG_variable
  19. ; CHECK: DW_AT_location
  20. ; CHECK-NOT: DW_AT
  21. ; DWARF23: DW_OP_lit13{{$}}
  22. ; DWARF4: DW_OP_lit13, DW_OP_stack_value{{$}}
  23. ; Function Attrs: uwtable
  24. define i32 @main() #0 !dbg !4 {
  25. entry:
  26. %c = alloca i32, align 4
  27. tail call void @llvm.dbg.value(metadata i32 13, metadata !10, metadata !16), !dbg !17
  28. store volatile i32 13, i32* %c, align 4, !dbg !18
  29. %call = tail call i32 @_Z4funcv(), !dbg !19
  30. tail call void @llvm.dbg.value(metadata i32 %call, metadata !10, metadata !16), !dbg !17
  31. store volatile i32 %call, i32* %c, align 4, !dbg !19
  32. tail call void @llvm.dbg.value(metadata i32* %c, metadata !10, metadata !21), !dbg !17
  33. %c.0.c.0. = load volatile i32, i32* %c, align 4, !dbg !20
  34. ret i32 %c.0.c.0., !dbg !20
  35. }
  36. declare i32 @_Z4funcv() #1
  37. ; Function Attrs: nounwind readnone
  38. declare void @llvm.dbg.value(metadata, metadata, metadata) #2
  39. attributes #0 = { 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" }
  40. attributes #1 = { "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" }
  41. attributes #2 = { nounwind readnone }
  42. !llvm.dbg.cu = !{!0}
  43. !llvm.module.flags = !{!12, !13}
  44. !llvm.ident = !{!14}
  45. !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (trunk 223522)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
  46. !1 = !DIFile(filename: "test.cpp", directory: "/home/kromanova/ngh/ToT_latest/llvm/test/DebugInfo")
  47. !2 = !{}
  48. !4 = distinct !DISubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 4, file: !1, scope: !5, type: !6, retainedNodes: !9)
  49. !5 = !DIFile(filename: "test.cpp", directory: "/home/kromanova/ngh/ToT_latest/llvm/test/DebugInfo")
  50. !6 = !DISubroutineType(types: !7)
  51. !7 = !{!8}
  52. !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
  53. !9 = !{!10}
  54. !10 = !DILocalVariable(name: "c", line: 5, scope: !4, file: !5, type: !11)
  55. !11 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !8)
  56. !12 = !{i32 2, !"Dwarf Version", i32 2}
  57. !13 = !{i32 2, !"Debug Info Version", i32 3}
  58. !14 = !{!"clang version 3.6.0 (trunk 223522)"}
  59. !15 = !{i32 13}
  60. !16 = !DIExpression()
  61. !17 = !DILocation(line: 5, column: 16, scope: !4)
  62. !18 = !DILocation(line: 5, column: 3, scope: !4)
  63. !19 = !DILocation(line: 6, column: 7, scope: !4)
  64. !20 = !DILocation(line: 7, column: 3, scope: !4)
  65. !21 = !DIExpression(DW_OP_deref)