1 ; RUN: verify-uselistorder %s
3 ; Reproducer for PR36778.
5 ; Verify that uses in metadata operands are considered when generating the
6 ; use-list order. In this case the use-list order for @global_arr was not
7 ; correctly preserved due to the uses in the dbg.value contant expressions not
8 ; being considered, since they are wrapped in metadata.
10 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11 target triple = "x86_64-unknown-linux-gnu"
13 @global = local_unnamed_addr global i64 0, align 8
14 @global_arr = common local_unnamed_addr global [10 x i64] zeroinitializer, align 16
16 define void @foo() local_unnamed_addr !dbg !6 {
18 %0 = load i64, ptr getelementptr inbounds ([10 x i64], ptr @global_arr, i64 0, i64 4), align 16
19 call void @llvm.dbg.value(metadata ptr getelementptr inbounds ([10 x i64], ptr @global_arr, i64 0, i64 5), metadata !10, metadata !DIExpression()), !dbg !13
20 %1 = load i64, ptr getelementptr inbounds ([10 x i64], ptr @global_arr, i64 0, i64 6), align 16
21 call void @llvm.dbg.value(metadata ptr getelementptr inbounds ([10 x i64], ptr @global_arr, i64 0, i64 6), metadata !10, metadata !DIExpression()), !dbg !14
25 define void @bar() local_unnamed_addr !dbg !15 {
27 call void @llvm.dbg.value(metadata ptr getelementptr inbounds ([10 x i64], ptr @global_arr, i64 0, i64 7), metadata !17, metadata !DIExpression()), !dbg !18
31 ; Function Attrs: nounwind readnone speculatable
32 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
34 attributes #0 = { nounwind readnone speculatable }
37 !llvm.module.flags = !{!3, !4}
40 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !2, nameTableKind: None)
41 !1 = !DIFile(filename: "uses.c", directory: "/")
43 !3 = !{i32 2, !"Dwarf Version", i32 4}
44 !4 = !{i32 2, !"Debug Info Version", i32 3}
45 !5 = !{!"clang version 8.0.0"}
46 !6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 6, type: !7, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: true, unit: !0, retainedNodes: !9)
47 !7 = !DISubroutineType(types: !8)
50 !10 = !DILocalVariable(name: "local1", scope: !6, file: !1, line: 7, type: !11)
51 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
52 !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
53 !13 = !DILocation(line: 8, column: 8, scope: !6)
54 !14 = !DILocation(line: 7, column: 9, scope: !6)
55 !15 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 12, type: !7, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !0, retainedNodes: !16)
57 !17 = !DILocalVariable(name: "local2", scope: !15, file: !1, line: 13, type: !11)
58 !18 = !DILocation(line: 14, column: 1, scope: !15)