1; RUN: opt -verify < %s | opt -verify -S | FileCheck %s
2
3; Simple IR-BC-IR round-trip test for a @llvm.dbg.value that uses !DIArgList
4; and DW_OP_LLVM_arg.
5
6source_filename = ".\\debug_value_list.cpp"
7target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-pc-windows-msvc19.16.27034"
9
10; CHECK-COUNT-3: llvm.dbg.value(
11; CHECK-SAME: metadata !DIArgList(i32 %a, i32 %b, i32 5)
12; CHECK-SAME: metadata !16,
13; CHECK-SAME: metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_LLVM_arg, 2, DW_OP_plus)
14define dso_local i32 @"?foo@@YAHHH@Z"(i32 %a, i32 %b) local_unnamed_addr !dbg !8 {
15entry:
16  call void @llvm.dbg.value(metadata !DIArgList(i32 %b), metadata !14, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
17  call void @llvm.dbg.value(metadata !DIArgList(i32 %a), metadata !15, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !17
18  call void @llvm.dbg.value(
19    metadata !DIArgList(i32 %a, i32 %b, i32 5),
20    metadata !16,
21    metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus, DW_OP_LLVM_arg, 2, DW_OP_plus)), !dbg !17
22  %mul = mul nsw i32 %b, %a, !dbg !18
23  ret i32 %mul, !dbg !18
24}
25
26declare void @llvm.dbg.value(metadata, metadata, metadata)
27
28!llvm.dbg.cu = !{!0}
29!llvm.module.flags = !{!3, !4, !5, !6}
30!llvm.ident = !{!7}
31
32!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
33!1 = !DIFile(filename: "debug_value_list.cpp", directory: "/tmp")
34!2 = !{}
35!3 = !{i32 2, !"CodeView", i32 1}
36!4 = !{i32 2, !"Debug Info Version", i32 3}
37!5 = !{i32 1, !"wchar_size", i32 2}
38!6 = !{i32 7, !"PIC Level", i32 2}
39!7 = !{!"clang version 11.0.0"}
40!8 = distinct !DISubprogram(name: "foo", linkageName: "?foo@@YAHHH@Z", scope: !9, file: !9, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
41!9 = !DIFile(filename: ".\\debug_value_list.cpp", directory: "/tmp")
42!10 = !DISubroutineType(types: !11)
43!11 = !{!12, !12, !12}
44!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
45!13 = !{!14, !15, !16}
46!14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !9, line: 1, type: !12)
47!15 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !9, line: 1, type: !12)
48!16 = !DILocalVariable(name: "c", scope: !8, file: !9, line: 2, type: !12)
49!17 = !DILocation(line: 0, scope: !8)
50!18 = !DILocation(line: 3, scope: !8)
51