xref: /llvm-project/llvm/test/DebugInfo/X86/dbg-value-funcarg3.ll (revision 2191d502a8576c5d46f8771d5f0d353eb525b9b9)
1; RUN: llc -mtriple=x86_64-unknown-linux-gnu -start-after=codegenprepare -stop-before=finalize-isel -o - %s -experimental-debug-variable-locations=false | FileCheck %s
2; RUN: llc -mtriple=x86_64-unknown-linux-gnu -start-after=codegenprepare -stop-before=finalize-isel -o - %s -experimental-debug-variable-locations=true | FileCheck %s --check-prefixes=INSTRREF
3
4; Input to this test looked like this and was compiled using: clang -g -O1 -mllvm -stop-after=codegenprepare -S
5;
6;    int fn1(long t1) {
7;      return t;
8;    }
9;
10
11; Catch metadata references for involved variables.
12;
13; CHECK-DAG: ![[T1:.*]] = !DILocalVariable(name: "t1"
14; INSTRREF-DAG: ![[T1:.*]] = !DILocalVariable(name: "t1"
15
16
17define dso_local i32 @fn1(i64 %t1) local_unnamed_addr #0 !dbg !7 {
18; We expect that the same width COPY reuses the debug location,
19; but the width narrowing COPY does not.
20;
21; CHECK-LABEL: name:            fn1
22; CHECK: DBG_VALUE $rdi, $noreg, ![[T1]], !DIExpression(),
23; CHECK-NEXT: %0:gr64 = COPY $rdi
24; CHECK-NEXT: DBG_VALUE %0, $noreg, ![[T1]], !DIExpression(),
25; CHECK-NEXT: %1:gr32 = COPY %0.sub_32bit
26; CHECK-NEXT: COPY
27; CHECK-NEXT: RET
28;
29;; For instr-ref, no copies should be considered. Because argumenst are
30;; Special, we don't label them in the same way, and currently emit a
31;; DBG_VALUE for the physreg.
32; INSTRREF-LABEL: name:            fn1
33; INSTRREF: DBG_VALUE $rdi, $noreg, ![[T1]], !DIExpression(),
34; INSTRREF-NEXT: %0:gr64 = COPY $rdi
35; INSTRREF-NEXT: %1:gr32 = COPY %0.sub_32bit
36; INSTRREF-NEXT: COPY
37; INSTRREF-NEXT: RET
38
39entry:
40  call void @llvm.dbg.value(metadata i64 %t1, metadata !13, metadata !DIExpression()), !dbg !14
41  %0 = trunc i64 %t1 to i32, !dbg !15
42  ret i32 %0, !dbg !16
43}
44
45declare void @llvm.dbg.value(metadata, metadata, metadata) #1
46
47attributes #0 = { norecurse nounwind readnone uwtable }
48attributes #1 = { nounwind readnone speculatable willreturn }
49
50!llvm.dbg.cu = !{!0}
51!llvm.module.flags = !{!3, !4, !5}
52!llvm.ident = !{!6}
53
54!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0 (git@github.com:tbosch/llvm-project.git 0b11aed869bf09ba60
55d7ed17334cf0b76e6a5922)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
56!1 = !DIFile(filename: "test.cc", directory: "")
57!2 = !{}
58!3 = !{i32 7, !"Dwarf Version", i32 4}
59!4 = !{i32 2, !"Debug Info Version", i32 3}
60!5 = !{i32 1, !"wchar_size", i32 4}
61!6 = !{!"clang version 11.0.0 (git@github.com:tbosch/llvm-project.git 0b11aed869bf09ba60d7ed17334cf0b76e6a5922)"}
62!7 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12)
63!8 = !DISubroutineType(types: !9)
64!9 = !{!10, !11}
65!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
66!11 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
67!12 = !{!13}
68!13 = !DILocalVariable(name: "t1", arg: 1, scope: !7, file: !1, line: 1, type: !11)
69!14 = !DILocation(line: 0, scope: !7)
70!15 = !DILocation(line: 2, column: 10, scope: !7)
71!16 = !DILocation(line: 2, column: 3, scope: !7)
72