xref: /llvm-project/llvm/test/Linker/debug-info-use-before-def.ll (revision 094572701dce4aaf36f4521d6cf750420d39f206)
1; RUN: llvm-link -S %s | FileCheck %s
2; RUN: llvm-link -S %s --try-experimental-debuginfo-iterators | FileCheck %s
3
4; Test that when a debug metadata use-before-def is run through llvm-link, the
5; value reference is preserved. Tests both singular uses and DIArgList uses of
6; the value.
7
8; CHECK-LABEL: @test
9; CHECK: #dbg_value(i32 %A,
10; CHECK-NEXT: #dbg_value(!DIArgList(i32 0, i32 %A),
11; CHECK-NEXT: %A =
12
13target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
14target triple = "spir64-unknown-unknown-intelfpga"
15
16define void @test() {
17entry:
18  call void @llvm.dbg.value(metadata i32 %A, metadata !5, metadata !DIExpression()), !dbg !10
19  call void @llvm.dbg.value(metadata !DIArgList(i32 0, i32 %A), metadata !5, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_minus, DW_OP_stack_value)), !dbg !10
20  %A = add i32 0, 1
21  ret void
22}
23
24declare void @llvm.dbg.value(metadata, metadata, metadata)
25
26!llvm.dbg.cu = !{!0}
27!llvm.module.flags = !{!2, !3, !4}
28
29!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "bogus", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
30!1 = !DIFile(filename: "test.c", directory: "test")
31!2 = !{i32 7, !"Dwarf Version", i32 4}
32!3 = !{i32 2, !"Debug Info Version", i32 3}
33!4 = !{i32 1, !"wchar_size", i32 4}
34!5 = !DILocalVariable(name: "A", arg: 2, scope: !6, file: !1, line: 60, type: !9)
35!6 = distinct !DISubprogram(name: "test", linkageName: "_test", scope: !1, file: !1, line: 60, type: !7, scopeLine: 61, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
36!7 = !DISubroutineType(types: !8)
37!8 = !{null}
38!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
39!10 = !DILocation(line: 0, scope: !6)
40