blob: 9a6b6aa46d55d710c781106923649adc2ed5c253 [file] [log] [blame]
Wolfgang Piebdfad9b22016-08-15 18:18:26 +00001; REQUIRES: object-emission
2
3; Check that when variables are allocated on the stack we generate debug locations
4; for the stack location directly instead of generating a register+offset indirection.
5
Reid Klecknera7b04a52016-08-15 22:54:26 +00006; RUN: llc -O2 -filetype=obj -disable-post-ra -mtriple=x86_64-unknown-linux-gnu < %s \
Wolfgang Pieb12cd6dd2016-08-15 22:39:39 +00007; RUN: | llvm-dwarfdump - | FileCheck %s
Wolfgang Piebdfad9b22016-08-15 18:18:26 +00008;
9; int data = 17;
10; int sum = 0;
11; int zero = 0;
12; int *ptr;
13;
14; extern void foo(int i, int *p);
15;
16; int main()
17; {
18; int val;
19; val = data;
20; foo(1, &val);
21; foo(2, &data);
22; return zero;
23; }
24;
25; CHECK: .debug_info contents
26; CHECK: DW_TAG_subprogram
27; CHECK-NOT: NULL
28; CHECK: DW_TAG_variable
29; CHECK: DW_AT_location [DW_FORM_sec_offset] ([[DEBUGLOCOFFSET:0x[0-9a-f]+]]){{[[:space:]].*}}"val"
30
31; See that 'val' has at least one location entry with a DW_op_breg? operand.
32; The DWARF DW_op_breg* ops are encoded from 0x70 to 0x8f, but checking for an
33; op in the range from 0x70 to 0x7f should suffice because that range covers
34; all integer GPRs.
35;
36; CHECK: .debug_loc contents:
37; CHECK-NOT: .debug{{.*}} contents
38; CHECK: [[DEBUGLOCOFFSET]]: Beginning
39; CHECK-NOT: {{0x[0-9a-f]+}}: Beginning
40; CHECK: Location description: 7{{[0-9a-f] .*}}
41
42; ModuleID = 'frame.c'
43source_filename = "frame.c"
44
45@data = global i32 17, align 4
46@sum = local_unnamed_addr global i32 0, align 4
47@zero = local_unnamed_addr global i32 0, align 4
48@ptr = common local_unnamed_addr global i32* null, align 8
49
50; Function Attrs: nounwind uwtable
51define i32 @main() local_unnamed_addr !dbg !13 {
52entry:
53 %val = alloca i32, align 4
54 %0 = bitcast i32* %val to i8*, !dbg !18
55 call void @llvm.lifetime.start(i64 4, i8* %0), !dbg !18
56 %1 = load i32, i32* @data, align 4, !dbg !19, !tbaa !20
57 tail call void @llvm.dbg.value(metadata i32 %1, i64 0, metadata !17, metadata !24), !dbg !25
58 store i32 %1, i32* %val, align 4, !dbg !26, !tbaa !20
59 tail call void @llvm.dbg.value(metadata i32* %val, i64 0, metadata !17, metadata !27), !dbg !25
60 call void @foo(i32 1, i32* nonnull %val), !dbg !28
61 call void @foo(i32 2, i32* nonnull @data), !dbg !29
62 %2 = load i32, i32* @zero, align 4, !dbg !30, !tbaa !20
63 call void @llvm.lifetime.end(i64 4, i8* %0), !dbg !31
64 ret i32 %2, !dbg !32
65}
66
67; Function Attrs: argmemonly nounwind
68declare void @llvm.lifetime.start(i64, i8* nocapture)
69
70declare void @foo(i32, i32*) local_unnamed_addr
71
72; Function Attrs: argmemonly nounwind
73declare void @llvm.lifetime.end(i64, i8* nocapture)
74
75; Function Attrs: nounwind readnone
76declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
77
78!llvm.dbg.cu = !{!0}
79!llvm.module.flags = !{!10, !11}
80!llvm.ident = !{!12}
81
82!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (trunk 273961)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3)
83!1 = !DIFile(filename: "frame.c", directory: "/home/user/test")
84!2 = !{}
85!3 = !{!4, !6, !7, !8}
86!4 = distinct !DIGlobalVariable(name: "data", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32* @data)
87!5 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
88!6 = distinct !DIGlobalVariable(name: "sum", scope: !0, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, variable: i32* @sum)
89!7 = distinct !DIGlobalVariable(name: "zero", scope: !0, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, variable: i32* @zero)
90!8 = distinct !DIGlobalVariable(name: "ptr", scope: !0, file: !1, line: 4, type: !9, isLocal: false, isDefinition: true, variable: i32** @ptr)
91!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64, align: 64)
92!10 = !{i32 2, !"Dwarf Version", i32 4}
93!11 = !{i32 2, !"Debug Info Version", i32 3}
94!12 = !{!"clang version 3.9.0 (trunk 273961)"}
95!13 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 8, type: !14, isLocal: false, isDefinition: true, scopeLine: 9, isOptimized: true, unit: !0, variables: !16)
96!14 = !DISubroutineType(types: !15)
97!15 = !{!5}
98!16 = !{!17}
99!17 = !DILocalVariable(name: "val", scope: !13, file: !1, line: 10, type: !5)
100!18 = !DILocation(line: 10, column: 3, scope: !13)
101!19 = !DILocation(line: 11, column: 9, scope: !13)
102!20 = !{!21, !21, i64 0}
103!21 = !{!"int", !22, i64 0}
104!22 = !{!"omnipotent char", !23, i64 0}
105!23 = !{!"Simple C/C++ TBAA"}
106!24 = !DIExpression()
107!25 = !DILocation(line: 10, column: 7, scope: !13)
108!26 = !DILocation(line: 11, column: 7, scope: !13)
109!27 = !DIExpression(DW_OP_deref)
110!28 = !DILocation(line: 12, column: 3, scope: !13)
111!29 = !DILocation(line: 13, column: 3, scope: !13)
112!30 = !DILocation(line: 14, column: 10, scope: !13)
113!31 = !DILocation(line: 15, column: 1, scope: !13)
114!32 = !DILocation(line: 14, column: 3, scope: !13)