1 ; RUN: llc -O1 -filetype=obj -o - %s | llvm-dwarfdump -debug-dump=all - | FileCheck %s
2 ; Generated with -O1 from:
16 ; Test that we generate valid debug info for optimized code,
17 ; particularly variables that are described as constants and passed
19 ; rdar://problem/14874886
21 ; CHECK: .debug_info contents:
22 ; CHECK: DW_TAG_variable
24 ; CHECK: DW_AT_location [DW_FORM_data4] ([[LOC:.*]])
26 ; CHECK: DW_AT_name{{.*}}"i"
27 ; CHECK: .debug_loc contents:
30 ; CHECK: Beginning address offset: 0x0000000000000{{.*}}
31 ; CHECK: Ending address offset: [[C1:.*]]
32 ; CHECK: Location description: 11 03
34 ; CHECK: Beginning address offset: [[C1]]
35 ; CHECK: Ending address offset: [[C2:.*]]
36 ; CHECK: Location description: 11 07
37 ; rax, piece 0x00000004
38 ; CHECK: Beginning address offset: [[C2]]
39 ; CHECK: Ending address offset: [[R1:.*]]
40 ; CHECK: Location description: 50 93 04
42 ; CHECK: Beginning address offset: [[R1]]
43 ; CHECK: Ending address offset: [[R2:.*]]
44 ; CHECK: Location description: 75 00
46 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
47 target triple = "x86_64-apple-macosx10.9.0"
49 ; Function Attrs: nounwind ssp uwtable
50 define i32 @foo() #0 {
52 %i = alloca i32, align 4
53 call void @llvm.dbg.value(metadata i32 3, i64 0, metadata !10, metadata !MDExpression()), !dbg !15
54 %call = call i32 @f3(i32 3) #3, !dbg !16
55 call void @llvm.dbg.value(metadata i32 7, i64 0, metadata !10, metadata !MDExpression()), !dbg !18
56 %call1 = call i32 (...)* @f1() #3, !dbg !19
57 call void @llvm.dbg.value(metadata i32 %call1, i64 0, metadata !10, metadata !MDExpression()), !dbg !19
58 store i32 %call1, i32* %i, align 4, !dbg !19, !tbaa !20
59 call void @llvm.dbg.value(metadata i32* %i, i64 0, metadata !10, metadata !MDExpression()), !dbg !24
60 call void @f2(i32* %i) #3, !dbg !24
68 declare void @f2(i32*)
70 ; Function Attrs: nounwind readnone
71 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
73 attributes #0 = { nounwind ssp uwtable }
74 attributes #2 = { nounwind readnone }
75 attributes #3 = { nounwind }
78 !llvm.module.flags = !{!11, !12}
81 !0 = !MDCompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
82 !1 = !MDFile(filename: "dbg-value-const-byref.c", directory: "")
85 !4 = !MDSubprogram(name: "foo", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, scopeLine: 5, file: !1, scope: !5, type: !6, function: i32 ()* @foo, variables: !9)
86 !5 = !MDFile(filename: "dbg-value-const-byref.c", directory: "")
87 !6 = !MDSubroutineType(types: !7)
89 !8 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
91 !10 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "i", line: 6, scope: !4, file: !5, type: !8)
92 !11 = !{i32 2, !"Dwarf Version", i32 2}
93 !12 = !{i32 1, !"Debug Info Version", i32 3}
94 !13 = !{!"clang version 3.5.0 "}
96 !15 = !MDLocation(line: 6, scope: !4)
97 !16 = !MDLocation(line: 7, scope: !4)
99 !18 = !MDLocation(line: 8, scope: !4)
100 !19 = !MDLocation(line: 9, scope: !4)
101 !20 = !{!21, !21, i64 0}
102 !21 = !{!"int", !22, i64 0}
103 !22 = !{!"omnipotent char", !23, i64 0}
104 !23 = !{!"Simple C/C++ TBAA"}
105 !24 = !MDLocation(line: 10, scope: !4)
106 !25 = !MDLocation(line: 11, scope: !4)