1; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | \
2; RUN:     llvm-dwarfdump --name i --name indirect - | FileCheck %s
3;
4; This is a hand-crafted testcase generated from:
5;   int i = 23;
6;   int *indirect = &i;
7
8; CHECK: DW_TAG_variable
9; CHECK:   DW_AT_name	("i")
10; CHECK:   DW_AT_location	(DW_OP_addr 0x8, DW_OP_deref)
11; CHECK: DW_TAG_variable
12; CHECK:   DW_AT_name	("indirect")
13; CHECK:   DW_AT_location	(DW_OP_addr 0x8
14
15source_filename = "global-deref.c"
16target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
17target triple = "x86_64-apple-macosx10.13.0"
18
19@i = global i32 23, align 4
20@indirect = global i32* @i, align 8, !dbg !6, !dbg !0, !dbg !14, !dbg !15, !dbg !16
21
22!llvm.dbg.cu = !{!2}
23!llvm.module.flags = !{!10, !11, !12, !13}
24
25!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression(DW_OP_deref))
26!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 1, type: !9, isLocal: false, isDefinition: true)
27!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
28!3 = !DIFile(filename: "global-deref.c", directory: "/")
29!4 = !{}
30!5 = !{!0, !6}
31!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
32!7 = distinct !DIGlobalVariable(name: "indirect", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
33!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
34!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
35!10 = !{i32 2, !"Dwarf Version", i32 4}
36!11 = !{i32 2, !"Debug Info Version", i32 3}
37!12 = !{i32 1, !"wchar_size", i32 4}
38!13 = !{i32 7, !"PIC Level", i32 2}
39; This is malformed, but too expensive to detect in the verifier.
40!14 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
41!15 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression(DW_OP_LLVM_fragment, 0, 1))
42!16 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression(DW_OP_deref, DW_OP_constu, 1, DW_OP_plus, DW_OP_stack_value))
43