• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -debug-entry-values %s -o - -filetype=obj \
2; RUN:   | llvm-dwarfdump -verify - | FileCheck %s
3;
4; CHECK: No errors.
5;
6; The source code of the test case:
7;
8;extern int fn1();
9;extern int fn3(int);
10;
11;__attribute__((noinline))
12;void
13;fn2 (int *arg) {
14;  int a = ++(*arg);
15;  fn3 (a);
16;}
17;
18;__attribute__((noinline))
19;int f() {
20;  int x = fn1();
21;  fn2 (&x);
22;  return 0;
23;}
24;
25; ModuleID = 'test.c'
26target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27target triple = "x86_64-unknown-linux-gnu"
28
29; Function Attrs: noinline nounwind uwtable
30define dso_local void @fn2(i32* nocapture %arg) local_unnamed_addr !dbg !15 {
31entry:
32  call void @llvm.dbg.value(metadata i32* %arg, metadata !20, metadata !DIExpression()), !dbg !22
33  %0 = load i32, i32* %arg, align 4, !dbg !23
34  %inc = add nsw i32 %0, 1, !dbg !23
35  store i32 %inc, i32* %arg, align 4, !dbg !23
36  call void @llvm.dbg.value(metadata i32 %inc, metadata !21, metadata !DIExpression()), !dbg !22
37  %call = tail call i32 @fn3(i32 %inc), !dbg !23
38  ret void, !dbg !23
39}
40
41; Function Attrs: argmemonly nounwind willreturn
42declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture)
43
44declare !dbg !4 dso_local i32 @fn3(i32) local_unnamed_addr
45
46; Function Attrs: argmemonly nounwind willreturn
47declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture)
48
49; Function Attrs: noinline nounwind uwtable
50define dso_local i32 @f() local_unnamed_addr !dbg !24 {
51entry:
52  %x = alloca i32, align 4
53  %0 = bitcast i32* %x to i8*, !dbg !29
54  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0), !dbg !29
55  %call = tail call i32 (...) @fn1() #4, !dbg !29
56  call void @llvm.dbg.value(metadata i32 %call, metadata !28, metadata !DIExpression()), !dbg !30
57  store i32 %call, i32* %x, align 4, !dbg !29
58  call void @llvm.dbg.value(metadata i32* %x, metadata !28, metadata !DIExpression(DW_OP_deref)), !dbg !30
59  call void @fn2(i32* nonnull %x), !dbg !29
60  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %0), !dbg !29
61  ret i32 0, !dbg !29
62}
63
64declare !dbg !8 dso_local i32 @fn1(...) local_unnamed_addr
65
66; Function Attrs: nounwind readnone speculatable willreturn
67declare void @llvm.dbg.value(metadata, metadata, metadata)
68
69!llvm.dbg.cu = !{!0}
70!llvm.module.flags = !{!11, !12, !13}
71!llvm.ident = !{!14}
72
73!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
74!1 = !DIFile(filename: "test.c", directory: "dir")
75!2 = !{}
76!3 = !{!4, !8}
77!4 = !DISubprogram(name: "fn3", scope: !1, file: !1, line: 2, type: !5, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
78!5 = !DISubroutineType(types: !6)
79!6 = !{!7, !7}
80!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
81!8 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !9, spFlags: DISPFlagOptimized, retainedNodes: !2)
82!9 = !DISubroutineType(types: !10)
83!10 = !{!7, null}
84!11 = !{i32 2, !"Dwarf Version", i32 4}
85!12 = !{i32 2, !"Debug Info Version", i32 3}
86!13 = !{i32 1, !"wchar_size", i32 4}
87!14 = !{!"clang version 10.0.0"}
88!15 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 6, type: !16, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !19)
89!16 = !DISubroutineType(types: !17)
90!17 = !{null, !18}
91!18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
92!19 = !{!20, !21}
93!20 = !DILocalVariable(name: "arg", arg: 1, scope: !15, file: !1, line: 6, type: !18)
94!21 = !DILocalVariable(name: "a", scope: !15, file: !1, line: 7, type: !7)
95!22 = !DILocation(line: 0, scope: !15)
96!23 = !DILocation(line: 7, column: 11, scope: !15)
97!24 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 12, type: !25, scopeLine: 12, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !27)
98!25 = !DISubroutineType(types: !17)
99!26 = !{!7}
100!27 = !{!28}
101!28 = !DILocalVariable(name: "x", scope: !24, file: !1, line: 13, type: !7)
102!29 = !DILocation(line: 13, column: 3, scope: !24)
103!30 = !DILocation(line: 0, scope: !24)
104