blob: 766b72ebc417f867b9a6d422e8e0a1f1f2aa228e [file] [log] [blame]
Adrian Prantl75ce62a2014-04-01 21:04:18 +00001; RUN: llc -O1 -filetype=obj -o - %s | llvm-dwarfdump -debug-dump=all - | FileCheck %s
2; Generated with -O1 from:
3; int f1();
4; void f2(int*);
5; int f3(int);
6;
7; int foo() {
8; int i = 3;
9; f3(i);
10; i = 7;
11; i = f1();
12; f2(&i);
13; return 0;
14; }
15;
16; Test that we generate valid debug info for optimized code,
Alp Toker16f98b22014-04-09 14:47:27 +000017; particularly variables that are described as constants and passed
Adrian Prantl75ce62a2014-04-01 21:04:18 +000018; by reference.
19; rdar://problem/14874886
20;
21; CHECK: .debug_info contents:
22; CHECK: DW_TAG_variable
Adrian Prantl75ce62a2014-04-01 21:04:18 +000023; CHECK-NOT: DW_TAG
24; CHECK: DW_AT_location [DW_FORM_data4] ([[LOC:.*]])
David Blaikieeb1a2722014-06-13 22:18:23 +000025; CHECK-NOT: DW_TAG
26; CHECK: DW_AT_name{{.*}}"i"
Adrian Prantl75ce62a2014-04-01 21:04:18 +000027; CHECK: .debug_loc contents:
28; CHECK: [[LOC]]:
Adrian Prantl3bdcb522014-04-11 17:49:47 +000029; consts 0x00000003
Adrian Prantl75ce62a2014-04-01 21:04:18 +000030; CHECK: Beginning address offset: 0x0000000000000{{.*}}
31; CHECK: Ending address offset: [[C1:.*]]
Adrian Prantl3bdcb522014-04-11 17:49:47 +000032; CHECK: Location description: 11 03
33; consts 0x00000007
Adrian Prantl75ce62a2014-04-01 21:04:18 +000034; CHECK: Beginning address offset: [[C1]]
35; CHECK: Ending address offset: [[C2:.*]]
Adrian Prantl3bdcb522014-04-11 17:49:47 +000036; CHECK: Location description: 11 07
Adrian Prantl75ce62a2014-04-01 21:04:18 +000037; rax, piece 0x00000004
38; CHECK: Beginning address offset: [[C2]]
39; CHECK: Ending address offset: [[R1:.*]]
40; CHECK: Location description: 50 93 04
Adrian Prantl32da8892014-04-25 20:49:25 +000041; rdi+0
42; CHECK: Beginning address offset: [[R1]]
43; CHECK: Ending address offset: [[R2:.*]]
44; CHECK: Location description: 75 00
Adrian Prantl75ce62a2014-04-01 21:04:18 +000045;
46target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
47target triple = "x86_64-apple-macosx10.9.0"
48
49; Function Attrs: nounwind ssp uwtable
50define i32 @foo() #0 {
51entry:
52 %i = alloca i32, align 4
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000053 call void @llvm.dbg.value(metadata i32 3, i64 0, metadata !10, metadata !MDExpression()), !dbg !15
Adrian Prantl75ce62a2014-04-01 21:04:18 +000054 %call = call i32 @f3(i32 3) #3, !dbg !16
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000055 call void @llvm.dbg.value(metadata i32 7, i64 0, metadata !10, metadata !MDExpression()), !dbg !18
David Blaikie23af6482015-04-16 23:24:18 +000056 %call1 = call i32 (...) @f1() #3, !dbg !19
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000057 call void @llvm.dbg.value(metadata i32 %call1, i64 0, metadata !10, metadata !MDExpression()), !dbg !19
Adrian Prantl75ce62a2014-04-01 21:04:18 +000058 store i32 %call1, i32* %i, align 4, !dbg !19, !tbaa !20
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000059 call void @llvm.dbg.value(metadata i32* %i, i64 0, metadata !10, metadata !MDExpression()), !dbg !24
Adrian Prantl75ce62a2014-04-01 21:04:18 +000060 call void @f2(i32* %i) #3, !dbg !24
61 ret i32 0, !dbg !25
62}
63
64declare i32 @f3(i32)
65
66declare i32 @f1(...)
67
68declare void @f2(i32*)
69
70; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000071declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
Adrian Prantl75ce62a2014-04-01 21:04:18 +000072
73attributes #0 = { nounwind ssp uwtable }
74attributes #2 = { nounwind readnone }
75attributes #3 = { nounwind }
76
77!llvm.dbg.cu = !{!0}
78!llvm.module.flags = !{!11, !12}
79!llvm.ident = !{!13}
80
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000081!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: "")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000083!2 = !{}
84!3 = !{!4}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000085!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)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000088!7 = !{!8}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000089!8 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000090!9 = !{!10}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000091!10 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "i", line: 6, scope: !4, file: !5, type: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000092!11 = !{i32 2, !"Dwarf Version", i32 2}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000093!12 = !{i32 1, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000094!13 = !{!"clang version 3.5.0 "}
95!14 = !{i32 3}
Duncan P. N. Exon Smith98854692015-01-14 22:27:36 +000096!15 = !MDLocation(line: 6, scope: !4)
97!16 = !MDLocation(line: 7, scope: !4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000098!17 = !{i32 7}
Duncan P. N. Exon Smith98854692015-01-14 22:27:36 +000099!18 = !MDLocation(line: 8, scope: !4)
100!19 = !MDLocation(line: 9, scope: !4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000101!20 = !{!21, !21, i64 0}
102!21 = !{!"int", !22, i64 0}
103!22 = !{!"omnipotent char", !23, i64 0}
104!23 = !{!"Simple C/C++ TBAA"}
Duncan P. N. Exon Smith98854692015-01-14 22:27:36 +0000105!24 = !MDLocation(line: 10, scope: !4)
106!25 = !MDLocation(line: 11, scope: !4)