xref: /llvm-project/llvm/test/DebugInfo/X86/dbg-value-funcarg3.ll (revision 2191d502a8576c5d46f8771d5f0d353eb525b9b9)
11dc0e47cSJeremy Morse; 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*2191d502SJeremy Morse; 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
36a471403STobias Bosch
46a471403STobias Bosch; Input to this test looked like this and was compiled using: clang -g -O1 -mllvm -stop-after=codegenprepare -S
56a471403STobias Bosch;
66a471403STobias Bosch;    int fn1(long t1) {
76a471403STobias Bosch;      return t;
86a471403STobias Bosch;    }
96a471403STobias Bosch;
106a471403STobias Bosch
116a471403STobias Bosch; Catch metadata references for involved variables.
126a471403STobias Bosch;
136a471403STobias Bosch; CHECK-DAG: ![[T1:.*]] = !DILocalVariable(name: "t1"
14*2191d502SJeremy Morse; INSTRREF-DAG: ![[T1:.*]] = !DILocalVariable(name: "t1"
156a471403STobias Bosch
166a471403STobias Bosch
176a471403STobias Boschdefine dso_local i32 @fn1(i64 %t1) local_unnamed_addr #0 !dbg !7 {
186a471403STobias Bosch; We expect that the same width COPY reuses the debug location,
196a471403STobias Bosch; but the width narrowing COPY does not.
206a471403STobias Bosch;
216a471403STobias Bosch; CHECK-LABEL: name:            fn1
226a471403STobias Bosch; CHECK: DBG_VALUE $rdi, $noreg, ![[T1]], !DIExpression(),
236a471403STobias Bosch; CHECK-NEXT: %0:gr64 = COPY $rdi
246a471403STobias Bosch; CHECK-NEXT: DBG_VALUE %0, $noreg, ![[T1]], !DIExpression(),
256a471403STobias Bosch; CHECK-NEXT: %1:gr32 = COPY %0.sub_32bit
266a471403STobias Bosch; CHECK-NEXT: COPY
276a471403STobias Bosch; CHECK-NEXT: RET
28*2191d502SJeremy Morse;
29*2191d502SJeremy Morse;; For instr-ref, no copies should be considered. Because argumenst are
30*2191d502SJeremy Morse;; Special, we don't label them in the same way, and currently emit a
31*2191d502SJeremy Morse;; DBG_VALUE for the physreg.
32*2191d502SJeremy Morse; INSTRREF-LABEL: name:            fn1
33*2191d502SJeremy Morse; INSTRREF: DBG_VALUE $rdi, $noreg, ![[T1]], !DIExpression(),
34*2191d502SJeremy Morse; INSTRREF-NEXT: %0:gr64 = COPY $rdi
35*2191d502SJeremy Morse; INSTRREF-NEXT: %1:gr32 = COPY %0.sub_32bit
36*2191d502SJeremy Morse; INSTRREF-NEXT: COPY
37*2191d502SJeremy Morse; INSTRREF-NEXT: RET
38*2191d502SJeremy Morse
396a471403STobias Boschentry:
406a471403STobias Bosch  call void @llvm.dbg.value(metadata i64 %t1, metadata !13, metadata !DIExpression()), !dbg !14
416a471403STobias Bosch  %0 = trunc i64 %t1 to i32, !dbg !15
426a471403STobias Bosch  ret i32 %0, !dbg !16
436a471403STobias Bosch}
446a471403STobias Bosch
456a471403STobias Boschdeclare void @llvm.dbg.value(metadata, metadata, metadata) #1
466a471403STobias Bosch
476a471403STobias Boschattributes #0 = { norecurse nounwind readnone uwtable }
486a471403STobias Boschattributes #1 = { nounwind readnone speculatable willreturn }
496a471403STobias Bosch
506a471403STobias Bosch!llvm.dbg.cu = !{!0}
516a471403STobias Bosch!llvm.module.flags = !{!3, !4, !5}
526a471403STobias Bosch!llvm.ident = !{!6}
536a471403STobias Bosch
546a471403STobias Bosch!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
556a471403STobias Boschd7ed17334cf0b76e6a5922)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
566a471403STobias Bosch!1 = !DIFile(filename: "test.cc", directory: "")
576a471403STobias Bosch!2 = !{}
586a471403STobias Bosch!3 = !{i32 7, !"Dwarf Version", i32 4}
596a471403STobias Bosch!4 = !{i32 2, !"Debug Info Version", i32 3}
606a471403STobias Bosch!5 = !{i32 1, !"wchar_size", i32 4}
616a471403STobias Bosch!6 = !{!"clang version 11.0.0 (git@github.com:tbosch/llvm-project.git 0b11aed869bf09ba60d7ed17334cf0b76e6a5922)"}
626a471403STobias Bosch!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)
636a471403STobias Bosch!8 = !DISubroutineType(types: !9)
646a471403STobias Bosch!9 = !{!10, !11}
656a471403STobias Bosch!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
666a471403STobias Bosch!11 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
676a471403STobias Bosch!12 = !{!13}
686a471403STobias Bosch!13 = !DILocalVariable(name: "t1", arg: 1, scope: !7, file: !1, line: 1, type: !11)
696a471403STobias Bosch!14 = !DILocation(line: 0, scope: !7)
706a471403STobias Bosch!15 = !DILocation(line: 2, column: 10, scope: !7)
716a471403STobias Bosch!16 = !DILocation(line: 2, column: 3, scope: !7)
72